Fix crash when ownInstanceLoaded callback is called multiple times

This commit is contained in:
Shadowfacts 2022-01-25 21:01:36 -05:00
parent 41a31c23b7
commit 434d975767
2 changed files with 4 additions and 2 deletions

View File

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

View File

@ -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,