mirror of
https://gitlab.opencode.de/bwi/bundesmessenger/clients/bundesmessenger-ios.git
synced 2026-05-21 15:12:13 +02:00
Merge pull request #7571 from vector-im/nimau/7558_create_dm_unrecognized_matrixid
This commit is contained in:
@@ -366,6 +366,9 @@
|
||||
"room_creation_error_invite_user_by_email_without_identity_server" = "No identity server is configured so you cannot add a participant with an email.";
|
||||
"room_creation_dm_error" = "We couldn't create your DM. Please check the users you want to invite and try again.";
|
||||
"room_creation_only_one_email_invite" = "You can only invite one email at a time";
|
||||
"room_creation_user_not_found_prompt_title" = "Confirmation";
|
||||
"room_creation_user_not_found_prompt_message" = "Unable to find profiles for this Matrix ID. Would you like to start a DM anyway?";
|
||||
"room_creation_user_not_found_prompt_invite_action" = "Start DM anyway";
|
||||
|
||||
// Room recents
|
||||
"room_recents_directory_section" = "ROOM DIRECTORY";
|
||||
@@ -459,6 +462,8 @@ Tap the + to start adding people.";
|
||||
"room_participants_invite_prompt_title" = "Confirmation";
|
||||
"room_participants_invite_prompt_msg" = "Are you sure you want to invite %@ to this chat?";
|
||||
"room_participants_invite_prompt_to_msg" = "Are you sure you want to invite %@ to %@?";
|
||||
"room_participants_invite_unknown_participant_prompt_to_msg" = "Unable to find profiles for this Matrix ID. Are you sure you want to invite %@ to %@?";
|
||||
"room_participants_invite_anyway" = "Invite anyway";
|
||||
"room_participants_filter_room_members" = "Filter room members";
|
||||
"room_participants_filter_room_members_for_dm" = "Filter members";
|
||||
"room_participants_invite_another_user" = "Search / invite by User ID, Name or email";
|
||||
|
||||
@@ -5371,6 +5371,18 @@ public class VectorL10n: NSObject {
|
||||
public static var roomCreationTitle: String {
|
||||
return VectorL10n.tr("Vector", "room_creation_title")
|
||||
}
|
||||
/// Start DM anyway
|
||||
public static var roomCreationUserNotFoundPromptInviteAction: String {
|
||||
return VectorL10n.tr("Vector", "room_creation_user_not_found_prompt_invite_action")
|
||||
}
|
||||
/// Unable to find profiles for this Matrix ID. Would you like to start a DM anyway?
|
||||
public static var roomCreationUserNotFoundPromptMessage: String {
|
||||
return VectorL10n.tr("Vector", "room_creation_user_not_found_prompt_message")
|
||||
}
|
||||
/// Confirmation
|
||||
public static var roomCreationUserNotFoundPromptTitle: String {
|
||||
return VectorL10n.tr("Vector", "room_creation_user_not_found_prompt_title")
|
||||
}
|
||||
/// A room is already being created. Please wait.
|
||||
public static var roomCreationWaitForCreation: String {
|
||||
return VectorL10n.tr("Vector", "room_creation_wait_for_creation")
|
||||
@@ -6375,6 +6387,10 @@ public class VectorL10n: NSObject {
|
||||
public static var roomParticipantsInviteAnotherUser: String {
|
||||
return VectorL10n.tr("Vector", "room_participants_invite_another_user")
|
||||
}
|
||||
/// Invite anyway
|
||||
public static var roomParticipantsInviteAnyway: String {
|
||||
return VectorL10n.tr("Vector", "room_participants_invite_anyway")
|
||||
}
|
||||
/// Malformed ID. Should be an email address or a Matrix ID like '@localpart:domain'
|
||||
public static var roomParticipantsInviteMalformedId: String {
|
||||
return VectorL10n.tr("Vector", "room_participants_invite_malformed_id")
|
||||
@@ -6395,6 +6411,10 @@ public class VectorL10n: NSObject {
|
||||
public static func roomParticipantsInvitePromptToMsg(_ p1: String, _ p2: String) -> String {
|
||||
return VectorL10n.tr("Vector", "room_participants_invite_prompt_to_msg", p1, p2)
|
||||
}
|
||||
/// Unable to find profiles for this Matrix ID. Are you sure you want to invite %@ to %@?
|
||||
public static func roomParticipantsInviteUnknownParticipantPromptToMsg(_ p1: String, _ p2: String) -> String {
|
||||
return VectorL10n.tr("Vector", "room_participants_invite_unknown_participant_prompt_to_msg", p1, p2)
|
||||
}
|
||||
/// INVITED
|
||||
public static var roomParticipantsInvitedSection: String {
|
||||
return VectorL10n.tr("Vector", "room_participants_invited_section")
|
||||
|
||||
@@ -86,7 +86,7 @@
|
||||
}
|
||||
else if (_mxUser)
|
||||
{
|
||||
self.displayNameTextField.text = (_mxUser.displayname.length) ? _mxUser.displayname : nil;
|
||||
self.displayNameTextField.text = (_mxUser.displayname.length) ? _mxUser.displayname : _mxUser.userId;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
+8
@@ -138,4 +138,12 @@ extension ContactsPickerCoordinator: ContactsPickerViewModelCoordinatorDelegate
|
||||
|
||||
currentAlert = alert
|
||||
}
|
||||
|
||||
func contactsPickerViewModelDidStartValidatingUser(_ coordinator: ContactsPickerViewModelProtocol) {
|
||||
contactsPickerViewController?.startActivityIndicator()
|
||||
}
|
||||
|
||||
func contactsPickerViewModelDidEndValidatingUser(_ coordinator: ContactsPickerViewModelProtocol) {
|
||||
contactsPickerViewController?.stopActivityIndicator()
|
||||
}
|
||||
}
|
||||
|
||||
+23
-4
@@ -201,12 +201,31 @@ extension ContactsPickerViewModel: ContactsTableViewControllerDelegate {
|
||||
return
|
||||
}
|
||||
|
||||
// Check for user
|
||||
if MXTools.isMatrixUserIdentifier(contact.displayName) {
|
||||
let user = MXUser(userId: contact.displayName)
|
||||
coordinatorDelegate?.contactsPickerViewModelDidStartValidatingUser(self)
|
||||
user?.update(fromHomeserverOfMatrixSession: self.room.mxSession, success: { [weak self] in
|
||||
guard let self = self else { return }
|
||||
self.coordinatorDelegate?.contactsPickerViewModelDidEndValidatingUser(self)
|
||||
self.displayInvitePrompt(contact: contact)
|
||||
}, failure: { [weak self] error in
|
||||
guard let self = self else { return }
|
||||
self.coordinatorDelegate?.contactsPickerViewModelDidEndValidatingUser(self)
|
||||
self.displayInvitePrompt(contact: contact, isUnknownUser: true)
|
||||
})
|
||||
} else {
|
||||
displayInvitePrompt(contact: contact)
|
||||
}
|
||||
}
|
||||
|
||||
private func displayInvitePrompt(contact: MXKContact, isUnknownUser: Bool = false) {
|
||||
let roomName = room.displayName ?? VectorL10n.spaceTag
|
||||
let message = VectorL10n.roomParticipantsInvitePromptToMsg(contact.displayName, roomName)
|
||||
|
||||
let message = isUnknownUser ? VectorL10n.roomParticipantsInviteUnknownParticipantPromptToMsg(contact.displayName, roomName) : VectorL10n.roomParticipantsInvitePromptToMsg(contact.displayName, roomName)
|
||||
let inviteActionTitle = isUnknownUser ? VectorL10n.roomParticipantsInviteAnyway : VectorL10n.invite
|
||||
coordinatorDelegate?.contactsPickerViewModel(self, display: message, title: VectorL10n.roomParticipantsInvitePromptTitle, actions: [
|
||||
UIAlertAction(title: VectorL10n.cancel, style: .cancel, handler: nil),
|
||||
UIAlertAction(title: VectorL10n.invite, style: .default, handler: { [weak self] action in
|
||||
UIAlertAction(title: VectorL10n.cancel, style: .cancel),
|
||||
UIAlertAction(title: VectorL10n.invite, style: .default, handler: { [weak self] _ in
|
||||
self?.invite(contact: contact)
|
||||
})
|
||||
])
|
||||
|
||||
+2
@@ -23,6 +23,8 @@ protocol ContactsPickerViewModelCoordinatorDelegate: AnyObject {
|
||||
func contactsPickerViewModelDidEndInvite(_ viewModel: ContactsPickerViewModelProtocol)
|
||||
func contactsPickerViewModel(_ viewModel: ContactsPickerViewModelProtocol, inviteFailedWithError error: Error?)
|
||||
func contactsPickerViewModel(_ viewModel: ContactsPickerViewModelProtocol, display message: String, title: String, actions: [UIAlertAction])
|
||||
func contactsPickerViewModelDidStartValidatingUser(_ coordinator: ContactsPickerViewModelProtocol)
|
||||
func contactsPickerViewModelDidEndValidatingUser(_ coordinator: ContactsPickerViewModelProtocol)
|
||||
}
|
||||
|
||||
protocol ContactsPickerViewModelProtocol {
|
||||
|
||||
@@ -276,7 +276,6 @@ final class RoomCoordinator: NSObject, RoomCoordinatorProtocol {
|
||||
self.stopLoading()
|
||||
|
||||
self.parameters.session.store.store(user)
|
||||
|
||||
// Update RoomViewController with found target user
|
||||
self.roomViewController.displayNewDirectChat(withTargetUser: user, session: self.parameters.session)
|
||||
} failure: { [weak self] error in
|
||||
@@ -286,10 +285,18 @@ final class RoomCoordinator: NSObject, RoomCoordinatorProtocol {
|
||||
MXLog.error("[RoomCoordinator] User does not exist")
|
||||
|
||||
// Alert user
|
||||
self.displayError(message: VectorL10n.roomCreationDmError) { [weak self] in
|
||||
guard let self = self else { return }
|
||||
self.delegate?.roomCoordinatorDidCancelNewDirectChat(self)
|
||||
}
|
||||
self.displayUserNotFoundPrompt(
|
||||
invite: { [weak self] in
|
||||
guard let self = self else { return }
|
||||
self.parameters.session.store.store(MXUser(userId: userId))
|
||||
// Update RoomViewController with target user anyway
|
||||
self.roomViewController.displayNewDirectChat(withTargetUser: user, session: self.parameters.session)
|
||||
},
|
||||
cancel: { [weak self] in
|
||||
guard let self = self else { return }
|
||||
self.delegate?.roomCoordinatorDidCancelNewDirectChat(self)
|
||||
}
|
||||
)
|
||||
}
|
||||
}
|
||||
} else {
|
||||
@@ -525,6 +532,22 @@ final class RoomCoordinator: NSObject, RoomCoordinatorProtocol {
|
||||
alert.addAction(action)
|
||||
toPresentable().present(alert, animated: true)
|
||||
}
|
||||
|
||||
private func displayUserNotFoundPrompt(invite: (() -> Void)? = nil, cancel: (() -> Void)? = nil) {
|
||||
let title = VectorL10n.roomCreationUserNotFoundPromptTitle
|
||||
let message = VectorL10n.roomCreationUserNotFoundPromptMessage
|
||||
|
||||
let alert = UIAlertController(title: title, message: message, preferredStyle: .alert)
|
||||
let cancelAction = UIAlertAction(title: VectorL10n.cancel, style: .cancel) { _ in
|
||||
cancel?()
|
||||
}
|
||||
let inviteAction = UIAlertAction(title: VectorL10n.roomCreationUserNotFoundPromptInviteAction, style: .default) { _ in
|
||||
invite?()
|
||||
}
|
||||
alert.addAction(cancelAction)
|
||||
alert.addAction(inviteAction)
|
||||
toPresentable().present(alert, animated: true)
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: - RoomIdentifiable
|
||||
|
||||
@@ -2056,7 +2056,7 @@ static CGSize kThreadListBarButtonItemImageSize;
|
||||
{
|
||||
[userPictureView vc_setRoomAvatarImageWith:self.directChatTargetUser.avatarUrl
|
||||
roomId:self.directChatTargetUser.userId
|
||||
displayName:self.directChatTargetUser.displayname
|
||||
displayName:self.directChatTargetUser.displayname ?: self.directChatTargetUser.userId
|
||||
mediaManager:self.mainSession.mediaManager];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
Prompt the user when the invited MatrixId is not recognized
|
||||
Reference in New Issue
Block a user