Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

837 inviter a rejoindre tchap erreur avec le mainlining 1 83 #889

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
120 changes: 60 additions & 60 deletions Riot/Modules/Home/AllChats/AllChatsCoordinator.swift
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ class AllChatsCoordinator: NSObject, SplitViewMasterCoordinatorProtocol {
private var indicators = [UserIndicator]()
private var signOutFlowPresenter: SignOutFlowPresenter?
// Tchap: Add invite service for user invitation
private var inviteService: InviteServiceType?
// private var inviteService: InviteServiceType?
private var errorPresenter: ErrorPresenter?
private weak var currentAlertController: UIAlertController?

Expand Down Expand Up @@ -360,7 +360,7 @@ class AllChatsCoordinator: NSObject, SplitViewMasterCoordinatorProtocol {
!UserService.isExternalUser(for: userID) {
subMenuActions.append(UIAction(title: TchapL10n.sideMenuActionInviteFriends, image: UIImage(systemName: "square.and.arrow.up.fill")) { [weak self] action in
guard let self = self else { return }
self.showInviteFriends(from: self.avatarMenuButton)
self.allChatsViewController.startChat()
})
}
}
Expand Down Expand Up @@ -644,15 +644,15 @@ class AllChatsCoordinator: NSObject, SplitViewMasterCoordinatorProtocol {
// }

private func showInviteFriends(from sourceView: UIView?) {
// Tchap: Use Tchap specific mechanism.
promptUserToFillAnEmailToInvite { [weak self] email in
self?.sendEmailInvite(to: email)
}

// let myUserId = self.parameters.userSessionsService.mainUserSession?.userId ?? ""
//
// let inviteFriendsPresenter = InviteFriendsPresenter()
// inviteFriendsPresenter.present(for: myUserId, from: self.navigationRouter.toPresentable(), sourceView: sourceView, animated: true)
// // Tchap: Use Tchap specific mechanism.
// promptUserToFillAnEmailToInvite { [weak self] email in
// self?.sendEmailInvite(to: email)
// }
//
//// let myUserId = self.parameters.userSessionsService.mainUserSession?.userId ?? ""
////
//// let inviteFriendsPresenter = InviteFriendsPresenter()
//// inviteFriendsPresenter.present(for: myUserId, from: self.navigationRouter.toPresentable(), sourceView: sourceView, animated: true)
}

private func showBugReport() {
Expand Down Expand Up @@ -911,55 +911,55 @@ extension AllChatsCoordinator {
}

private func sendEmailInvite(to email: String) {
guard let session = self.currentMatrixSession else { return }
if self.inviteService == nil {
self.inviteService = InviteService(session: session)
}
guard let inviteService = self.inviteService else { return }

self.activityIndicatorPresenter.presentActivityIndicator(on: self.navigationRouter.toPresentable().view, animated: true)
inviteService.sendEmailInvite(to: email) { [weak self] (response) in
guard let sself = self else {
return
}

sself.activityIndicatorPresenter.removeCurrentActivityIndicator(animated: true)
switch response {
case .success(let result):
var message: String
var discoveredUserID: String?
switch result {
case .inviteHasBeenSent(roomID: _):
message = TchapL10n.inviteSendingSucceeded
case .inviteAlreadySent(roomID: _):
message = TchapL10n.inviteAlreadySentByEmail(email)
case .inviteIgnoredForDiscoveredUser(userID: let userID):
discoveredUserID = userID
message = TchapL10n.inviteNotSentForDiscoveredUser
case .inviteIgnoredForUnauthorizedEmail:
message = TchapL10n.inviteNotSentForUnauthorizedEmail(email)
}

sself.currentAlertController?.dismiss(animated: false)

let alert = UIAlertController(title: TchapL10n.inviteInformationTitle, message: message, preferredStyle: .alert)

let okTitle = VectorL10n.ok
let okAction = UIAlertAction(title: okTitle, style: .default, handler: { action in
if let userID = discoveredUserID {
// Open the discussion
AppDelegate.theDelegate().startDirectChat(withUserId: userID, completion: nil)
}
})
alert.addAction(okAction)
sself.currentAlertController = alert

sself.navigationRouter.toPresentable().present(alert, animated: true, completion: nil)
case .failure(let error):
let errorPresentable = sself.inviteErrorPresentable(from: error)
sself.errorPresenter?.present(errorPresentable: errorPresentable, animated: true)
}
}
// guard let session = self.currentMatrixSession else { return }
// if self.inviteService == nil {
// self.inviteService = InviteService(session: session)
// }
// guard let inviteService = self.inviteService else { return }
//
// self.activityIndicatorPresenter.presentActivityIndicator(on: self.navigationRouter.toPresentable().view, animated: true)
// inviteService.sendEmailInvite(to: email) { [weak self] (response) in
// guard let sself = self else {
// return
// }
//
// sself.activityIndicatorPresenter.removeCurrentActivityIndicator(animated: true)
// switch response {
// case .success(let result):
// var message: String
// var discoveredUserID: String?
// switch result {
// case .inviteHasBeenSent(roomID: _):
// message = TchapL10n.inviteSendingSucceeded
// case .inviteAlreadySent(roomID: _):
// message = TchapL10n.inviteAlreadySentByEmail(email)
// case .inviteIgnoredForDiscoveredUser(userID: let userID):
// discoveredUserID = userID
// message = TchapL10n.inviteNotSentForDiscoveredUser
// case .inviteIgnoredForUnauthorizedEmail:
// message = TchapL10n.inviteNotSentForUnauthorizedEmail(email)
// }
//
// sself.currentAlertController?.dismiss(animated: false)
//
// let alert = UIAlertController(title: TchapL10n.inviteInformationTitle, message: message, preferredStyle: .alert)
//
// let okTitle = VectorL10n.ok
// let okAction = UIAlertAction(title: okTitle, style: .default, handler: { action in
// if let userID = discoveredUserID {
// // Open the discussion
// AppDelegate.theDelegate().startDirectChat(withUserId: userID, completion: nil)
// }
// })
// alert.addAction(okAction)
// sself.currentAlertController = alert
//
// sself.navigationRouter.toPresentable().present(alert, animated: true, completion: nil)
// case .failure(let error):
// let errorPresentable = sself.inviteErrorPresentable(from: error)
// sself.errorPresenter?.present(errorPresentable: errorPresentable, animated: true)
// }
// }
}

private func inviteErrorPresentable(from error: Error) -> ErrorPresentable {
Expand Down
100 changes: 50 additions & 50 deletions Riot/Modules/TabBar/TabBarCoordinator.swift
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ final class TabBarCoordinator: NSObject, SplitViewMasterCoordinatorProtocol {

private var indicators = [UserIndicator]()
// Tchap: Add invite service for user invitation
private var inviteService: InviteServiceType?
// private var inviteService: InviteServiceType?
private var errorPresenter: ErrorPresenter?
private weak var currentAlertController: UIAlertController?

Expand Down Expand Up @@ -1020,55 +1020,55 @@ extension TabBarCoordinator {
}

private func sendEmailInvite(to email: String) {
guard let session = self.currentMatrixSession else { return }
if self.inviteService == nil {
self.inviteService = InviteService(session: session)
}
guard let inviteService = self.inviteService else { return }

self.activityIndicatorPresenter.presentActivityIndicator(on: masterTabBarController.view, animated: true)
inviteService.sendEmailInvite(to: email) { [weak self] (response) in
guard let sself = self else {
return
}

sself.activityIndicatorPresenter.removeCurrentActivityIndicator(animated: true)
switch response {
case .success(let result):
var message: String
var discoveredUserID: String?
switch result {
case .inviteHasBeenSent(roomID: _):
message = TchapL10n.inviteSendingSucceeded
case .inviteAlreadySent(roomID: _):
message = TchapL10n.inviteAlreadySentByEmail(email)
case .inviteIgnoredForDiscoveredUser(userID: let userID):
discoveredUserID = userID
message = TchapL10n.inviteNotSentForDiscoveredUser
case .inviteIgnoredForUnauthorizedEmail:
message = TchapL10n.inviteNotSentForUnauthorizedEmail(email)
}

sself.currentAlertController?.dismiss(animated: false)

let alert = UIAlertController(title: TchapL10n.inviteInformationTitle, message: message, preferredStyle: .alert)

let okTitle = VectorL10n.ok
let okAction = UIAlertAction(title: okTitle, style: .default, handler: { action in
if let userID = discoveredUserID {
// Open the discussion
AppDelegate.theDelegate().startDirectChat(withUserId: userID, completion: nil)
}
})
alert.addAction(okAction)
sself.currentAlertController = alert

sself.masterTabBarController.present(alert, animated: true, completion: nil)
case .failure(let error):
let errorPresentable = sself.inviteErrorPresentable(from: error)
sself.errorPresenter?.present(errorPresentable: errorPresentable, animated: true)
}
}
// guard let session = self.currentMatrixSession else { return }
// if self.inviteService == nil {
// self.inviteService = InviteService(session: session)
// }
// guard let inviteService = self.inviteService else { return }
//
// self.activityIndicatorPresenter.presentActivityIndicator(on: masterTabBarController.view, animated: true)
// inviteService.sendEmailInvite(to: email) { [weak self] (response) in
// guard let sself = self else {
// return
// }
//
// sself.activityIndicatorPresenter.removeCurrentActivityIndicator(animated: true)
// switch response {
// case .success(let result):
// var message: String
// var discoveredUserID: String?
// switch result {
// case .inviteHasBeenSent(roomID: _):
// message = TchapL10n.inviteSendingSucceeded
// case .inviteAlreadySent(roomID: _):
// message = TchapL10n.inviteAlreadySentByEmail(email)
// case .inviteIgnoredForDiscoveredUser(userID: let userID):
// discoveredUserID = userID
// message = TchapL10n.inviteNotSentForDiscoveredUser
// case .inviteIgnoredForUnauthorizedEmail:
// message = TchapL10n.inviteNotSentForUnauthorizedEmail(email)
// }
//
// sself.currentAlertController?.dismiss(animated: false)
//
// let alert = UIAlertController(title: TchapL10n.inviteInformationTitle, message: message, preferredStyle: .alert)
//
// let okTitle = VectorL10n.ok
// let okAction = UIAlertAction(title: okTitle, style: .default, handler: { action in
// if let userID = discoveredUserID {
// // Open the discussion
// AppDelegate.theDelegate().startDirectChat(withUserId: userID, completion: nil)
// }
// })
// alert.addAction(okAction)
// sself.currentAlertController = alert
//
// sself.masterTabBarController.present(alert, animated: true, completion: nil)
// case .failure(let error):
// let errorPresentable = sself.inviteErrorPresentable(from: error)
// sself.errorPresenter?.present(errorPresentable: errorPresentable, animated: true)
// }
// }
}

private func inviteErrorPresentable(from error: Error) -> ErrorPresentable {
Expand Down
Loading
Loading