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
|
@ -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