From d6d91180cbf8ed80657c9a91c25501da11d06241 Mon Sep 17 00:00:00 2001 From: sunxiaojian Date: Fri, 23 Apr 2021 19:15:52 +0800 Subject: [PATCH] fix: the data source update queue , change activityIndicatorView color --- Mastodon/Scene/Search/SearchViewModel.swift | 14 +++++++------- .../SuggestionAccountTableViewCell.swift | 1 - 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/Mastodon/Scene/Search/SearchViewModel.swift b/Mastodon/Scene/Search/SearchViewModel.swift index 5f1ff5f46..e10b04c9e 100644 --- a/Mastodon/Scene/Search/SearchViewModel.swift +++ b/Mastodon/Scene/Search/SearchViewModel.swift @@ -162,7 +162,6 @@ final class SearchViewModel: NSObject { .store(in: &disposeBag) requestRecommendAccountsV2() - .receive(on: DispatchQueue.main) .sink { [weak self] _ in guard let self = self else { return } if !self.recommendAccounts.isEmpty { @@ -176,7 +175,6 @@ final class SearchViewModel: NSObject { .sink { [weak self] _ in guard let self = self else { return } self.requestRecommendAccounts() - .receive(on: DispatchQueue.main) .sink { [weak self] _ in guard let self = self else { return } if !self.recommendAccounts.isEmpty { @@ -295,11 +293,13 @@ final class SearchViewModel: NSObject { } func applyDataSource() { - guard let dataSource = accountDiffableDataSource else { return } - var snapshot = NSDiffableDataSourceSnapshot() - snapshot.appendSections([.main]) - snapshot.appendItems(recommendAccounts, toSection: .main) - dataSource.apply(snapshot, animatingDifferences: false, completion: nil) + DispatchQueue.main.async { + guard let dataSource = self.accountDiffableDataSource else { return } + var snapshot = NSDiffableDataSourceSnapshot() + snapshot.appendSections([.main]) + snapshot.appendItems(self.recommendAccounts, toSection: .main) + dataSource.apply(snapshot, animatingDifferences: false, completion: nil) + } } func receiveAccounts(ids: [String]) { diff --git a/Mastodon/Scene/SuggestionAccount/TableViewCell/SuggestionAccountTableViewCell.swift b/Mastodon/Scene/SuggestionAccount/TableViewCell/SuggestionAccountTableViewCell.swift index a550fd889..db56d63ca 100644 --- a/Mastodon/Scene/SuggestionAccount/TableViewCell/SuggestionAccountTableViewCell.swift +++ b/Mastodon/Scene/SuggestionAccount/TableViewCell/SuggestionAccountTableViewCell.swift @@ -62,7 +62,6 @@ final class SuggestionAccountTableViewCell: UITableViewCell { let activityIndicatorView: UIActivityIndicatorView = { let activityIndicatorView = UIActivityIndicatorView(style: .medium) - activityIndicatorView.color = .white activityIndicatorView.hidesWhenStopped = true return activityIndicatorView }()