|
|
|
|
@ -142,8 +142,9 @@ final class JoinPublicChatVC : BaseVC, UIPageViewControllerDataSource, UIPageVie
|
|
|
|
|
transaction.removeObject(forKey: "\(urlAsString).\(channelID)", inCollection: PublicChatAPI.lastMessageServerIDCollection)
|
|
|
|
|
transaction.removeObject(forKey: "\(urlAsString).\(channelID)", inCollection: PublicChatAPI.lastDeletionServerIDCollection)
|
|
|
|
|
}
|
|
|
|
|
ModalActivityIndicatorViewController.present(fromViewController: navigationController!, canCancel: false) { [weak self] _ in
|
|
|
|
|
PublicChatManager.shared.addChat(server: urlAsString, channel: channelID)
|
|
|
|
|
.done(on: .main) { [weak self] _ in
|
|
|
|
|
.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)
|
|
|
|
|
@ -151,7 +152,8 @@ final class JoinPublicChatVC : BaseVC, UIPageViewControllerDataSource, UIPageVie
|
|
|
|
|
let _ = syncManager.syncAllOpenGroups()
|
|
|
|
|
self?.presentingViewController!.dismiss(animated: true, completion: nil)
|
|
|
|
|
}
|
|
|
|
|
.catch(on: .main) { [weak self] error in
|
|
|
|
|
.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 {
|
|
|
|
|
@ -162,6 +164,7 @@ final class JoinPublicChatVC : BaseVC, UIPageViewControllerDataSource, UIPageVie
|
|
|
|
|
self?.showError(title: title, message: message)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// MARK: Convenience
|
|
|
|
|
private func showError(title: String, message: String = "") {
|
|
|
|
|
|