From 1bd4d144a39850a9cbaab5a75796bb2b48267925 Mon Sep 17 00:00:00 2001 From: Shadowfacts Date: Tue, 27 Aug 2024 12:42:41 -0400 Subject: [PATCH] Fix crash on launch if there are somehow duplicate saved hashtags --- Tusker/Screens/Main/NewMainTabBarViewController.swift | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Tusker/Screens/Main/NewMainTabBarViewController.swift b/Tusker/Screens/Main/NewMainTabBarViewController.swift index a0c99a97..44335353 100644 --- a/Tusker/Screens/Main/NewMainTabBarViewController.swift +++ b/Tusker/Screens/Main/NewMainTabBarViewController.swift @@ -285,7 +285,7 @@ final class NewMainTabBarViewController: BaseMainTabBarViewController { var tabs: [UITab] = [] let savedReq = SavedHashtag.fetchRequest(account: mastodonController.accountInfo!) let saved = (try? mastodonController.persistentContainer.viewContext.fetch(savedReq)) ?? [] - for hashtag in saved { + for hashtag in saved where !seenTags.contains(hashtag.name) { seenTags.insert(hashtag.name) tabs.append(HashtagTab(hashtagName: hashtag.name, viewControllerProvider: viewControllerProvider)) } @@ -293,6 +293,7 @@ final class NewMainTabBarViewController: BaseMainTabBarViewController { let followedReq = FollowedHashtag.fetchRequest() let followed = (try? mastodonController.persistentContainer.viewContext.fetch(followedReq)) ?? [] for hashtag in followed where !seenTags.contains(hashtag.name) { + seenTags.insert(hashtag.name) tabs.append(HashtagTab(hashtagName: hashtag.name, viewControllerProvider: viewControllerProvider)) }