From 83241cc32947b36fb57a2509cd309568ac7898ea Mon Sep 17 00:00:00 2001 From: Martin Hartl Date: Sun, 2 Feb 2020 21:44:54 +0100 Subject: [PATCH] =?UTF-8?q?Don=E2=80=99t=20show=20=E2=80=9CGo=20to=20feed?= =?UTF-8?q?=E2=80=9D=20action=20if=20already=20inside=20feed?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- iOS/MasterTimeline/MasterTimelineViewController.swift | 6 ++++-- iOS/SceneCoordinator.swift | 8 ++++++++ 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/iOS/MasterTimeline/MasterTimelineViewController.swift b/iOS/MasterTimeline/MasterTimelineViewController.swift index 22ac0af25..9e7f83da0 100644 --- a/iOS/MasterTimeline/MasterTimelineViewController.swift +++ b/iOS/MasterTimeline/MasterTimelineViewController.swift @@ -769,7 +769,8 @@ private extension MasterTimelineViewController { } func discloseFeedAction(_ article: Article) -> UIAction? { - guard let webFeed = article.webFeed else { return nil } + guard let webFeed = article.webFeed, + !coordinator.timelineFeedIsEqualTo(webFeed) else { return nil } let title = NSLocalizedString("Go to Feed", comment: "Go to Feed") let action = UIAction(title: title, image: AppAssets.openInSidebarImage) { [weak self] action in @@ -779,7 +780,8 @@ private extension MasterTimelineViewController { } func discloseFeedAlertAction(_ article: Article, completion: @escaping (Bool) -> Void) -> UIAlertAction? { - guard let webFeed = article.webFeed else { return nil } + guard let webFeed = article.webFeed, + !coordinator.timelineFeedIsEqualTo(webFeed) else { return nil } let title = NSLocalizedString("Go to Feed", comment: "Go to Feed") let action = UIAlertAction(title: title, style: .default) { [weak self] action in diff --git a/iOS/SceneCoordinator.swift b/iOS/SceneCoordinator.swift index b09d74094..5b7afe315 100644 --- a/iOS/SceneCoordinator.swift +++ b/iOS/SceneCoordinator.swift @@ -997,6 +997,14 @@ class SceneCoordinator: NSObject, UndoableCommandRunner, UnreadCountProvider { markArticlesWithUndo([article], statusKey: .starred, flag: !article.status.starred) } + func timelineFeedIsEqualTo(_ feed: WebFeed) -> Bool { + guard let timelineFeed = timelineFeed as? WebFeed else { + return false + } + + return timelineFeed == feed + } + func discloseFeed(_ feed: WebFeed, animations: Animations = [], completion: (() -> Void)? = nil) { if isSearching { masterTimelineViewController?.hideSearch()