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)
|
||||
mastodonController.run(req) { [weak self] (response) in
|
||||
guard let self = self else { return }
|
||||
guard case let .success(account, _) = response else { fatalError() }
|
||||
self.mastodonController.persistentContainer.addOrUpdate(account: account, incrementReferenceCount: true) { (account) in
|
||||
switch response {
|
||||
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 {
|
||||
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)
|
||||
}
|
||||
}
|
||||
|
||||
extension ProfileViewController: ToastableViewController {
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue