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 {
|
class ProfileStatusesViewController: UIViewController, TimelineLikeCollectionViewController {
|
||||||
|
|
||||||
unowned var owner: ProfileViewController
|
weak var owner: ProfileViewController?
|
||||||
var mastodonController: MastodonController { owner.mastodonController }
|
let mastodonController: MastodonController
|
||||||
private(set) var accountID: String!
|
private(set) var accountID: String!
|
||||||
let kind: Kind
|
let kind: Kind
|
||||||
var initialHeaderMode: HeaderMode?
|
var initialHeaderMode: HeaderMode?
|
||||||
|
@ -37,6 +37,7 @@ class ProfileStatusesViewController: UIViewController, TimelineLikeCollectionVie
|
||||||
self.accountID = accountID
|
self.accountID = accountID
|
||||||
self.kind = kind
|
self.kind = kind
|
||||||
self.owner = owner
|
self.owner = owner
|
||||||
|
self.mastodonController = owner.mastodonController
|
||||||
|
|
||||||
super.init(nibName: nil, bundle: nil)
|
super.init(nibName: nil, bundle: nil)
|
||||||
|
|
||||||
|
@ -130,7 +131,7 @@ class ProfileStatusesViewController: UIViewController, TimelineLikeCollectionVie
|
||||||
let view = ProfileHeaderView.create()
|
let view = ProfileHeaderView.create()
|
||||||
view.delegate = self.profileHeaderDelegate
|
view.delegate = self.profileHeaderDelegate
|
||||||
view.updateUI(for: id)
|
view.updateUI(for: id)
|
||||||
view.pagesSegmentedControl.selectedSegmentIndex = self.owner.currentIndex ?? 0
|
view.pagesSegmentedControl.selectedSegmentIndex = self.owner?.currentIndex ?? 0
|
||||||
cell.addHeader(view)
|
cell.addHeader(view)
|
||||||
case .placeholder(height: let height):
|
case .placeholder(height: let height):
|
||||||
_ = cell.addConstraint(height: height)
|
_ = cell.addConstraint(height: height)
|
||||||
|
|
|
@ -119,12 +119,12 @@ class ProfileHeaderView: UIView {
|
||||||
|
|
||||||
let request = Client.getRelationships(accounts: [accountID])
|
let request = Client.getRelationships(accounts: [accountID])
|
||||||
mastodonController.run(request) { [weak self] (response) in
|
mastodonController.run(request) { [weak self] (response) in
|
||||||
guard let self = self,
|
guard let mastodonController = self?.mastodonController,
|
||||||
case let .success(results, _) = response,
|
case let .success(results, _) = response,
|
||||||
let relationship = results.first else {
|
let relationship = results.first else {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
self.mastodonController.persistentContainer.addOrUpdate(relationship: relationship)
|
mastodonController.persistentContainer.addOrUpdate(relationship: relationship)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue