From d1a35620c937275bdcf254c447fd720a66798f13 Mon Sep 17 00:00:00 2001 From: Shadowfacts Date: Sun, 5 Feb 2023 14:27:26 -0500 Subject: [PATCH] Remove profile directory The code remains for now, in case it needs to return --- .../Explore/ExploreViewController.swift | 16 +----- .../Main/MainSidebarViewController.swift | 55 ++----------------- .../Main/MainSplitViewController.swift | 10 +--- 3 files changed, 9 insertions(+), 72 deletions(-) diff --git a/Tusker/Screens/Explore/ExploreViewController.swift b/Tusker/Screens/Explore/ExploreViewController.swift index 4b1b37b2..e82b1e6c 100644 --- a/Tusker/Screens/Explore/ExploreViewController.swift +++ b/Tusker/Screens/Explore/ExploreViewController.swift @@ -175,7 +175,7 @@ class ExploreViewController: UIViewController, UICollectionViewDelegate, Collect private func addDiscoverSection(to snapshot: inout NSDiffableDataSourceSnapshot) { snapshot.insertSections([.discover], afterSection: .bookmarks) - snapshot.appendItems([.trendingTags, .profileDirectory], toSection: .discover) + snapshot.appendItems([.trendingTags], toSection: .discover) if mastodonController.instanceFeatures.trendingStatusesAndLinks { snapshot.insertItems([.trendingStatuses], beforeItem: .trendingTags) snapshot.insertItems([.trendingLinks], afterItem: .trendingTags) @@ -187,7 +187,7 @@ class ExploreViewController: UIViewController, UICollectionViewDelegate, Collect if mastodonController.instanceFeatures.trends, !snapshot.sectionIdentifiers.contains(.discover) { snapshot.insertSections([.discover], afterSection: .bookmarks) - snapshot.appendItems([.trendingTags, .profileDirectory], toSection: .discover) + snapshot.appendItems([.trendingTags], toSection: .discover) } self.dataSource.apply(snapshot) } @@ -348,9 +348,6 @@ class ExploreViewController: UIViewController, UICollectionViewDelegate, Collect case .trendingLinks: show(TrendingLinksViewController(mastodonController: mastodonController), sender: nil) - case .profileDirectory: - show(ProfileDirectoryViewController(mastodonController: mastodonController), sender: nil) - case let .list(list): show(ListTimelineViewController(for: list, mastodonController: mastodonController), sender: nil) @@ -415,7 +412,6 @@ extension ExploreViewController { case trendingStatuses case trendingTags case trendingLinks - case profileDirectory case list(List) case addList case savedHashtag(Hashtag) @@ -435,8 +431,6 @@ extension ExploreViewController { return NSLocalizedString("Trending Hashtags", comment: "trending hashtags nav item title") case .trendingLinks: return NSLocalizedString("Trending Links", comment: "trending links nav item title") - case .profileDirectory: - return NSLocalizedString("Profile Directory", comment: "profile directory nav item title") case let .list(list): return list.title case .addList: @@ -465,8 +459,6 @@ extension ExploreViewController { name = "number" case .trendingLinks: name = "link" - case .profileDirectory: - name = "person.2.fill" case .list(_): name = "list.bullet" case .addList, .addSavedHashtag: @@ -493,8 +485,6 @@ extension ExploreViewController { return true case (.trendingLinks, .trendingLinks): return true - case (.profileDirectory, .profileDirectory): - return true case let (.list(a), .list(b)): return a.id == b.id && a.title == b.title case (.addList, .addList): @@ -524,8 +514,6 @@ extension ExploreViewController { hasher.combine("trendingTags") case .trendingLinks: hasher.combine("trendingLinks") - case .profileDirectory: - hasher.combine("profileDirectory") case let .list(list): hasher.combine("list") hasher.combine(list.id) diff --git a/Tusker/Screens/Main/MainSidebarViewController.swift b/Tusker/Screens/Main/MainSidebarViewController.swift index 7d91ff59..b6d7761f 100644 --- a/Tusker/Screens/Main/MainSidebarViewController.swift +++ b/Tusker/Screens/Main/MainSidebarViewController.swift @@ -41,7 +41,7 @@ class MainSidebarViewController: UIViewController { } var exploreTabItems: [Item] { - var items: [Item] = [.explore, .bookmarks, .favorites, .profileDirectory] + var items: [Item] = [.explore, .bookmarks, .favorites] let snapshot = dataSource.snapshot() for case let .list(list) in snapshot.itemIdentifiers(inSection: .lists) { items.append(.list(list)) @@ -104,7 +104,6 @@ class MainSidebarViewController: UIViewController { select(item: .tab(.timelines), animated: false) NotificationCenter.default.addObserver(self, selector: #selector(reloadSavedInstances), name: .savedInstancesChanged, object: nil) - NotificationCenter.default.addObserver(self, selector: #selector(preferencesChanged), name: .preferencesChanged, object: nil) mastodonController.$lists .sink { [unowned self] in self.reloadLists($0) } @@ -166,7 +165,7 @@ class MainSidebarViewController: UIViewController { private func applyInitialSnapshot() { var snapshot = NSDiffableDataSourceSnapshot() - snapshot.appendSections(Section.allCases.filter { $0 != .discover }) + snapshot.appendSections(Section.allCases) snapshot.appendItems([ .tab(.timelines), .tab(.notifications), @@ -178,36 +177,14 @@ class MainSidebarViewController: UIViewController { snapshot.appendItems([ .tab(.compose) ], toSection: .compose) - if mastodonController.instanceFeatures.trends, - !Preferences.shared.hideDiscover { - snapshot.insertSections([.discover], afterSection: .compose) - } dataSource.apply(snapshot, animatingDifferences: false) - applyDiscoverSectionSnapshot() reloadLists(mastodonController.lists) updateHashtagsSection(followed: mastodonController.followedHashtags) reloadSavedInstances() } - private func applyDiscoverSectionSnapshot() { - var discoverSnapshot = NSDiffableDataSourceSectionSnapshot() - discoverSnapshot.append([.discoverHeader]) - discoverSnapshot.append([ - .profileDirectory, - ], to: .discoverHeader) - dataSource.apply(discoverSnapshot, to: .discover) - } - private func ownInstanceLoaded(_ instance: Instance) { - if mastodonController.instanceFeatures.trends { - var snapshot = self.dataSource.snapshot() - if !snapshot.sectionIdentifiers.contains(.discover) { - snapshot.appendSections([.discover]) - dataSource.apply(snapshot, animatingDifferences: false) - } - applyDiscoverSectionSnapshot() - } let prevSelected = collectionView.indexPathsForSelectedItems if let prevSelected = prevSelected?.first { @@ -290,22 +267,6 @@ class MainSidebarViewController: UIViewController { self.dataSource.apply(instancesSnapshot, to: .savedInstances) } - @objc private func preferencesChanged() { - var snapshot = dataSource.snapshot() - let hasSection = snapshot.sectionIdentifiers.contains(.discover) - let hide = Preferences.shared.hideDiscover - if hasSection && hide { - snapshot.deleteSections([.discover]) - dataSource.apply(snapshot) - } else if !hasSection && !hide { - snapshot.insertSections([.discover], afterSection: .compose) - dataSource.apply(snapshot) - applyDiscoverSectionSnapshot() - } else { - return - } - } - private func returnToPreviousItem() { let item = previouslySelectedItem ?? .tab(.timelines) previouslySelectedItem = nil @@ -378,7 +339,6 @@ extension MainSidebarViewController { enum Section: Int, Hashable, CaseIterable { case tabs case compose - case discover case lists case savedHashtags case savedInstances @@ -386,7 +346,6 @@ extension MainSidebarViewController { enum Item: Hashable { case tab(MainTabBarViewController.Tab) case explore, bookmarks, favorites - case discoverHeader, profileDirectory case listsHeader, list(List), addList case savedHashtagsHeader, savedHashtag(Hashtag), addSavedHashtag case savedInstancesHeader, savedInstance(URL), addSavedInstance @@ -401,10 +360,6 @@ extension MainSidebarViewController { return "Bookmarks" case .favorites: return "Favorites" - case .discoverHeader: - return "Discover" - case .profileDirectory: - return "Profile Directory" case .listsHeader: return "Lists" case let .list(list): @@ -436,15 +391,13 @@ extension MainSidebarViewController { return "bookmark" case .favorites: return "star" - case .profileDirectory: - return "person.2.fill" case .list(_): return "list.bullet" case .savedHashtag(_): return "number" case .savedInstance(_): return "globe" - case .discoverHeader, .listsHeader, .savedHashtagsHeader, .savedInstancesHeader: + case .listsHeader, .savedHashtagsHeader, .savedInstancesHeader: return nil case .addList, .addSavedHashtag, .addSavedInstance: return "plus" @@ -453,7 +406,7 @@ extension MainSidebarViewController { var hasChildren: Bool { switch self { - case .discoverHeader, .listsHeader, .savedHashtagsHeader, .savedInstancesHeader: + case .listsHeader, .savedHashtagsHeader, .savedInstancesHeader: return true default: return false diff --git a/Tusker/Screens/Main/MainSplitViewController.swift b/Tusker/Screens/Main/MainSplitViewController.swift index 693f193b..fde39326 100644 --- a/Tusker/Screens/Main/MainSplitViewController.swift +++ b/Tusker/Screens/Main/MainSplitViewController.swift @@ -232,7 +232,7 @@ extension MainSplitViewController: UISplitViewControllerDelegate { tabBarViewController.select(tab: .explore) - case .bookmarks, .favorites, .profileDirectory, .list(_), .savedHashtag(_), .savedInstance(_): + case .bookmarks, .favorites, .list(_), .savedHashtag(_), .savedInstance(_): tabBarViewController.select(tab: .explore) // Make sure the Explore VC doesn't show its search bar when it appears, in case the user was previously // in compact mode and performing a search. @@ -240,7 +240,7 @@ extension MainSplitViewController: UISplitViewControllerDelegate { let explore = exploreNav.viewControllers.first as! ExploreViewController explore.searchControllerStatusOnAppearance = false - case .discoverHeader, .listsHeader, .addList, .savedHashtagsHeader, .addSavedHashtag, .savedInstancesHeader, .addSavedInstance: + case .listsHeader, .addList, .savedHashtagsHeader, .addSavedHashtag, .savedInstancesHeader, .addSavedInstance: // These items are not selectable in the sidebar collection view, so this code is unreachable. fatalError("unexpected selected sidebar item: \(sidebar.selectedItem!)") } @@ -317,8 +317,6 @@ extension MainSplitViewController: UISplitViewControllerDelegate { exploreItem = .explore // these three VCs are part of the root SearchViewController, so we don't need to transfer them skipFirst = 2 - case is ProfileDirectoryViewController: - exploreItem = .profileDirectory default: // transfer the navigation stack prepending, the existing explore VC // if there was other stuff on the explore stack, it will get discarded @@ -384,15 +382,13 @@ fileprivate extension MainSidebarViewController.Item { return BookmarksViewController(mastodonController: mastodonController) case .favorites: return FavoritesViewController(mastodonController: mastodonController) - case .profileDirectory: - return ProfileDirectoryViewController(mastodonController: mastodonController) case let .list(list): return ListTimelineViewController(for: list, mastodonController: mastodonController) case let .savedHashtag(hashtag): return HashtagTimelineViewController(for: hashtag, mastodonController: mastodonController) case let .savedInstance(url): return InstanceTimelineViewController(for: url, parentMastodonController: mastodonController) - case .discoverHeader, .listsHeader, .addList, .savedHashtagsHeader, .addSavedHashtag, .savedInstancesHeader, .addSavedInstance: + case .listsHeader, .addList, .savedHashtagsHeader, .addSavedHashtag, .savedInstancesHeader, .addSavedInstance: return nil } }