Fix crash on launch if there are somehow duplicate saved hashtags

This commit is contained in:
Shadowfacts 2024-08-27 12:42:41 -04:00
parent b54d34ebfc
commit 1bd4d144a3
1 changed files with 2 additions and 1 deletions

View File

@ -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))
}