From 434d975767877a02469aab1e550b9f750392bed5 Mon Sep 17 00:00:00 2001 From: Shadowfacts Date: Tue, 25 Jan 2022 21:01:36 -0500 Subject: [PATCH] Fix crash when ownInstanceLoaded callback is called multiple times --- Tusker/Screens/Explore/ExploreViewController.swift | 3 ++- Tusker/Screens/Main/MainSidebarViewController.swift | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/Tusker/Screens/Explore/ExploreViewController.swift b/Tusker/Screens/Explore/ExploreViewController.swift index 0a74e2db..6413e580 100644 --- a/Tusker/Screens/Explore/ExploreViewController.swift +++ b/Tusker/Screens/Explore/ExploreViewController.swift @@ -154,7 +154,8 @@ class ExploreViewController: UIViewController, UICollectionViewDelegate { private func ownInstanceLoaded(_ instance: Instance) { var snapshot = self.dataSource.snapshot() - if mastodonController.instanceFeatures.instanceType.isMastodon { + if mastodonController.instanceFeatures.instanceType.isMastodon, + !snapshot.sectionIdentifiers.contains(.discover) { snapshot.insertSections([.discover], afterSection: .bookmarks) snapshot.appendItems([.trendingTags, .profileDirectory], toSection: .discover) } diff --git a/Tusker/Screens/Main/MainSidebarViewController.swift b/Tusker/Screens/Main/MainSidebarViewController.swift index 6aceb87c..c2cfe6fd 100644 --- a/Tusker/Screens/Main/MainSidebarViewController.swift +++ b/Tusker/Screens/Main/MainSidebarViewController.swift @@ -161,7 +161,8 @@ class MainSidebarViewController: UIViewController { private func ownInstanceLoaded(_ instance: Instance) { var snapshot = self.dataSource.snapshot() - if mastodonController.instanceFeatures.instanceType.isMastodon { + if mastodonController.instanceFeatures.instanceType.isMastodon, + !snapshot.sectionIdentifiers.contains(.discover) { snapshot.insertSections([.discover], afterSection: .compose) snapshot.appendItems([ .trendingTags,