Remove profile directory

The code remains for now, in case it needs to return
This commit is contained in:
Shadowfacts 2023-02-05 14:27:26 -05:00
parent ce741d6e1f
commit d1a35620c9
3 changed files with 9 additions and 72 deletions

View File

@ -175,7 +175,7 @@ class ExploreViewController: UIViewController, UICollectionViewDelegate, Collect
private func addDiscoverSection(to snapshot: inout NSDiffableDataSourceSnapshot<Section, Item>) { private func addDiscoverSection(to snapshot: inout NSDiffableDataSourceSnapshot<Section, Item>) {
snapshot.insertSections([.discover], afterSection: .bookmarks) snapshot.insertSections([.discover], afterSection: .bookmarks)
snapshot.appendItems([.trendingTags, .profileDirectory], toSection: .discover) snapshot.appendItems([.trendingTags], toSection: .discover)
if mastodonController.instanceFeatures.trendingStatusesAndLinks { if mastodonController.instanceFeatures.trendingStatusesAndLinks {
snapshot.insertItems([.trendingStatuses], beforeItem: .trendingTags) snapshot.insertItems([.trendingStatuses], beforeItem: .trendingTags)
snapshot.insertItems([.trendingLinks], afterItem: .trendingTags) snapshot.insertItems([.trendingLinks], afterItem: .trendingTags)
@ -187,7 +187,7 @@ class ExploreViewController: UIViewController, UICollectionViewDelegate, Collect
if mastodonController.instanceFeatures.trends, if mastodonController.instanceFeatures.trends,
!snapshot.sectionIdentifiers.contains(.discover) { !snapshot.sectionIdentifiers.contains(.discover) {
snapshot.insertSections([.discover], afterSection: .bookmarks) snapshot.insertSections([.discover], afterSection: .bookmarks)
snapshot.appendItems([.trendingTags, .profileDirectory], toSection: .discover) snapshot.appendItems([.trendingTags], toSection: .discover)
} }
self.dataSource.apply(snapshot) self.dataSource.apply(snapshot)
} }
@ -348,9 +348,6 @@ class ExploreViewController: UIViewController, UICollectionViewDelegate, Collect
case .trendingLinks: case .trendingLinks:
show(TrendingLinksViewController(mastodonController: mastodonController), sender: nil) show(TrendingLinksViewController(mastodonController: mastodonController), sender: nil)
case .profileDirectory:
show(ProfileDirectoryViewController(mastodonController: mastodonController), sender: nil)
case let .list(list): case let .list(list):
show(ListTimelineViewController(for: list, mastodonController: mastodonController), sender: nil) show(ListTimelineViewController(for: list, mastodonController: mastodonController), sender: nil)
@ -415,7 +412,6 @@ extension ExploreViewController {
case trendingStatuses case trendingStatuses
case trendingTags case trendingTags
case trendingLinks case trendingLinks
case profileDirectory
case list(List) case list(List)
case addList case addList
case savedHashtag(Hashtag) case savedHashtag(Hashtag)
@ -435,8 +431,6 @@ extension ExploreViewController {
return NSLocalizedString("Trending Hashtags", comment: "trending hashtags nav item title") return NSLocalizedString("Trending Hashtags", comment: "trending hashtags nav item title")
case .trendingLinks: case .trendingLinks:
return NSLocalizedString("Trending Links", comment: "trending links nav item title") 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): case let .list(list):
return list.title return list.title
case .addList: case .addList:
@ -465,8 +459,6 @@ extension ExploreViewController {
name = "number" name = "number"
case .trendingLinks: case .trendingLinks:
name = "link" name = "link"
case .profileDirectory:
name = "person.2.fill"
case .list(_): case .list(_):
name = "list.bullet" name = "list.bullet"
case .addList, .addSavedHashtag: case .addList, .addSavedHashtag:
@ -493,8 +485,6 @@ extension ExploreViewController {
return true return true
case (.trendingLinks, .trendingLinks): case (.trendingLinks, .trendingLinks):
return true return true
case (.profileDirectory, .profileDirectory):
return true
case let (.list(a), .list(b)): case let (.list(a), .list(b)):
return a.id == b.id && a.title == b.title return a.id == b.id && a.title == b.title
case (.addList, .addList): case (.addList, .addList):
@ -524,8 +514,6 @@ extension ExploreViewController {
hasher.combine("trendingTags") hasher.combine("trendingTags")
case .trendingLinks: case .trendingLinks:
hasher.combine("trendingLinks") hasher.combine("trendingLinks")
case .profileDirectory:
hasher.combine("profileDirectory")
case let .list(list): case let .list(list):
hasher.combine("list") hasher.combine("list")
hasher.combine(list.id) hasher.combine(list.id)

View File

@ -41,7 +41,7 @@ class MainSidebarViewController: UIViewController {
} }
var exploreTabItems: [Item] { var exploreTabItems: [Item] {
var items: [Item] = [.explore, .bookmarks, .favorites, .profileDirectory] var items: [Item] = [.explore, .bookmarks, .favorites]
let snapshot = dataSource.snapshot() let snapshot = dataSource.snapshot()
for case let .list(list) in snapshot.itemIdentifiers(inSection: .lists) { for case let .list(list) in snapshot.itemIdentifiers(inSection: .lists) {
items.append(.list(list)) items.append(.list(list))
@ -104,7 +104,6 @@ class MainSidebarViewController: UIViewController {
select(item: .tab(.timelines), animated: false) select(item: .tab(.timelines), animated: false)
NotificationCenter.default.addObserver(self, selector: #selector(reloadSavedInstances), name: .savedInstancesChanged, object: nil) NotificationCenter.default.addObserver(self, selector: #selector(reloadSavedInstances), name: .savedInstancesChanged, object: nil)
NotificationCenter.default.addObserver(self, selector: #selector(preferencesChanged), name: .preferencesChanged, object: nil)
mastodonController.$lists mastodonController.$lists
.sink { [unowned self] in self.reloadLists($0) } .sink { [unowned self] in self.reloadLists($0) }
@ -166,7 +165,7 @@ class MainSidebarViewController: UIViewController {
private func applyInitialSnapshot() { private func applyInitialSnapshot() {
var snapshot = NSDiffableDataSourceSnapshot<Section, Item>() var snapshot = NSDiffableDataSourceSnapshot<Section, Item>()
snapshot.appendSections(Section.allCases.filter { $0 != .discover }) snapshot.appendSections(Section.allCases)
snapshot.appendItems([ snapshot.appendItems([
.tab(.timelines), .tab(.timelines),
.tab(.notifications), .tab(.notifications),
@ -178,36 +177,14 @@ class MainSidebarViewController: UIViewController {
snapshot.appendItems([ snapshot.appendItems([
.tab(.compose) .tab(.compose)
], toSection: .compose) ], toSection: .compose)
if mastodonController.instanceFeatures.trends,
!Preferences.shared.hideDiscover {
snapshot.insertSections([.discover], afterSection: .compose)
}
dataSource.apply(snapshot, animatingDifferences: false) dataSource.apply(snapshot, animatingDifferences: false)
applyDiscoverSectionSnapshot()
reloadLists(mastodonController.lists) reloadLists(mastodonController.lists)
updateHashtagsSection(followed: mastodonController.followedHashtags) updateHashtagsSection(followed: mastodonController.followedHashtags)
reloadSavedInstances() reloadSavedInstances()
} }
private func applyDiscoverSectionSnapshot() {
var discoverSnapshot = NSDiffableDataSourceSectionSnapshot<Item>()
discoverSnapshot.append([.discoverHeader])
discoverSnapshot.append([
.profileDirectory,
], to: .discoverHeader)
dataSource.apply(discoverSnapshot, to: .discover)
}
private func ownInstanceLoaded(_ instance: Instance) { 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 let prevSelected = collectionView.indexPathsForSelectedItems
if let prevSelected = prevSelected?.first { if let prevSelected = prevSelected?.first {
@ -290,22 +267,6 @@ class MainSidebarViewController: UIViewController {
self.dataSource.apply(instancesSnapshot, to: .savedInstances) 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() { private func returnToPreviousItem() {
let item = previouslySelectedItem ?? .tab(.timelines) let item = previouslySelectedItem ?? .tab(.timelines)
previouslySelectedItem = nil previouslySelectedItem = nil
@ -378,7 +339,6 @@ extension MainSidebarViewController {
enum Section: Int, Hashable, CaseIterable { enum Section: Int, Hashable, CaseIterable {
case tabs case tabs
case compose case compose
case discover
case lists case lists
case savedHashtags case savedHashtags
case savedInstances case savedInstances
@ -386,7 +346,6 @@ extension MainSidebarViewController {
enum Item: Hashable { enum Item: Hashable {
case tab(MainTabBarViewController.Tab) case tab(MainTabBarViewController.Tab)
case explore, bookmarks, favorites case explore, bookmarks, favorites
case discoverHeader, profileDirectory
case listsHeader, list(List), addList case listsHeader, list(List), addList
case savedHashtagsHeader, savedHashtag(Hashtag), addSavedHashtag case savedHashtagsHeader, savedHashtag(Hashtag), addSavedHashtag
case savedInstancesHeader, savedInstance(URL), addSavedInstance case savedInstancesHeader, savedInstance(URL), addSavedInstance
@ -401,10 +360,6 @@ extension MainSidebarViewController {
return "Bookmarks" return "Bookmarks"
case .favorites: case .favorites:
return "Favorites" return "Favorites"
case .discoverHeader:
return "Discover"
case .profileDirectory:
return "Profile Directory"
case .listsHeader: case .listsHeader:
return "Lists" return "Lists"
case let .list(list): case let .list(list):
@ -436,15 +391,13 @@ extension MainSidebarViewController {
return "bookmark" return "bookmark"
case .favorites: case .favorites:
return "star" return "star"
case .profileDirectory:
return "person.2.fill"
case .list(_): case .list(_):
return "list.bullet" return "list.bullet"
case .savedHashtag(_): case .savedHashtag(_):
return "number" return "number"
case .savedInstance(_): case .savedInstance(_):
return "globe" return "globe"
case .discoverHeader, .listsHeader, .savedHashtagsHeader, .savedInstancesHeader: case .listsHeader, .savedHashtagsHeader, .savedInstancesHeader:
return nil return nil
case .addList, .addSavedHashtag, .addSavedInstance: case .addList, .addSavedHashtag, .addSavedInstance:
return "plus" return "plus"
@ -453,7 +406,7 @@ extension MainSidebarViewController {
var hasChildren: Bool { var hasChildren: Bool {
switch self { switch self {
case .discoverHeader, .listsHeader, .savedHashtagsHeader, .savedInstancesHeader: case .listsHeader, .savedHashtagsHeader, .savedInstancesHeader:
return true return true
default: default:
return false return false

View File

@ -232,7 +232,7 @@ extension MainSplitViewController: UISplitViewControllerDelegate {
tabBarViewController.select(tab: .explore) tabBarViewController.select(tab: .explore)
case .bookmarks, .favorites, .profileDirectory, .list(_), .savedHashtag(_), .savedInstance(_): case .bookmarks, .favorites, .list(_), .savedHashtag(_), .savedInstance(_):
tabBarViewController.select(tab: .explore) tabBarViewController.select(tab: .explore)
// Make sure the Explore VC doesn't show its search bar when it appears, in case the user was previously // 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. // in compact mode and performing a search.
@ -240,7 +240,7 @@ extension MainSplitViewController: UISplitViewControllerDelegate {
let explore = exploreNav.viewControllers.first as! ExploreViewController let explore = exploreNav.viewControllers.first as! ExploreViewController
explore.searchControllerStatusOnAppearance = false 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. // These items are not selectable in the sidebar collection view, so this code is unreachable.
fatalError("unexpected selected sidebar item: \(sidebar.selectedItem!)") fatalError("unexpected selected sidebar item: \(sidebar.selectedItem!)")
} }
@ -317,8 +317,6 @@ extension MainSplitViewController: UISplitViewControllerDelegate {
exploreItem = .explore exploreItem = .explore
// these three VCs are part of the root SearchViewController, so we don't need to transfer them // these three VCs are part of the root SearchViewController, so we don't need to transfer them
skipFirst = 2 skipFirst = 2
case is ProfileDirectoryViewController:
exploreItem = .profileDirectory
default: default:
// transfer the navigation stack prepending, the existing explore VC // transfer the navigation stack prepending, the existing explore VC
// if there was other stuff on the explore stack, it will get discarded // 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) return BookmarksViewController(mastodonController: mastodonController)
case .favorites: case .favorites:
return FavoritesViewController(mastodonController: mastodonController) return FavoritesViewController(mastodonController: mastodonController)
case .profileDirectory:
return ProfileDirectoryViewController(mastodonController: mastodonController)
case let .list(list): case let .list(list):
return ListTimelineViewController(for: list, mastodonController: mastodonController) return ListTimelineViewController(for: list, mastodonController: mastodonController)
case let .savedHashtag(hashtag): case let .savedHashtag(hashtag):
return HashtagTimelineViewController(for: hashtag, mastodonController: mastodonController) return HashtagTimelineViewController(for: hashtag, mastodonController: mastodonController)
case let .savedInstance(url): case let .savedInstance(url):
return InstanceTimelineViewController(for: url, parentMastodonController: mastodonController) return InstanceTimelineViewController(for: url, parentMastodonController: mastodonController)
case .discoverHeader, .listsHeader, .addList, .savedHashtagsHeader, .addSavedHashtag, .savedInstancesHeader, .addSavedInstance: case .listsHeader, .addList, .savedHashtagsHeader, .addSavedHashtag, .savedInstancesHeader, .addSavedInstance:
return nil return nil
} }
} }