forked from shadowfacts/Tusker
Fix crash in profile due to accessing data source before it exists
This could happen if an account is updated in the background while a profile is on screen and the user has not visited all of the tabs.
This commit is contained in:
parent
0e06d47687
commit
cbbe9ec11f
|
@ -41,16 +41,6 @@ class ProfileStatusesViewController: UIViewController, TimelineLikeCollectionVie
|
|||
|
||||
self.controller = TimelineLikeController(delegate: self)
|
||||
|
||||
mastodonController.persistentContainer.accountSubject
|
||||
.receive(on: DispatchQueue.main)
|
||||
.filter { [unowned self] in $0 == self.accountID }
|
||||
.sink { [unowned self] id in
|
||||
var snapshot = dataSource.snapshot()
|
||||
snapshot.reconfigureItems([.header(id)])
|
||||
dataSource.apply(snapshot, animatingDifferences: true)
|
||||
}
|
||||
.store(in: &cancellables)
|
||||
|
||||
addKeyCommand(MenuController.refreshCommand(discoverabilityTitle: "Refresh Profile"))
|
||||
}
|
||||
|
||||
|
@ -97,7 +87,16 @@ class ProfileStatusesViewController: UIViewController, TimelineLikeCollectionVie
|
|||
|
||||
override func viewDidLoad() {
|
||||
super.viewDidLoad()
|
||||
|
||||
|
||||
mastodonController.persistentContainer.accountSubject
|
||||
.receive(on: DispatchQueue.main)
|
||||
.filter { [unowned self] in $0 == self.accountID }
|
||||
.sink { [unowned self] id in
|
||||
var snapshot = dataSource.snapshot()
|
||||
snapshot.reconfigureItems([.header(id)])
|
||||
dataSource.apply(snapshot, animatingDifferences: true)
|
||||
}
|
||||
.store(in: &cancellables)
|
||||
}
|
||||
|
||||
private func createDataSource() -> UICollectionViewDiffableDataSource<Section, Item> {
|
||||
|
|
Loading…
Reference in New Issue