Show a loader while an open group is being joined
This commit is contained in:
parent
5d8ae82817
commit
11d4add8f9
|
@ -142,24 +142,27 @@ final class JoinPublicChatVC : BaseVC, UIPageViewControllerDataSource, UIPageVie
|
|||
transaction.removeObject(forKey: "\(urlAsString).\(channelID)", inCollection: PublicChatAPI.lastMessageServerIDCollection)
|
||||
transaction.removeObject(forKey: "\(urlAsString).\(channelID)", inCollection: PublicChatAPI.lastDeletionServerIDCollection)
|
||||
}
|
||||
PublicChatManager.shared.addChat(server: urlAsString, channel: channelID)
|
||||
.done(on: .main) { [weak self] _ in
|
||||
let _ = PublicChatAPI.setDisplayName(to: displayName, on: urlAsString)
|
||||
let _ = PublicChatAPI.setProfilePictureURL(to: profilePictureURL, using: profileKey, on: urlAsString)
|
||||
let _ = PublicChatAPI.join(channelID, on: urlAsString)
|
||||
let syncManager = SSKEnvironment.shared.syncManager
|
||||
let _ = syncManager.syncAllOpenGroups()
|
||||
self?.presentingViewController!.dismiss(animated: true, completion: nil)
|
||||
}
|
||||
.catch(on: .main) { [weak self] error in
|
||||
var title = NSLocalizedString("Couldn't Join", comment: "")
|
||||
var message = ""
|
||||
if case HTTP.Error.httpRequestFailed(let statusCode, _) = error, statusCode == 401 || statusCode == 403 {
|
||||
title = NSLocalizedString("Unauthorized", comment: "")
|
||||
message = NSLocalizedString("Please ask the open group operator to add you to the group.", comment: "")
|
||||
ModalActivityIndicatorViewController.present(fromViewController: navigationController!, canCancel: false) { [weak self] _ in
|
||||
PublicChatManager.shared.addChat(server: urlAsString, channel: channelID)
|
||||
.done(on: DispatchQueue.main) { [weak self] _ in
|
||||
let _ = PublicChatAPI.setDisplayName(to: displayName, on: urlAsString)
|
||||
let _ = PublicChatAPI.setProfilePictureURL(to: profilePictureURL, using: profileKey, on: urlAsString)
|
||||
let _ = PublicChatAPI.join(channelID, on: urlAsString)
|
||||
let syncManager = SSKEnvironment.shared.syncManager
|
||||
let _ = syncManager.syncAllOpenGroups()
|
||||
self?.presentingViewController!.dismiss(animated: true, completion: nil)
|
||||
}
|
||||
.catch(on: DispatchQueue.main) { [weak self] error in
|
||||
self?.dismiss(animated: true, completion: nil) // Dismiss the loader
|
||||
var title = NSLocalizedString("Couldn't Join", comment: "")
|
||||
var message = ""
|
||||
if case HTTP.Error.httpRequestFailed(let statusCode, _) = error, statusCode == 401 || statusCode == 403 {
|
||||
title = NSLocalizedString("Unauthorized", comment: "")
|
||||
message = NSLocalizedString("Please ask the open group operator to add you to the group.", comment: "")
|
||||
}
|
||||
self?.isJoining = false
|
||||
self?.showError(title: title, message: message)
|
||||
}
|
||||
self?.isJoining = false
|
||||
self?.showError(title: title, message: message)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -189,7 +189,7 @@ final class NewClosedGroupVC : BaseVC, UITableViewDataSource, UITableViewDelegat
|
|||
self?.presentingViewController?.dismiss(animated: true, completion: nil)
|
||||
SignalApp.shared().presentConversation(for: thread, action: .compose, animated: false)
|
||||
}.catch(on: DispatchQueue.main) { _ in
|
||||
self?.dismiss(animated: true, completion: nil) // Dismiss the modal
|
||||
self?.dismiss(animated: true, completion: nil) // Dismiss the loader
|
||||
let title = NSLocalizedString("Couldn't Create Group", comment: "")
|
||||
let message = NSLocalizedString("Please check your internet connection and try again.", comment: "")
|
||||
let alert = UIAlertController(title: title, message: message, preferredStyle: .alert)
|
||||
|
|
Loading…
Reference in New Issue