forked from shadowfacts/Tusker
parent
137a537f68
commit
ec75906bc1
|
@ -199,8 +199,10 @@ public class Client {
|
||||||
return Request<Account>(method: .get, path: "/api/v1/accounts/verify_credentials")
|
return Request<Account>(method: .get, path: "/api/v1/accounts/verify_credentials")
|
||||||
}
|
}
|
||||||
|
|
||||||
public static func getFavourites() -> Request<[Status]> {
|
public static func getFavourites(range: RequestRange = .default) -> Request<[Status]> {
|
||||||
return Request<[Status]>(method: .get, path: "/api/v1/favourites")
|
var request = Request<[Status]>(method: .get, path: "/api/v1/favourites")
|
||||||
|
request.range = range
|
||||||
|
return request
|
||||||
}
|
}
|
||||||
|
|
||||||
public static func getRelationships(accounts: [String]? = nil) -> Request<[Relationship]> {
|
public static func getRelationships(accounts: [String]? = nil) -> Request<[Relationship]> {
|
||||||
|
|
|
@ -296,6 +296,7 @@
|
||||||
D6C143DA253510F4007DC240 /* ComposeEmojiTextField.swift in Sources */ = {isa = PBXBuildFile; fileRef = D6C143D9253510F4007DC240 /* ComposeEmojiTextField.swift */; };
|
D6C143DA253510F4007DC240 /* ComposeEmojiTextField.swift in Sources */ = {isa = PBXBuildFile; fileRef = D6C143D9253510F4007DC240 /* ComposeEmojiTextField.swift */; };
|
||||||
D6C1B2082545D1EC00DAAA66 /* StatusCardView.swift in Sources */ = {isa = PBXBuildFile; fileRef = D6C1B2072545D1EC00DAAA66 /* StatusCardView.swift */; };
|
D6C1B2082545D1EC00DAAA66 /* StatusCardView.swift in Sources */ = {isa = PBXBuildFile; fileRef = D6C1B2072545D1EC00DAAA66 /* StatusCardView.swift */; };
|
||||||
D6C3F4F5298ED0890009FCFF /* LocalPredicateStatusesViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = D6C3F4F4298ED0890009FCFF /* LocalPredicateStatusesViewController.swift */; };
|
D6C3F4F5298ED0890009FCFF /* LocalPredicateStatusesViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = D6C3F4F4298ED0890009FCFF /* LocalPredicateStatusesViewController.swift */; };
|
||||||
|
D6C3F4F7298ED7F70009FCFF /* FavoritesViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = D6C3F4F6298ED7F70009FCFF /* FavoritesViewController.swift */; };
|
||||||
D6C693EF216192C2007D6A6D /* TuskerNavigationDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = D6C693EE216192C2007D6A6D /* TuskerNavigationDelegate.swift */; };
|
D6C693EF216192C2007D6A6D /* TuskerNavigationDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = D6C693EE216192C2007D6A6D /* TuskerNavigationDelegate.swift */; };
|
||||||
D6C693FC2162FE6F007D6A6D /* LoadingViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = D6C693FB2162FE6F007D6A6D /* LoadingViewController.swift */; };
|
D6C693FC2162FE6F007D6A6D /* LoadingViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = D6C693FB2162FE6F007D6A6D /* LoadingViewController.swift */; };
|
||||||
D6C693FE2162FEEA007D6A6D /* UIViewController+Children.swift in Sources */ = {isa = PBXBuildFile; fileRef = D6C693FD2162FEEA007D6A6D /* UIViewController+Children.swift */; };
|
D6C693FE2162FEEA007D6A6D /* UIViewController+Children.swift in Sources */ = {isa = PBXBuildFile; fileRef = D6C693FD2162FEEA007D6A6D /* UIViewController+Children.swift */; };
|
||||||
|
@ -704,6 +705,7 @@
|
||||||
D6C143D9253510F4007DC240 /* ComposeEmojiTextField.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ComposeEmojiTextField.swift; sourceTree = "<group>"; };
|
D6C143D9253510F4007DC240 /* ComposeEmojiTextField.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ComposeEmojiTextField.swift; sourceTree = "<group>"; };
|
||||||
D6C1B2072545D1EC00DAAA66 /* StatusCardView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = StatusCardView.swift; sourceTree = "<group>"; };
|
D6C1B2072545D1EC00DAAA66 /* StatusCardView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = StatusCardView.swift; sourceTree = "<group>"; };
|
||||||
D6C3F4F4298ED0890009FCFF /* LocalPredicateStatusesViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LocalPredicateStatusesViewController.swift; sourceTree = "<group>"; };
|
D6C3F4F4298ED0890009FCFF /* LocalPredicateStatusesViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LocalPredicateStatusesViewController.swift; sourceTree = "<group>"; };
|
||||||
|
D6C3F4F6298ED7F70009FCFF /* FavoritesViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FavoritesViewController.swift; sourceTree = "<group>"; };
|
||||||
D6C693EE216192C2007D6A6D /* TuskerNavigationDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TuskerNavigationDelegate.swift; sourceTree = "<group>"; };
|
D6C693EE216192C2007D6A6D /* TuskerNavigationDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TuskerNavigationDelegate.swift; sourceTree = "<group>"; };
|
||||||
D6C693FB2162FE6F007D6A6D /* LoadingViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LoadingViewController.swift; sourceTree = "<group>"; };
|
D6C693FB2162FE6F007D6A6D /* LoadingViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LoadingViewController.swift; sourceTree = "<group>"; };
|
||||||
D6C693FD2162FEEA007D6A6D /* UIViewController+Children.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "UIViewController+Children.swift"; sourceTree = "<group>"; };
|
D6C693FD2162FEEA007D6A6D /* UIViewController+Children.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "UIViewController+Children.swift"; sourceTree = "<group>"; };
|
||||||
|
@ -944,6 +946,7 @@
|
||||||
children = (
|
children = (
|
||||||
D6C3F4F4298ED0890009FCFF /* LocalPredicateStatusesViewController.swift */,
|
D6C3F4F4298ED0890009FCFF /* LocalPredicateStatusesViewController.swift */,
|
||||||
D6DD8FFE2984D327002AD3FD /* BookmarksViewController.swift */,
|
D6DD8FFE2984D327002AD3FD /* BookmarksViewController.swift */,
|
||||||
|
D6C3F4F6298ED7F70009FCFF /* FavoritesViewController.swift */,
|
||||||
);
|
);
|
||||||
path = "Local Predicate Statuses List";
|
path = "Local Predicate Statuses List";
|
||||||
sourceTree = "<group>";
|
sourceTree = "<group>";
|
||||||
|
@ -2155,6 +2158,7 @@
|
||||||
D6D706A72948D4D0000827ED /* TimlineState.swift in Sources */,
|
D6D706A72948D4D0000827ED /* TimlineState.swift in Sources */,
|
||||||
D66C900B28DAB7FD00217BF2 /* TimelineViewController.swift in Sources */,
|
D66C900B28DAB7FD00217BF2 /* TimelineViewController.swift in Sources */,
|
||||||
D61F758D2933C69C00C0B37F /* StatusUpdatedNotificationTableViewCell.swift in Sources */,
|
D61F758D2933C69C00C0B37F /* StatusUpdatedNotificationTableViewCell.swift in Sources */,
|
||||||
|
D6C3F4F7298ED7F70009FCFF /* FavoritesViewController.swift in Sources */,
|
||||||
D6AEBB432321685E00E5038B /* OpenInSafariActivity.swift in Sources */,
|
D6AEBB432321685E00E5038B /* OpenInSafariActivity.swift in Sources */,
|
||||||
D6C693FE2162FEEA007D6A6D /* UIViewController+Children.swift in Sources */,
|
D6C693FE2162FEEA007D6A6D /* UIViewController+Children.swift in Sources */,
|
||||||
D61A45EA28DF51EE002BE511 /* TimelineLikeCollectionViewController.swift in Sources */,
|
D61A45EA28DF51EE002BE511 /* TimelineLikeCollectionViewController.swift in Sources */,
|
||||||
|
|
|
@ -154,7 +154,7 @@ class ExploreViewController: UIViewController, UICollectionViewDelegate, Collect
|
||||||
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.filter { $0 != .discover })
|
||||||
snapshot.appendItems([.bookmarks], toSection: .bookmarks)
|
snapshot.appendItems([.bookmarks, .favorites], toSection: .bookmarks)
|
||||||
if mastodonController.instanceFeatures.trends,
|
if mastodonController.instanceFeatures.trends,
|
||||||
!Preferences.shared.hideDiscover {
|
!Preferences.shared.hideDiscover {
|
||||||
addDiscoverSection(to: &snapshot)
|
addDiscoverSection(to: &snapshot)
|
||||||
|
@ -336,6 +336,9 @@ class ExploreViewController: UIViewController, UICollectionViewDelegate, Collect
|
||||||
case .bookmarks:
|
case .bookmarks:
|
||||||
show(BookmarksViewController(mastodonController: mastodonController), sender: nil)
|
show(BookmarksViewController(mastodonController: mastodonController), sender: nil)
|
||||||
|
|
||||||
|
case .favorites:
|
||||||
|
show(FavoritesViewController(mastodonController: mastodonController), sender: nil)
|
||||||
|
|
||||||
case .trendingStatuses:
|
case .trendingStatuses:
|
||||||
show(TrendingStatusesViewController(mastodonController: mastodonController), sender: nil)
|
show(TrendingStatusesViewController(mastodonController: mastodonController), sender: nil)
|
||||||
|
|
||||||
|
@ -408,6 +411,7 @@ extension ExploreViewController {
|
||||||
|
|
||||||
enum Item: Hashable {
|
enum Item: Hashable {
|
||||||
case bookmarks
|
case bookmarks
|
||||||
|
case favorites
|
||||||
case trendingStatuses
|
case trendingStatuses
|
||||||
case trendingTags
|
case trendingTags
|
||||||
case trendingLinks
|
case trendingLinks
|
||||||
|
@ -423,6 +427,8 @@ extension ExploreViewController {
|
||||||
switch self {
|
switch self {
|
||||||
case .bookmarks:
|
case .bookmarks:
|
||||||
return NSLocalizedString("Bookmarks", comment: "bookmarks nav item title")
|
return NSLocalizedString("Bookmarks", comment: "bookmarks nav item title")
|
||||||
|
case .favorites:
|
||||||
|
return NSLocalizedString("Favorites", comment: "favorites nav item title")
|
||||||
case .trendingStatuses:
|
case .trendingStatuses:
|
||||||
return NSLocalizedString("Trending Posts", comment: "trending statuses nav item title")
|
return NSLocalizedString("Trending Posts", comment: "trending statuses nav item title")
|
||||||
case .trendingTags:
|
case .trendingTags:
|
||||||
|
@ -451,6 +457,8 @@ extension ExploreViewController {
|
||||||
switch self {
|
switch self {
|
||||||
case .bookmarks:
|
case .bookmarks:
|
||||||
name = "bookmark.fill"
|
name = "bookmark.fill"
|
||||||
|
case .favorites:
|
||||||
|
name = "star.fill"
|
||||||
case .trendingStatuses:
|
case .trendingStatuses:
|
||||||
name = "doc.text.image"
|
name = "doc.text.image"
|
||||||
case .trendingTags:
|
case .trendingTags:
|
||||||
|
@ -477,6 +485,8 @@ extension ExploreViewController {
|
||||||
switch (lhs, rhs) {
|
switch (lhs, rhs) {
|
||||||
case (.bookmarks, .bookmarks):
|
case (.bookmarks, .bookmarks):
|
||||||
return true
|
return true
|
||||||
|
case (.favorites, .favorites):
|
||||||
|
return true
|
||||||
case (.trendingStatuses, .trendingStatuses):
|
case (.trendingStatuses, .trendingStatuses):
|
||||||
return true
|
return true
|
||||||
case (.trendingTags, .trendingTags):
|
case (.trendingTags, .trendingTags):
|
||||||
|
@ -506,6 +516,8 @@ extension ExploreViewController {
|
||||||
switch self {
|
switch self {
|
||||||
case .bookmarks:
|
case .bookmarks:
|
||||||
hasher.combine("bookmarks")
|
hasher.combine("bookmarks")
|
||||||
|
case .favorites:
|
||||||
|
hasher.combine("favorites")
|
||||||
case .trendingStatuses:
|
case .trendingStatuses:
|
||||||
hasher.combine("trendingStatuses")
|
hasher.combine("trendingStatuses")
|
||||||
case .trendingTags:
|
case .trendingTags:
|
||||||
|
|
|
@ -0,0 +1,27 @@
|
||||||
|
//
|
||||||
|
// FavoritesViewController.swift
|
||||||
|
// Tusker
|
||||||
|
//
|
||||||
|
// Created by Shadowfacts on 2/4/23.
|
||||||
|
// Copyright © 2023 Shadowfacts. All rights reserved.
|
||||||
|
//
|
||||||
|
|
||||||
|
import UIKit
|
||||||
|
import Pachyderm
|
||||||
|
|
||||||
|
class FavoritesViewController: LocalPredicateStatusesViewController {
|
||||||
|
|
||||||
|
init(mastodonController: MastodonController) {
|
||||||
|
super.init(
|
||||||
|
predicate: \.favourited,
|
||||||
|
predicateTitle: "Favorites",
|
||||||
|
request: { Client.getFavourites(range: $0) },
|
||||||
|
mastodonController: mastodonController
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
required init?(coder: NSCoder) {
|
||||||
|
fatalError("init(coder:) has not been implemented")
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -41,7 +41,7 @@ class MainSidebarViewController: UIViewController {
|
||||||
}
|
}
|
||||||
|
|
||||||
var exploreTabItems: [Item] {
|
var exploreTabItems: [Item] {
|
||||||
var items: [Item] = [.explore, .bookmarks, .profileDirectory]
|
var items: [Item] = [.explore, .bookmarks, .favorites, .profileDirectory]
|
||||||
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))
|
||||||
|
@ -172,6 +172,7 @@ class MainSidebarViewController: UIViewController {
|
||||||
.tab(.notifications),
|
.tab(.notifications),
|
||||||
.explore,
|
.explore,
|
||||||
.bookmarks,
|
.bookmarks,
|
||||||
|
.favorites,
|
||||||
.tab(.myProfile)
|
.tab(.myProfile)
|
||||||
], toSection: .tabs)
|
], toSection: .tabs)
|
||||||
snapshot.appendItems([
|
snapshot.appendItems([
|
||||||
|
@ -384,7 +385,7 @@ extension MainSidebarViewController {
|
||||||
}
|
}
|
||||||
enum Item: Hashable {
|
enum Item: Hashable {
|
||||||
case tab(MainTabBarViewController.Tab)
|
case tab(MainTabBarViewController.Tab)
|
||||||
case explore, bookmarks
|
case explore, bookmarks, favorites
|
||||||
case discoverHeader, profileDirectory
|
case discoverHeader, profileDirectory
|
||||||
case listsHeader, list(List), addList
|
case listsHeader, list(List), addList
|
||||||
case savedHashtagsHeader, savedHashtag(Hashtag), addSavedHashtag
|
case savedHashtagsHeader, savedHashtag(Hashtag), addSavedHashtag
|
||||||
|
@ -398,6 +399,8 @@ extension MainSidebarViewController {
|
||||||
return "Explore"
|
return "Explore"
|
||||||
case .bookmarks:
|
case .bookmarks:
|
||||||
return "Bookmarks"
|
return "Bookmarks"
|
||||||
|
case .favorites:
|
||||||
|
return "Favorites"
|
||||||
case .discoverHeader:
|
case .discoverHeader:
|
||||||
return "Discover"
|
return "Discover"
|
||||||
case .profileDirectory:
|
case .profileDirectory:
|
||||||
|
@ -431,6 +434,8 @@ extension MainSidebarViewController {
|
||||||
return "magnifyingglass"
|
return "magnifyingglass"
|
||||||
case .bookmarks:
|
case .bookmarks:
|
||||||
return "bookmark"
|
return "bookmark"
|
||||||
|
case .favorites:
|
||||||
|
return "star"
|
||||||
case .profileDirectory:
|
case .profileDirectory:
|
||||||
return "person.2.fill"
|
return "person.2.fill"
|
||||||
case .list(_):
|
case .list(_):
|
||||||
|
|
|
@ -232,9 +232,9 @@ extension MainSplitViewController: UISplitViewControllerDelegate {
|
||||||
|
|
||||||
tabBarViewController.select(tab: .explore)
|
tabBarViewController.select(tab: .explore)
|
||||||
|
|
||||||
case .bookmarks, .profileDirectory, .list(_), .savedHashtag(_), .savedInstance(_):
|
case .bookmarks, .favorites, .profileDirectory, .list(_), .savedHashtag(_), .savedInstance(_):
|
||||||
tabBarViewController.select(tab: .explore)
|
tabBarViewController.select(tab: .explore)
|
||||||
// Make sure the Explore VC doesn't show it's 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.
|
||||||
let exploreNav = tabBarViewController.viewController(for: .explore) as! UINavigationController
|
let exploreNav = tabBarViewController.viewController(for: .explore) as! UINavigationController
|
||||||
let explore = exploreNav.viewControllers.first as! ExploreViewController
|
let explore = exploreNav.viewControllers.first as! ExploreViewController
|
||||||
|
@ -305,6 +305,8 @@ extension MainSplitViewController: UISplitViewControllerDelegate {
|
||||||
switch tabNavigationStack[1] {
|
switch tabNavigationStack[1] {
|
||||||
case is BookmarksViewController:
|
case is BookmarksViewController:
|
||||||
exploreItem = .bookmarks
|
exploreItem = .bookmarks
|
||||||
|
case is FavoritesViewController:
|
||||||
|
exploreItem = .favorites
|
||||||
case let listVC as ListTimelineViewController:
|
case let listVC as ListTimelineViewController:
|
||||||
exploreItem = .list(listVC.list)
|
exploreItem = .list(listVC.list)
|
||||||
case let hashtagVC as HashtagTimelineViewController:
|
case let hashtagVC as HashtagTimelineViewController:
|
||||||
|
@ -380,6 +382,8 @@ fileprivate extension MainSidebarViewController.Item {
|
||||||
return SearchViewController(mastodonController: mastodonController)
|
return SearchViewController(mastodonController: mastodonController)
|
||||||
case .bookmarks:
|
case .bookmarks:
|
||||||
return BookmarksViewController(mastodonController: mastodonController)
|
return BookmarksViewController(mastodonController: mastodonController)
|
||||||
|
case .favorites:
|
||||||
|
return FavoritesViewController(mastodonController: mastodonController)
|
||||||
case .profileDirectory:
|
case .profileDirectory:
|
||||||
return ProfileDirectoryViewController(mastodonController: mastodonController)
|
return ProfileDirectoryViewController(mastodonController: mastodonController)
|
||||||
case let .list(list):
|
case let .list(list):
|
||||||
|
|
Loading…
Reference in New Issue