feat: trigger timeline fetching after publish post

This commit is contained in:
CMK 2021-06-17 19:43:16 +08:00
parent f2795c035a
commit 353e752083
2 changed files with 8 additions and 3 deletions

View File

@ -92,15 +92,13 @@ extension HomeTimelineViewController {
viewModel.homeTimelineNavigationBarTitleViewModel.state viewModel.homeTimelineNavigationBarTitleViewModel.state
.removeDuplicates() .removeDuplicates()
.debounce(for: 0.3, scheduler: RunLoop.main) .receive(on: DispatchQueue.main)
.receive(on: RunLoop.main)
.sink { [weak self] state in .sink { [weak self] state in
guard let self = self else { return } guard let self = self else { return }
self.titleView.configure(state: state) self.titleView.configure(state: state)
} }
.store(in: &disposeBag) .store(in: &disposeBag)
#if DEBUG #if DEBUG
// long press to trigger debug menu // long press to trigger debug menu
settingBarButtonItem.menu = debugMenu settingBarButtonItem.menu = debugMenu

View File

@ -36,6 +36,7 @@ final class HomeTimelineViewModel: NSObject {
let timelineIsEmpty = CurrentValueSubject<Bool, Never>(false) let timelineIsEmpty = CurrentValueSubject<Bool, Never>(false)
let homeTimelineNeedRefresh = PassthroughSubject<Void, Never>() let homeTimelineNeedRefresh = PassthroughSubject<Void, Never>()
// output // output
// top loader // top loader
private(set) lazy var loadLatestStateMachine: GKStateMachine = { private(set) lazy var loadLatestStateMachine: GKStateMachine = {
@ -130,6 +131,12 @@ final class HomeTimelineViewModel: NSObject {
} }
.store(in: &disposeBag) .store(in: &disposeBag)
homeTimelineNavigationBarTitleViewModel.isPublished
.sink { [weak self] isPublished in
guard let self = self else { return }
self.homeTimelineNeedRefresh.send()
}
.store(in: &disposeBag)
} }
deinit { deinit {