From 37df2fbd456cb559e15311aba42d56a2cfbe768e Mon Sep 17 00:00:00 2001 From: CMK Date: Wed, 30 Jun 2021 16:20:46 +0800 Subject: [PATCH] fix: notification always trigger scroll-to-top issue --- Mastodon/Scene/Notification/NotificationViewController.swift | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Mastodon/Scene/Notification/NotificationViewController.swift b/Mastodon/Scene/Notification/NotificationViewController.swift index 322f804af..6004c48df 100644 --- a/Mastodon/Scene/Notification/NotificationViewController.swift +++ b/Mastodon/Scene/Notification/NotificationViewController.swift @@ -93,6 +93,7 @@ extension NotificationViewController { .receive(on: RunLoop.main) .sink { [weak self] in guard let self = self else { return } + guard self.viewModel.needsScrollToTopAfterDataSourceUpdate else { return } self.viewModel.needsScrollToTopAfterDataSourceUpdate = false DispatchQueue.main.asyncAfter(deadline: .now() + 0.33) { self.scrollToTop(animated: true) @@ -106,6 +107,9 @@ extension NotificationViewController { .sink { [weak self] segment in guard let self = self else { return } self.segmentControl.selectedSegmentIndex = segment.rawValue + + // trigger scroll-to-top after data reload + self.viewModel.needsScrollToTopAfterDataSourceUpdate = true guard let domain = self.viewModel.activeMastodonAuthenticationBox.value?.domain, let userID = self.viewModel.activeMastodonAuthenticationBox.value?.userID else { return