Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New Post Tracker #874

Merged
merged 73 commits into from
Jan 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
73 commits
Select commit Hold shift + click to select a range
3e23425
rebase conflict
EricBAndrews Jan 5, 2024
235001b
commit before rebase
EricBAndrews Jan 5, 2024
ee4f84c
updated StandardTracker to use new LoadAction enum to govern loading,…
EricBAndrews Jan 5, 2024
79e54d1
fixed a bug where toggling to unread only in the inbox wasn't working…
EricBAndrews Jan 6, 2024
31aad9a
added cursor support to StandardTracker
EricBAndrews Jan 7, 2024
2e4db5d
added most basic navigation back to feeds
EricBAndrews Jan 8, 2024
2248d5a
incremental progress
EricBAndrews Jan 8, 2024
6261ce3
got rudimentary nav linked up to community list
EricBAndrews Jan 8, 2024
0f50aa5
rebuilding aggregate feed view
EricBAndrews Jan 12, 2024
c9d7415
tested page and cursor loading
EricBAndrews Jan 12, 2024
5c6de5d
implemented core feed
EricBAndrews Jan 14, 2024
33f67aa
progress towards no posts view
EricBAndrews Jan 15, 2024
5ad862d
progress towards no posts view
EricBAndrews Jan 15, 2024
bdf5b06
new PostFeedView
EricBAndrews Jan 15, 2024
0eea1d5
moved voting into PostModel
EricBAndrews Jan 15, 2024
38bd0b3
moved most post methods into PostModel
EricBAndrews Jan 17, 2024
b389110
merged dev
EricBAndrews Jan 17, 2024
2cf8c5e
moved editing to PostModel
EricBAndrews Jan 17, 2024
950bc40
removed unnecessary calls to postTracker from post editing
EricBAndrews Jan 17, 2024
430a046
got filtering by read working
EricBAndrews Jan 18, 2024
3f30a80
filters mostly operational
EricBAndrews Jan 19, 2024
452bb1d
got the basics of nav working
EricBAndrews Jan 20, 2024
fa3d5c6
got the basics of nav working
EricBAndrews Jan 20, 2024
6b2e1ea
removed post tracker from LargePost
EricBAndrews Jan 20, 2024
e74ac04
implemented deletion
EricBAndrews Jan 20, 2024
ec4e331
tweaked filtering behavior
EricBAndrews Jan 21, 2024
d255c66
added no posts view back in
EricBAndrews Jan 21, 2024
9bdd880
added sorting
EricBAndrews Jan 21, 2024
ad86dd8
reinstated feed headers
EricBAndrews Jan 21, 2024
f12fddb
one approach to background color problems
EricBAndrews Jan 21, 2024
204e44a
set feed background to systemBackground
EricBAndrews Jan 21, 2024
6e39f0d
initial work towards post and comment tracker
EricBAndrews Jan 22, 2024
c54416d
initial work towards post and comment tracker
EricBAndrews Jan 22, 2024
61d16c0
killed some old views
EricBAndrews Jan 22, 2024
9ce3e11
killed FeedView
EricBAndrews Jan 22, 2024
880ab44
killed PostFeedView
EricBAndrews Jan 22, 2024
41dc2a9
killed old feed components
EricBAndrews Jan 22, 2024
5921680
refactored community section
EricBAndrews Jan 22, 2024
8e7ada4
added scroll thing back to community list
EricBAndrews Jan 22, 2024
8dea7cc
refactored names
EricBAndrews Jan 22, 2024
977f782
removed old post tracker
EricBAndrews Jan 22, 2024
5e6dd56
tweaked scroll bar
EricBAndrews Jan 22, 2024
76ab4de
got default feed working
EricBAndrews Jan 22, 2024
fb902b3
fixed subscribed indicator
EricBAndrews Jan 22, 2024
b4899c0
renamed NewPostFilter to PostFilter
EricBAndrews Jan 22, 2024
b682147
removed dead code
EricBAndrews Jan 22, 2024
d8e8011
made swiftlint mean again
EricBAndrews Jan 22, 2024
43a770d
lint
EricBAndrews Jan 22, 2024
189706b
fixed switching post tabs reloading feed
EricBAndrews Jan 23, 2024
e7f699e
fixed community list not being fancy tab scroll compatible
EricBAndrews Jan 23, 2024
9374e35
file ordering
EricBAndrews Jan 23, 2024
099fe0b
fixed crash on opening with saved as default
EricBAndrews Jan 23, 2024
bf0b8e2
removed dead code
EricBAndrews Jan 23, 2024
115ed06
changed how initial sort type is handled
EricBAndrews Jan 23, 2024
5b551b8
masked bad noPostsView behavior
EricBAndrews Jan 23, 2024
60826ff
added 0.17 compatibility decoder back into ListingType
EricBAndrews Jan 24, 2024
2d3229d
neatened up shortcut handling
EricBAndrews Jan 24, 2024
6494ae1
re-enabled lemmy link resolution on feeds
EricBAndrews Jan 24, 2024
d481347
fixed (yet another) post sort issue
EricBAndrews Jan 24, 2024
e62ab66
Merge branch 'dev' into eric/new-post-tracker
EricBAndrews Jan 24, 2024
a9addd2
fixed unread count and read status not properly propagating
EricBAndrews Jan 24, 2024
60358b4
fixed load flicker on community
EricBAndrews Jan 24, 2024
374a9c2
Update Mlem/Views/Tabs/Feeds/Feed Types/AggregateFeedView.swift
EricBAndrews Jan 24, 2024
6fac552
added padding on top of noPostsView
EricBAndrews Jan 25, 2024
abac03b
removed stale tests
EricBAndrews Jan 25, 2024
66ba3aa
removed testing code
EricBAndrews Jan 25, 2024
4e56fc6
fixed noPostsView not properly reloading posts
EricBAndrews Jan 25, 2024
6d440d1
smoothed some animations and removed test prints
EricBAndrews Jan 25, 2024
ae3d593
fixed moderator flair not appearing
EricBAndrews Jan 25, 2024
625a580
removed test prints
EricBAndrews Jan 25, 2024
350012e
removed more test prints
EricBAndrews Jan 25, 2024
05260ed
Merge branch 'dev' into eric/new-post-tracker
EricBAndrews Jan 25, 2024
ee4ee9c
Merge branch 'dev' into eric/new-post-tracker
EricBAndrews Jan 27, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
212 changes: 120 additions & 92 deletions Mlem.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion Mlem/API/APIClient/APIClient+Comment.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ extension APIClient {
func loadComments(
for postId: Int,
maxDepth: Int = 15,
type: FeedType = .all,
type: APIListingType = .all,
sort: CommentSortType? = nil,
page: Int? = nil,
limit: Int? = nil,
Expand Down
2 changes: 1 addition & 1 deletion Mlem/API/APIClient/APIClient+Post.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ extension APIClient {
page: Int,
cursor: String?,
sort: PostSortType?,
type: FeedType,
type: APIListingType,
limit: Int?,
savedOnly: Bool?,
communityName: String?
Expand Down
2 changes: 1 addition & 1 deletion Mlem/API/APIClient/APIClient.swift
Original file line number Diff line number Diff line change
Expand Up @@ -389,7 +389,7 @@ extension APIClient {
query: String,
searchType: SearchType,
sortOption: PostSortType,
listingType: FeedType,
listingType: APIListingType,
page: Int?,
limit: Int?
) async throws -> SearchResponse {
Expand Down
5 changes: 3 additions & 2 deletions Mlem/API/Models/ListingType.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,11 @@ enum APIListingType: String, Codable {
case all = "All"
case local = "Local"
case subscribed = "Subscribed"
case moderatorView = "ModeratorView"

// Pre 0.18.0 it appears that they used integers instead of strings here. We can remove this intialiser once we drop support for old versions. To fully support both systems, we'd also need to *encode* back into the correct integer or string format. I'd rather not go through the effort for instance versions that most people don't use any more, so I've disabled the option to edit account settings on instances running <0.18.0
// - sjmarf

// TODO: 0.17 deprecation remove this initialiser

init(from decoder: Decoder) throws {
EricBAndrews marked this conversation as resolved.
Show resolved Hide resolved
Expand All @@ -28,7 +29,7 @@ enum APIListingType: String, Codable {
}
self = value
} else if let intValue = try? container.decode(Int.self) {
guard 0...2 ~= intValue else {
guard 0 ... 2 ~= intValue else {
throw DecodingError.dataCorruptedError(
in: container,
debugDescription: "Must be an integer in range 0...2."
Expand Down
2 changes: 1 addition & 1 deletion Mlem/API/Requests/Comment/GetComments.swift
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ struct GetCommentsRequest: APIGetRequest {
session: APISession,
postId: Int,
maxDepth: Int,
type: FeedType,
type: APIListingType,
sort: CommentSortType?,
page: Int?,
limit: Int?,
Expand Down
2 changes: 1 addition & 1 deletion Mlem/API/Requests/Post/GetPosts.swift
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ struct GetPostsRequest: APIGetRequest {
page: Int,
cursor: String?,
sort: PostSortType?,
type: FeedType,
type: APIListingType,
limit: Int? = nil,
savedOnly: Bool? = nil,
communityName: String? = nil
Expand Down
2 changes: 1 addition & 1 deletion Mlem/API/Requests/SearchRequest.swift
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ struct SearchRequest: APIGetRequest {
query: String,
searchType: SearchType,
sortOption: PostSortType,
listingType: FeedType,
listingType: APIListingType,
page: Int?,
communityId: Int?,
communityName: String?,
Expand Down
24 changes: 12 additions & 12 deletions Mlem/ContentView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ struct ContentView: View {
var body: some View {
FancyTabBar(selection: $tabSelection, navigationSelection: $tabNavigation, dragUpGestureCallback: showAccountSwitcherDragCallback) {
Group {
FeedRoot()
FeedsView()
.fancyTabItem(tag: TabSelection.feeds) {
FancyTabBarLabel(
tag: TabSelection.feeds,
Expand All @@ -76,18 +76,18 @@ struct ContentView: View {
}

ProfileView(user: myUser)
.fancyTabItem(tag: TabSelection.profile) {
FancyTabBarLabel(
tag: TabSelection.profile,
customText: appState.tabDisplayName,
symbolConfiguration: .init(
symbol: FancyTabBarLabel.SymbolConfiguration.profile.symbol,
activeSymbol: FancyTabBarLabel.SymbolConfiguration.profile.activeSymbol,
remoteSymbolUrl: appState.profileTabRemoteSymbolUrl
.fancyTabItem(tag: TabSelection.profile) {
FancyTabBarLabel(
tag: TabSelection.profile,
customText: appState.tabDisplayName,
symbolConfiguration: .init(
symbol: FancyTabBarLabel.SymbolConfiguration.profile.symbol,
activeSymbol: FancyTabBarLabel.SymbolConfiguration.profile.activeSymbol,
remoteSymbolUrl: appState.profileTabRemoteSymbolUrl
)
)
)
.simultaneousGesture(accountSwitchLongPress)
}
.simultaneousGesture(accountSwitchLongPress)
}

SearchRoot()
.fancyTabItem(tag: TabSelection.search) {
Expand Down
132 changes: 100 additions & 32 deletions Mlem/Enums/FeedType.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2,76 +2,144 @@
// FeedType.swift
// Mlem
//
// Created by Jonathan de Jong on 12.06.2023.
// Created by Eric Andrews on 2024-01-08.
//

import Foundation
import SwiftUI

enum FeedType: String, Encodable, SettingsOptions, AssociatedColor {
var id: Self { self }

enum FeedType {
case all, local, subscribed, saved
case community(CommunityModel)

static var allAggregateFeedCases: [FeedType] = [.all, .local, .subscribed, .saved]

var label: String {
return rawValue
switch self {
case .all: "All"
case .local: "Local"
case .subscribed: "Subscribed"
case .saved: "Saved"
case let .community(communityModel): communityModel.name
}
}

var description: String {
/// Maps FeedType to APIListingType
var toApiListingType: APIListingType {
switch self {
case .all:
return "Subscribed communities from all instances"
case .local:
return "Local communities from your server"
case .subscribed:
return "All communities that federate with your server"
case .all: .all
case .local: .local
case .subscribed: .subscribed
case .saved: .all // TODO: change this?
case .community: .subscribed
}
}

var color: Color? {
/// String for use in shortcuts
var toShortcutString: String {
switch self {
case .all: "All"
case .local: "Local"
case .subscribed: "Subscribed"
case .saved: "Saved" // TODO: change this?
case .community: "Subscribed"
}
}

static func fromShortcutString(shortcut: String?) -> FeedType? {
switch shortcut {
case "All":
return .all
case "Local":
return .local
case "Subscribed":
return .subscribed
case "Saved":
return .saved
default:
return nil
}
}

var communityId: Int? {
switch self {
case let .community(communityModel): communityModel.communityId
default: nil
}
}
}

extension FeedType: Hashable, Identifiable {
func hash(into hasher: inout Hasher) {
switch self {
case .all:
return .blue
hasher.combine("all")
case .local:
return .green
hasher.combine("local")
case .subscribed:
return .red
hasher.combine("subscribed")
case .saved:
hasher.combine("saved")
case let .community(communityModel):
hasher.combine("community")
hasher.combine(communityModel.communityId)
}
}

case subscribed = "Subscribed"
case local = "Local"
case all = "All"

var id: Int { hashValue }
}

extension FeedType: AssociatedIcon {
var iconName: String {
switch self {
case .all: return Icons.federatedFeed
case .local: return Icons.localFeed
case .subscribed: return Icons.subscribedFeed
case .all: Icons.federatedFeed
case .local: Icons.localFeed
case .subscribed: Icons.subscribedFeed
case .saved: Icons.savedFeed
case .community: Icons.community
}
}

var iconNameFill: String {
switch self {
case .all: return Icons.federatedFeedFill
case .local: return Icons.localFeedFill
case .subscribed: return Icons.subscribedFeedFill
case .all: Icons.federatedFeedFill
case .local: Icons.localFeedFill
case .subscribed: Icons.subscribedFeedFill
case .saved: Icons.savedFeedFill
case .community: Icons.communityFill
}
}

var iconNameCircle: String {
switch self {
case .all: return Icons.federatedFeedCircle
case .local: return Icons.localFeedCircle
case .subscribed: return Icons.subscribedFeedCircle
case .all: Icons.federatedFeedCircle
case .local: Icons.localFeedCircle
case .subscribed: Icons.subscribedFeedCircle
case .saved: Icons.savedFeedCircle
case .community: Icons.community
}
}

/// Icon to use in system settings. This should be removed when the "unified symbol handling" is closed
var settingsIconName: String {
switch self {
case .all: return "circle.hexagongrid"
case .local: return "house"
case .subscribed: return "newspaper"
case .all: "circle.hexagongrid"
case .local: "house"
case .subscribed: "newspaper"
case .saved: Icons.save
case .community: Icons.community
}
}
}

extension FeedType: AssociatedColor {
var color: Color? {
switch self {
case .all: .blue
case .local: .purple
case .subscribed: .red
case .saved: .green
case .community: .blue
}
}
}
34 changes: 34 additions & 0 deletions Mlem/Enums/Settings/DefaultFeedType.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
//
// DefaultFeedType.swift
// Mlem
//
// Created by Eric Andrews on 2024-01-22.
//

import Foundation

enum DefaultFeedType: String, SettingsOptions, CaseIterable {
case all, local, subscribed, saved

var label: String { rawValue.capitalized }

var settingsIconName: String {
switch self {
case .all: Icons.federatedFeed
case .local: Icons.localFeed
case .subscribed: Icons.subscribedFeed
case .saved: Icons.savedFeed
}
}

var toFeedType: FeedType {
switch self {
case .all: .all
case .local: .local
case .subscribed: .subscribed
case .saved: .saved
}
}

var id: Self { self }
}
2 changes: 1 addition & 1 deletion Mlem/Enums/User/UserViewTab.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import Foundation

enum UserViewTab: String, CaseIterable, Identifiable {
case overview, comments, posts, communities, saved
case overview, comments, posts, communities

var id: Self { self }

Expand Down
17 changes: 17 additions & 0 deletions Mlem/Extensions/Tracker Items/PostModel+TrackerItem.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
//
// PostModel+TrackerItem.swift
// Mlem
//
// Created by Eric Andrews on 2024-01-04.
//

import Foundation

extension PostModel: TrackerItem {
func sortVal(sortType: TrackerSortType) -> TrackerSortVal {
switch sortType {
case .published:
return .published(published)
}
}
}
Loading
Loading