forked from zelo72/mastodon-ios
fix: suggestion account not thread safe issue
This commit is contained in:
parent
54ea1e9c0d
commit
cd36d7e4c3
|
@ -49,14 +49,22 @@ final class SuggestionAccountViewModel: NSObject {
|
|||
|
||||
super.init()
|
||||
|
||||
Publishers.CombineLatest(self.accounts,self.selectedAccounts)
|
||||
Publishers.CombineLatest(
|
||||
self.accounts,
|
||||
self.selectedAccounts
|
||||
)
|
||||
.receive(on: RunLoop.main)
|
||||
.sink { [weak self] accounts,selectedAccounts in
|
||||
self?.applyTableViewDataSource(accounts: accounts)
|
||||
self?.applySelectedCollectionViewDataSource(accounts: selectedAccounts)
|
||||
}
|
||||
.store(in: &disposeBag)
|
||||
|
||||
Publishers.CombineLatest(self.selectedAccounts,self.headerPlaceholderCount)
|
||||
Publishers.CombineLatest(
|
||||
self.selectedAccounts,
|
||||
self.headerPlaceholderCount
|
||||
)
|
||||
.receive(on: RunLoop.main)
|
||||
.sink { [weak self] selectedAccount,count in
|
||||
self?.applySelectedCollectionViewDataSource(accounts: selectedAccount)
|
||||
}
|
||||
|
@ -133,6 +141,7 @@ final class SuggestionAccountViewModel: NSObject {
|
|||
}
|
||||
|
||||
func applyTableViewDataSource(accounts: [NSManagedObjectID]) {
|
||||
assert(Thread.isMainThread)
|
||||
guard let dataSource = diffableDataSource else { return }
|
||||
var snapshot = NSDiffableDataSourceSnapshot<RecommendAccountSection, NSManagedObjectID>()
|
||||
snapshot.appendSections([.main])
|
||||
|
@ -141,6 +150,7 @@ final class SuggestionAccountViewModel: NSObject {
|
|||
}
|
||||
|
||||
func applySelectedCollectionViewDataSource(accounts: [NSManagedObjectID]) {
|
||||
assert(Thread.isMainThread)
|
||||
guard let count = headerPlaceholderCount.value else { return }
|
||||
guard let dataSource = collectionDiffableDataSource else { return }
|
||||
var snapshot = NSDiffableDataSourceSnapshot<SelectedAccountSection, SelectedAccountItem>()
|
||||
|
|
Loading…
Reference in New Issue