forked from shadowfacts/Tusker
Fix crash when loading account
This commit is contained in:
parent
20dab7c77a
commit
7465abe0a9
|
@ -120,10 +120,21 @@ class ProfileViewController: UIPageViewController {
|
||||||
let req = Client.getAccount(id: accountID)
|
let req = Client.getAccount(id: accountID)
|
||||||
mastodonController.run(req) { [weak self] (response) in
|
mastodonController.run(req) { [weak self] (response) in
|
||||||
guard let self = self else { return }
|
guard let self = self else { return }
|
||||||
guard case let .success(account, _) = response else { fatalError() }
|
switch response {
|
||||||
self.mastodonController.persistentContainer.addOrUpdate(account: account, incrementReferenceCount: true) { (account) in
|
case .success(let account, _):
|
||||||
|
self.mastodonController.persistentContainer.addOrUpdate(account: account, incrementReferenceCount: true) { (account) in
|
||||||
|
DispatchQueue.main.async {
|
||||||
|
self.updateAccountUI()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
case .failure(let error):
|
||||||
DispatchQueue.main.async {
|
DispatchQueue.main.async {
|
||||||
self.updateAccountUI()
|
let config = ToastConfiguration(from: error, with: "Loading", in: self) { [unowned self] (toast) in
|
||||||
|
toast.dismissToast(animated: true)
|
||||||
|
self.loadAccount()
|
||||||
|
}
|
||||||
|
self.showToast(configuration: config, animated: true)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -271,3 +282,6 @@ extension ProfileViewController: TabbedPageViewController {
|
||||||
selectPage(at: currentIndex - 1, animated: true)
|
selectPage(at: currentIndex - 1, animated: true)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
extension ProfileViewController: ToastableViewController {
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue