Prompt the user when the invited MatrixId is not recognized (#8483)
This commit is contained in:
parent
824f3802b2
commit
07e06957ef
|
@ -0,0 +1 @@
|
|||
Prompt the user when the invited MatrixId is not recognized
|
|
@ -1729,6 +1729,8 @@
|
|||
<string name="create_room_public_title">"Public"</string>
|
||||
<string name="create_room_public_description">"Anyone will be able to join this room"</string>
|
||||
<string name="create_room_federation_error">"The room has been created, but some invitations have not been sent for the following reason:\n\n%s"</string>
|
||||
<string name="create_room_unknown_users_dialog_content">Unable to find profiles for the Matrix IDs listed below. Would you like to start a chat anyway?\n\n%s</string>
|
||||
<string name="create_room_unknown_users_dialog_submit">Start chat anyway</string>
|
||||
|
||||
<string name="keys_backup_unable_to_get_trust_info">"An error occurred getting trust info"</string>
|
||||
<string name="keys_backup_unable_to_get_keys_backup_data">"An error occurred getting keys backup data"</string>
|
||||
|
@ -2744,6 +2746,8 @@
|
|||
<item quantity="other">Invitations sent to %1$s and %2$d more</item>
|
||||
</plurals>
|
||||
<string name="invite_users_to_room_failure">We could not invite users. Please check the users you want to invite and try again.</string>
|
||||
<string name="invite_unknown_users_dialog_content">Unable to find profiles for the Matrix IDs listed below. Would you like to invite them anyway?\n\n%s</string>
|
||||
<string name="invite_unknown_users_dialog_submit">Invite anyway</string>
|
||||
|
||||
<string name="user_code_scan">Scan a QR code</string>
|
||||
<string name="user_code_share">Share my code</string>
|
||||
|
|
|
@ -48,6 +48,7 @@ import im.vector.app.features.qrcode.QrCodeScannerEvents
|
|||
import im.vector.app.features.qrcode.QrCodeScannerFragment
|
||||
import im.vector.app.features.qrcode.QrCodeScannerViewModel
|
||||
import im.vector.app.features.qrcode.QrScannerArgs
|
||||
import im.vector.app.features.userdirectory.PendingSelection
|
||||
import im.vector.app.features.userdirectory.UserListFragment
|
||||
import im.vector.app.features.userdirectory.UserListFragmentArgs
|
||||
import im.vector.app.features.userdirectory.UserListSharedAction
|
||||
|
@ -160,7 +161,19 @@ class CreateDirectRoomActivity : SimpleFragmentActivity() {
|
|||
}
|
||||
|
||||
private fun handleOnMenuItemSubmitClick(action: UserListSharedAction.OnMenuItemSubmitClick) {
|
||||
viewModel.handle(CreateDirectRoomAction.PrepareRoomWithSelectedUsers(action.selections))
|
||||
val unknownUsers = action.selections.filter { it is PendingSelection.UserPendingSelection && it.isUnknownUser }
|
||||
if (unknownUsers.isEmpty()) {
|
||||
viewModel.handle(CreateDirectRoomAction.PrepareRoomWithSelectedUsers(action.selections))
|
||||
} else {
|
||||
MaterialAlertDialogBuilder(this)
|
||||
.setTitle(R.string.dialog_title_confirmation)
|
||||
.setMessage(getString(R.string.create_room_unknown_users_dialog_content, unknownUsers.joinToString("\n • ", " • ") { it.getMxId() }))
|
||||
.setPositiveButton(R.string.create_room_unknown_users_dialog_submit) { _, _ ->
|
||||
viewModel.handle(CreateDirectRoomAction.PrepareRoomWithSelectedUsers(action.selections))
|
||||
}
|
||||
.setNegativeButton(R.string.action_cancel, null)
|
||||
.show()
|
||||
}
|
||||
}
|
||||
|
||||
private fun renderCreateAndInviteState(state: Async<String>) {
|
||||
|
|
|
@ -37,6 +37,7 @@ import im.vector.app.core.utils.onPermissionDeniedSnackbar
|
|||
import im.vector.app.core.utils.registerForPermissionsResult
|
||||
import im.vector.app.core.utils.toast
|
||||
import im.vector.app.features.contactsbook.ContactsBookFragment
|
||||
import im.vector.app.features.userdirectory.PendingSelection
|
||||
import im.vector.app.features.userdirectory.UserListFragment
|
||||
import im.vector.app.features.userdirectory.UserListFragmentArgs
|
||||
import im.vector.app.features.userdirectory.UserListSharedAction
|
||||
|
@ -94,7 +95,19 @@ class InviteUsersToRoomActivity : SimpleFragmentActivity() {
|
|||
}
|
||||
|
||||
private fun handleOnMenuItemSubmitClick(action: UserListSharedAction.OnMenuItemSubmitClick) {
|
||||
viewModel.handle(InviteUsersToRoomAction.InviteSelectedUsers(action.selections))
|
||||
val unknownUsers = action.selections.filter { it is PendingSelection.UserPendingSelection && it.isUnknownUser }
|
||||
if (unknownUsers.isEmpty()) {
|
||||
viewModel.handle(InviteUsersToRoomAction.InviteSelectedUsers(action.selections))
|
||||
} else {
|
||||
MaterialAlertDialogBuilder(this)
|
||||
.setTitle(R.string.dialog_title_confirmation)
|
||||
.setMessage(getString(R.string.invite_unknown_users_dialog_content, unknownUsers.joinToString("\n • ", " • ") { it.getMxId() }))
|
||||
.setPositiveButton(R.string.invite_unknown_users_dialog_submit) { _, _ ->
|
||||
viewModel.handle(InviteUsersToRoomAction.InviteSelectedUsers(action.selections))
|
||||
}
|
||||
.setNegativeButton(R.string.action_cancel, null)
|
||||
.show()
|
||||
}
|
||||
}
|
||||
|
||||
private fun openPhoneBook() {
|
||||
|
|
|
@ -22,7 +22,7 @@ import org.matrix.android.sdk.api.session.user.model.User
|
|||
import org.matrix.android.sdk.api.util.toMatrixItem
|
||||
|
||||
sealed class PendingSelection {
|
||||
data class UserPendingSelection(val user: User) : PendingSelection()
|
||||
data class UserPendingSelection(val user: User, var isUnknownUser: Boolean = false) : PendingSelection()
|
||||
data class ThreePidPendingSelection(val threePid: ThreePid) : PendingSelection()
|
||||
|
||||
fun getBestName(): String {
|
||||
|
|
|
@ -260,6 +260,7 @@ class UserListViewModel @AssistedInject constructor(
|
|||
.sortedBy { it.toMatrixItem().firstLetterOfDisplayName() }
|
||||
val userProfile = if (MatrixPatterns.isUserId(search)) {
|
||||
val user = tryOrNull { session.profileService().getProfileAsUser(search) }
|
||||
setState { copy(unknownUserId = search.takeIf { user == null }) }
|
||||
User(
|
||||
userId = search,
|
||||
displayName = user?.displayName,
|
||||
|
@ -284,6 +285,9 @@ class UserListViewModel @AssistedInject constructor(
|
|||
(action.pendingSelection is PendingSelection.UserPendingSelection &&
|
||||
state.pendingSelections.last() is PendingSelection.UserPendingSelection)
|
||||
if (canSelectUser) {
|
||||
if (action.pendingSelection is PendingSelection.UserPendingSelection) {
|
||||
action.pendingSelection.isUnknownUser = action.pendingSelection.getMxId() == state.unknownUserId
|
||||
}
|
||||
val selections = state.pendingSelections.toggle(action.pendingSelection, singleElement = state.singleSelection)
|
||||
setState { copy(pendingSelections = selections) }
|
||||
}
|
||||
|
|
|
@ -30,6 +30,7 @@ data class UserListViewState(
|
|||
val matchingEmail: Async<ThreePidUser?> = Uninitialized,
|
||||
val filteredMappedContacts: List<MappedContact> = emptyList(),
|
||||
val pendingSelections: Set<PendingSelection> = emptySet(),
|
||||
val unknownUserId: String? = null,
|
||||
val searchTerm: String = "",
|
||||
val singleSelection: Boolean,
|
||||
val single3pidSelection: Boolean,
|
||||
|
|
Loading…
Reference in New Issue