From 2fc7b4dad83be5f3f1a344cadde62d807eb3b01f Mon Sep 17 00:00:00 2001 From: Justin Mazzocchi <2831158+jzzocc@users.noreply.github.com> Date: Tue, 1 Dec 2020 10:40:19 -0800 Subject: [PATCH] View bookmarks --- DB/Sources/DB/Content/TimelineRecord.swift | 2 +- DB/Sources/DB/Entities/Timeline.swift | 3 +++ DB/Sources/DB/Extensions/Timeline+Extensions.swift | 2 ++ Localizations/Localizable.strings | 1 + .../Sources/MastodonAPI/Endpoints/StatusesEndpoint.swift | 5 ++++- ServiceLayer/Sources/ServiceLayer/Entities/Timeline.swift | 2 ++ ViewModels/Sources/ViewModels/NavigationViewModel.swift | 8 +++++++- Views/SecondaryNavigationView.swift | 6 +++++- Views/TabNavigationView.swift | 5 ++++- 9 files changed, 29 insertions(+), 5 deletions(-) diff --git a/DB/Sources/DB/Content/TimelineRecord.swift b/DB/Sources/DB/Content/TimelineRecord.swift index 0cbcc4e..30c8a1e 100644 --- a/DB/Sources/DB/Content/TimelineRecord.swift +++ b/DB/Sources/DB/Content/TimelineRecord.swift @@ -44,7 +44,7 @@ extension TimelineRecord { id = timeline.id switch timeline { - case .home, .local, .federated, .favorites: + case .home, .local, .federated, .favorites, .bookmarks: listId = nil listTitle = nil tag = nil diff --git a/DB/Sources/DB/Entities/Timeline.swift b/DB/Sources/DB/Entities/Timeline.swift index 5e59fe6..de73ec7 100644 --- a/DB/Sources/DB/Entities/Timeline.swift +++ b/DB/Sources/DB/Entities/Timeline.swift @@ -11,6 +11,7 @@ public enum Timeline: Hashable { case tag(String) case profile(accountId: Account.Id, profileCollection: ProfileCollection) case favorites + case bookmarks } public extension Timeline { @@ -50,6 +51,8 @@ extension Timeline: Identifiable { return "profile-\(accountId)-\(profileCollection)" case .favorites: return "favorites" + case .bookmarks: + return "bookmarks" } } } diff --git a/DB/Sources/DB/Extensions/Timeline+Extensions.swift b/DB/Sources/DB/Extensions/Timeline+Extensions.swift index 7dfdb49..84a1b7c 100644 --- a/DB/Sources/DB/Extensions/Timeline+Extensions.swift +++ b/DB/Sources/DB/Extensions/Timeline+Extensions.swift @@ -26,6 +26,8 @@ extension Timeline { self = .profile(accountId: accountId, profileCollection: profileCollection) case (Timeline.favorites.id, _, _, _, _, _): self = .favorites + case (Timeline.bookmarks.id, _, _, _, _, _): + self = .bookmarks default: return nil } diff --git a/Localizations/Localizable.strings b/Localizations/Localizable.strings index e486776..d6e7ac9 100644 --- a/Localizations/Localizable.strings +++ b/Localizations/Localizable.strings @@ -24,6 +24,7 @@ "add-identity.unable-to-connect-to-instance" = "Unable to connect to instance"; "attachment.sensitive-content" = "Sensitive content"; "attachment.media-hidden" = "Media hidden"; +"bookmarks" = "Bookmarks"; "cancel" = "Cancel"; "favorites" = "Favorites"; "registration.review-terms-of-use-and-privacy-policy-%@" = "Please review %@'s Terms of Use and Privacy Policy to continue"; diff --git a/MastodonAPI/Sources/MastodonAPI/Endpoints/StatusesEndpoint.swift b/MastodonAPI/Sources/MastodonAPI/Endpoints/StatusesEndpoint.swift index a5edf70..e77dc65 100644 --- a/MastodonAPI/Sources/MastodonAPI/Endpoints/StatusesEndpoint.swift +++ b/MastodonAPI/Sources/MastodonAPI/Endpoints/StatusesEndpoint.swift @@ -11,6 +11,7 @@ public enum StatusesEndpoint { case timelinesList(id: List.Id) case accountsStatuses(id: Account.Id, excludeReplies: Bool, onlyMedia: Bool, pinned: Bool) case favourites + case bookmarks } extension StatusesEndpoint: Endpoint { @@ -22,7 +23,7 @@ extension StatusesEndpoint: Endpoint { return defaultContext + ["timelines"] case .accountsStatuses: return defaultContext + ["accounts"] - case .favourites: + case .favourites, .bookmarks: return defaultContext } } @@ -41,6 +42,8 @@ extension StatusesEndpoint: Endpoint { return [id, "statuses"] case .favourites: return ["favourites"] + case .bookmarks: + return ["bookmarks"] } } diff --git a/ServiceLayer/Sources/ServiceLayer/Entities/Timeline.swift b/ServiceLayer/Sources/ServiceLayer/Entities/Timeline.swift index 254f8ae..dc70130 100644 --- a/ServiceLayer/Sources/ServiceLayer/Entities/Timeline.swift +++ b/ServiceLayer/Sources/ServiceLayer/Entities/Timeline.swift @@ -41,6 +41,8 @@ extension Timeline { pinned: false) case .favorites: return .favourites + case .bookmarks: + return .bookmarks } } } diff --git a/ViewModels/Sources/ViewModels/NavigationViewModel.swift b/ViewModels/Sources/ViewModels/NavigationViewModel.swift index da58e40..92e2ccb 100644 --- a/ViewModels/Sources/ViewModels/NavigationViewModel.swift +++ b/ViewModels/Sources/ViewModels/NavigationViewModel.swift @@ -95,7 +95,7 @@ public extension NavigationViewModel { switch timeline { case .home, .list: return identification.identity.handle - case .local, .federated, .tag, .profile, .favorites: + case .local, .federated, .tag, .profile, .favorites, .bookmarks: return identification.identity.instance?.uri ?? "" } } @@ -146,6 +146,12 @@ public extension NavigationViewModel { collectionService: identification.service.service(timeline: .favorites), identification: identification) } + + func bookmarksViewModel() -> CollectionViewModel { + CollectionItemsViewModel( + collectionService: identification.service.service(timeline: .bookmarks), + identification: identification) + } } extension NavigationViewModel.Tab: Identifiable { diff --git a/Views/SecondaryNavigationView.swift b/Views/SecondaryNavigationView.swift index e82fe81..de959f9 100644 --- a/Views/SecondaryNavigationView.swift +++ b/Views/SecondaryNavigationView.swift @@ -58,7 +58,11 @@ struct SecondaryNavigationView: View { } NavigationLink(destination: TableView(viewModel: viewModel.favoritesViewModel()) .navigationTitle(Text("favorites"))) { - Label("favorites", systemImage: "star.fill") + Label("favorites", systemImage: "star") + } + NavigationLink(destination: TableView(viewModel: viewModel.bookmarksViewModel()) + .navigationTitle(Text("bookmarks"))) { + Label("bookmarks", systemImage: "bookmark") } } Section { diff --git a/Views/TabNavigationView.swift b/Views/TabNavigationView.swift index 3671048..9fedc10 100644 --- a/Views/TabNavigationView.swift +++ b/Views/TabNavigationView.swift @@ -161,6 +161,8 @@ private extension Timeline { return "" case .favorites: return NSLocalizedString("favorites", comment: "") + case .bookmarks: + return NSLocalizedString("bookmarks", comment: "") } } @@ -172,7 +174,8 @@ private extension Timeline { case .list: return "scroll" case .tag: return "number" case .profile: return "person" - case .favorites: return "star.fill" + case .favorites: return "star" + case .bookmarks: return "bookmark" } } }