From 353e752083599c3de1b84799365c8db7e78c3288 Mon Sep 17 00:00:00 2001 From: CMK Date: Thu, 17 Jun 2021 19:43:16 +0800 Subject: [PATCH] feat: trigger timeline fetching after publish post --- .../Scene/HomeTimeline/HomeTimelineViewController.swift | 4 +--- Mastodon/Scene/HomeTimeline/HomeTimelineViewModel.swift | 7 +++++++ 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/Mastodon/Scene/HomeTimeline/HomeTimelineViewController.swift b/Mastodon/Scene/HomeTimeline/HomeTimelineViewController.swift index 6aed1f574..529f2d81c 100644 --- a/Mastodon/Scene/HomeTimeline/HomeTimelineViewController.swift +++ b/Mastodon/Scene/HomeTimeline/HomeTimelineViewController.swift @@ -92,15 +92,13 @@ extension HomeTimelineViewController { viewModel.homeTimelineNavigationBarTitleViewModel.state .removeDuplicates() - .debounce(for: 0.3, scheduler: RunLoop.main) - .receive(on: RunLoop.main) + .receive(on: DispatchQueue.main) .sink { [weak self] state in guard let self = self else { return } self.titleView.configure(state: state) } .store(in: &disposeBag) - #if DEBUG // long press to trigger debug menu settingBarButtonItem.menu = debugMenu diff --git a/Mastodon/Scene/HomeTimeline/HomeTimelineViewModel.swift b/Mastodon/Scene/HomeTimeline/HomeTimelineViewModel.swift index 717519464..fdbbfba9d 100644 --- a/Mastodon/Scene/HomeTimeline/HomeTimelineViewModel.swift +++ b/Mastodon/Scene/HomeTimeline/HomeTimelineViewModel.swift @@ -36,6 +36,7 @@ final class HomeTimelineViewModel: NSObject { let timelineIsEmpty = CurrentValueSubject(false) let homeTimelineNeedRefresh = PassthroughSubject() + // output // top loader private(set) lazy var loadLatestStateMachine: GKStateMachine = { @@ -130,6 +131,12 @@ final class HomeTimelineViewModel: NSObject { } .store(in: &disposeBag) + homeTimelineNavigationBarTitleViewModel.isPublished + .sink { [weak self] isPublished in + guard let self = self else { return } + self.homeTimelineNeedRefresh.send() + } + .store(in: &disposeBag) } deinit {