forked from shadowfacts/Tusker
Fix crashes when ProfileStatusesVC doesn't finish loading until ProfileVC is deinit'd
This commit is contained in:
parent
16ba292afa
commit
4644475bc7
|
@ -12,8 +12,8 @@ import Combine
|
|||
|
||||
class ProfileStatusesViewController: UIViewController, TimelineLikeCollectionViewController {
|
||||
|
||||
unowned var owner: ProfileViewController
|
||||
var mastodonController: MastodonController { owner.mastodonController }
|
||||
weak var owner: ProfileViewController?
|
||||
let mastodonController: MastodonController
|
||||
private(set) var accountID: String!
|
||||
let kind: Kind
|
||||
var initialHeaderMode: HeaderMode?
|
||||
|
@ -37,6 +37,7 @@ class ProfileStatusesViewController: UIViewController, TimelineLikeCollectionVie
|
|||
self.accountID = accountID
|
||||
self.kind = kind
|
||||
self.owner = owner
|
||||
self.mastodonController = owner.mastodonController
|
||||
|
||||
super.init(nibName: nil, bundle: nil)
|
||||
|
||||
|
@ -130,7 +131,7 @@ class ProfileStatusesViewController: UIViewController, TimelineLikeCollectionVie
|
|||
let view = ProfileHeaderView.create()
|
||||
view.delegate = self.profileHeaderDelegate
|
||||
view.updateUI(for: id)
|
||||
view.pagesSegmentedControl.selectedSegmentIndex = self.owner.currentIndex ?? 0
|
||||
view.pagesSegmentedControl.selectedSegmentIndex = self.owner?.currentIndex ?? 0
|
||||
cell.addHeader(view)
|
||||
case .placeholder(height: let height):
|
||||
_ = cell.addConstraint(height: height)
|
||||
|
|
|
@ -119,12 +119,12 @@ class ProfileHeaderView: UIView {
|
|||
|
||||
let request = Client.getRelationships(accounts: [accountID])
|
||||
mastodonController.run(request) { [weak self] (response) in
|
||||
guard let self = self,
|
||||
guard let mastodonController = self?.mastodonController,
|
||||
case let .success(results, _) = response,
|
||||
let relationship = results.first else {
|
||||
return
|
||||
}
|
||||
self.mastodonController.persistentContainer.addOrUpdate(relationship: relationship)
|
||||
mastodonController.persistentContainer.addOrUpdate(relationship: relationship)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue