fix: The empty view should not display when the user just sign-in the first time
This commit is contained in:
parent
d4f4a3e086
commit
326aea36cd
|
@ -36,7 +36,7 @@ extension RecommendAccountSection {
|
|||
viewModel: SuggestionAccountViewModel,
|
||||
delegate: SuggestionAccountTableViewCellDelegate
|
||||
) -> UITableViewDiffableDataSource<RecommendAccountSection, NSManagedObjectID> {
|
||||
UITableViewDiffableDataSource(tableView: tableView) { [weak viewModel,weak delegate] (tableView, indexPath, objectID) -> UITableViewCell? in
|
||||
UITableViewDiffableDataSource(tableView: tableView) { [weak viewModel, weak delegate] (tableView, indexPath, objectID) -> UITableViewCell? in
|
||||
guard let viewModel = viewModel else { return nil }
|
||||
let cell = tableView.dequeueReusableCell(withIdentifier: String(describing: SuggestionAccountTableViewCell.self)) as! SuggestionAccountTableViewCell
|
||||
let user = managedObjectContext.object(with: objectID) as! MastodonUser
|
||||
|
|
|
@ -151,16 +151,7 @@ extension HomeTimelineViewController {
|
|||
UIView.animate(withDuration: 0.5) { [weak self] in
|
||||
guard let self = self else { return }
|
||||
self.refreshControl.endRefreshing()
|
||||
} completion: { [weak self] _ in
|
||||
guard let self = self else { return }
|
||||
if (self.viewModel.fetchedResultsController.fetchedObjects ?? []).isEmpty {
|
||||
self.showEmptyView()
|
||||
} else {
|
||||
self.emptyView.removeFromSuperview()
|
||||
}
|
||||
}
|
||||
} else {
|
||||
self.emptyView.removeFromSuperview()
|
||||
} completion: { _ in }
|
||||
}
|
||||
}
|
||||
.store(in: &disposeBag)
|
||||
|
@ -191,6 +182,17 @@ extension HomeTimelineViewController {
|
|||
self.publishProgressView.setProgress(progress, animated: true)
|
||||
}
|
||||
.store(in: &disposeBag)
|
||||
|
||||
viewModel.timelineIsEmpty
|
||||
.receive(on: DispatchQueue.main)
|
||||
.sink { [weak self] isEmpty in
|
||||
if isEmpty {
|
||||
self?.showEmptyView()
|
||||
} else {
|
||||
self?.emptyView.removeFromSuperview()
|
||||
}
|
||||
}
|
||||
.store(in: &disposeBag)
|
||||
}
|
||||
|
||||
override func viewWillAppear(_ animated: Bool) {
|
||||
|
|
|
@ -107,6 +107,7 @@ extension HomeTimelineViewModel.LoadLatestState {
|
|||
viewModel.homeTimelineNavigationBarTitleViewModel.newPostsIncoming()
|
||||
}
|
||||
}
|
||||
viewModel.timelineIsEmpty.value = latestStatusIDs.isEmpty && statuses.isEmpty
|
||||
}
|
||||
.store(in: &viewModel.disposeBag)
|
||||
}
|
||||
|
|
|
@ -34,6 +34,7 @@ final class HomeTimelineViewModel: NSObject {
|
|||
weak var tableView: UITableView?
|
||||
weak var timelineMiddleLoaderTableViewCellDelegate: TimelineMiddleLoaderTableViewCellDelegate?
|
||||
|
||||
let timelineIsEmpty = CurrentValueSubject<Bool, Never>(false)
|
||||
let homeTimelineNeedRefresh = PassthroughSubject<Void, Never>()
|
||||
// output
|
||||
// top loader
|
||||
|
|
Loading…
Reference in New Issue