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

added lists view and two ways to navigate to it #1726

Merged
merged 5 commits into from
Jan 11, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Release Notes
- Fixed: adding/removing relays not reflected on feed filter. [#119](https://github.com/verse-pbc/issues/issues/119)
- Added Lists view and two ways to navigate to it. [#133](https://github.com/verse-pbc/issues/issues/133)

### Internal Changes
- Added function for creating a new list and a test verifying list editing. [#112](https://github.com/verse-pbc/issues/issues/112)
Expand Down
12 changes: 12 additions & 0 deletions Nos.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,7 @@
50EA86D42D28150F001E62CC /* FeedSource.swift in Sources */ = {isa = PBXBuildFile; fileRef = 50EA86D32D28150D001E62CC /* FeedSource.swift */; };
50EA86D52D28150F001E62CC /* FeedSource.swift in Sources */ = {isa = PBXBuildFile; fileRef = 50EA86D32D28150D001E62CC /* FeedSource.swift */; };
50EA885C2D2D523F001E62CC /* follow_set_with_unknown_tag.json in Resources */ = {isa = PBXBuildFile; fileRef = 50EA885B2D2D5235001E62CC /* follow_set_with_unknown_tag.json */; };
50EA886F2D2D5783001E62CC /* AuthorListsView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 50EA886E2D2D5780001E62CC /* AuthorListsView.swift */; };
50F695072C6392C4000E4C74 /* zap_receipt.json in Resources */ = {isa = PBXBuildFile; fileRef = 50F695062C6392C4000E4C74 /* zap_receipt.json */; };
5B098DBC2BDAF6CB00500A1B /* NoteParserTests+NIP08.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5B098DBB2BDAF6CB00500A1B /* NoteParserTests+NIP08.swift */; };
5B098DC62BDAF73500500A1B /* AttributedString+Links.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5B098DC52BDAF73500500A1B /* AttributedString+Links.swift */; };
Expand Down Expand Up @@ -794,6 +795,7 @@
50E2EB712C86175900D4B360 /* NSRegularExpression+Replacement.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "NSRegularExpression+Replacement.swift"; sourceTree = "<group>"; };
50EA86D32D28150D001E62CC /* FeedSource.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FeedSource.swift; sourceTree = "<group>"; };
50EA885B2D2D5235001E62CC /* follow_set_with_unknown_tag.json */ = {isa = PBXFileReference; lastKnownFileType = text.json; path = follow_set_with_unknown_tag.json; sourceTree = "<group>"; };
50EA886E2D2D5780001E62CC /* AuthorListsView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AuthorListsView.swift; sourceTree = "<group>"; };
50F695062C6392C4000E4C74 /* zap_receipt.json */ = {isa = PBXFileReference; lastKnownFileType = text.json; path = zap_receipt.json; sourceTree = "<group>"; };
5B098DBB2BDAF6CB00500A1B /* NoteParserTests+NIP08.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "NoteParserTests+NIP08.swift"; sourceTree = "<group>"; };
5B098DC52BDAF73500500A1B /* AttributedString+Links.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "AttributedString+Links.swift"; sourceTree = "<group>"; };
Expand Down Expand Up @@ -1582,6 +1584,14 @@
path = Onboarding;
sourceTree = "<group>";
};
50EA886D2D2D5776001E62CC /* Lists */ = {
isa = PBXGroup;
children = (
50EA886E2D2D5780001E62CC /* AuthorListsView.swift */,
);
path = Lists;
sourceTree = "<group>";
};
5B79F5E92B97B5D7002DA9BE /* Edit */ = {
isa = PBXGroup;
children = (
Expand Down Expand Up @@ -2071,6 +2081,7 @@
65BD8DC12BDAF2C300802039 /* Discover */,
03618B112C825D8700BCBC55 /* Fixtures */,
C96877B32B4EDCCF0051ED2F /* Home */,
50EA886D2D2D5776001E62CC /* Lists */,
04368D542C99D32B00DEAA2E /* Moderation */,
C9CFF6D02AB241EB00D4B368 /* Modifiers */,
03618C6D2C8267E600BCBC55 /* Note */,
Expand Down Expand Up @@ -2422,6 +2433,7 @@
5BC0D9CC2B867B9D005D6980 /* NamesAPI.swift in Sources */,
C987F81D29BA6D9A00B44E7A /* ProfileTab.swift in Sources */,
C9ADB14129951CB10075E7F8 /* NSManagedObject+Nos.swift in Sources */,
50EA886F2D2D5783001E62CC /* AuthorListsView.swift in Sources */,
503CA9792D19C39F00805EF8 /* FeedCustomizerView.swift in Sources */,
C9F84C21298DC36800C6714D /* AppView.swift in Sources */,
C9CE5B142A0172CF008E198C /* WebView.swift in Sources */,
Expand Down
100 changes: 100 additions & 0 deletions Nos/Assets/Localization/Localizable.xcstrings
Original file line number Diff line number Diff line change
Expand Up @@ -4766,6 +4766,17 @@
}
}
},
"deleteList" : {
"extractionState" : "manual",
"localizations" : {
"en" : {
"stringUnit" : {
"state" : "translated",
"value" : "Delete List"
}
}
}
},
"deleteMyAccount" : {
"extractionState" : "manual",
"localizations" : {
Expand Down Expand Up @@ -5833,6 +5844,17 @@
}
}
},
"editListInfo" : {
"extractionState" : "manual",
"localizations" : {
"en" : {
"stringUnit" : {
"state" : "translated",
"value" : "Edit List Info"
}
}
}
},
"editProfile" : {
"extractionState" : "manual",
"localizations" : {
Expand Down Expand Up @@ -10434,6 +10456,17 @@
}
}
},
"listsDescription" : {
"extractionState" : "manual",
"localizations" : {
"en" : {
"stringUnit" : {
"state" : "translated",
"value" : "Add your favorite users to public lists and pin them to your home feed"
}
}
}
},
"loading" : {
"extractionState" : "manual",
"localizations" : {
Expand Down Expand Up @@ -10909,6 +10942,28 @@
}
}
},
"manageUsers" : {
"extractionState" : "manual",
"localizations" : {
"en" : {
"stringUnit" : {
"state" : "translated",
"value" : "Manage Users"
}
}
}
},
"manageYourLists" : {
"extractionState" : "manual",
"localizations" : {
"en" : {
"stringUnit" : {
"state" : "translated",
"value" : "Manage Your Lists"
}
}
}
},
"mention" : {
"extractionState" : "manual",
"localizations" : {
Expand Down Expand Up @@ -12259,6 +12314,17 @@
}
}
},
"noDescription" : {
"extractionState" : "manual",
"localizations" : {
"en" : {
"stringUnit" : {
"state" : "translated",
"value" : "No Description"
}
}
}
},
"noEvents" : {
"extractionState" : "manual",
"localizations" : {
Expand Down Expand Up @@ -20190,6 +20256,29 @@
}
}
},
"xUsers" : {
"extractionState" : "manual",
"localizations" : {
"en" : {
"variations" : {
"plural" : {
"one" : {
"stringUnit" : {
"state" : "translated",
"value" : "%1$lld user"
}
},
"other" : {
"stringUnit" : {
"state" : "translated",
"value" : "%1$lld users"
}
}
}
}
}
}
},
"yes" : {
"extractionState" : "manual",
"localizations" : {
Expand Down Expand Up @@ -20368,6 +20457,17 @@
}
}
},
"yourLists" : {
"extractionState" : "manual",
"localizations" : {
"en" : {
"stringUnit" : {
"state" : "translated",
"value" : "Your Lists"
}
}
}
},
"yourProfile" : {
"extractionState" : "manual",
"localizations" : {
Expand Down
12 changes: 2 additions & 10 deletions Nos/Controller/FeedController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import SwiftUI
private(set) var listRowItems: [FeedToggleRow.Item] = []
private(set) var relayRowItems: [FeedToggleRow.Item] = []

private var lists: [AuthorList] = [] {
private(set) var lists: [AuthorList] = [] {
didSet {
updateEnabledSources()
}
Expand All @@ -38,16 +38,8 @@ import SwiftUI
}

@ObservationIgnored private lazy var listsPublisher = {
let request = NSFetchRequest<AuthorList>(entityName: "AuthorList")
request.sortDescriptors = [NSSortDescriptor(keyPath: \Event.createdAt, ascending: false)]
request.predicate = NSPredicate(
format: "kind = %i AND author = %@ AND title != nil",
EventKind.followSet.rawValue,
author
)

let listWatcher = NSFetchedResultsController(
fetchRequest: request,
fetchRequest: AuthorList.authorLists(ownedBy: author),
managedObjectContext: persistenceController.viewContext,
sectionNameKeyPath: nil,
cacheName: "FeedController.listWatcher"
Expand Down
11 changes: 11 additions & 0 deletions Nos/Models/CoreData/AuthorList+CoreDataClass.swift
Original file line number Diff line number Diff line change
Expand Up @@ -96,4 +96,15 @@ public class AuthorList: Event {
var allAuthors: Set<Author> {
authors.union(privateAuthors)
}

static func authorLists(ownedBy owner: Author) -> NSFetchRequest<AuthorList> {
let request = NSFetchRequest<AuthorList>(entityName: "AuthorList")
request.sortDescriptors = [NSSortDescriptor(keyPath: \Event.createdAt, ascending: false)]
request.predicate = NSPredicate(
format: "kind = %i AND author = %@ AND title != nil AND deletedOn.@count = 0",
EventKind.followSet.rawValue,
owner
)
return request
}
}
33 changes: 23 additions & 10 deletions Nos/Views/Home/FeedCustomizerView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ struct FeedCustomizerView: View {

@Environment(FeedController.self) var feedController
let author: Author
@Binding var shouldNavigateToLists: Bool
@Binding var shouldNavigateToRelays: Bool

@AppStorage("selectedFeedTogglesTab") private var selectedTab = FeedTab.lists
Expand All @@ -53,18 +54,30 @@ struct FeedCustomizerView: View {
items: feedController.listRowItems,
footer: {
Group {
Text("Create your own lists on ") +
Text("Listr ")
.foregroundStyle(Color.accent) +
Text(Image(systemName: "link"))
.foregroundStyle(Color.accent)
}
.padding()
.onTapGesture {
if let url = URL(string: "https://listr.lol/feed") {
UIApplication.shared.open(url)
if feedController.listRowItems.isEmpty {
Group {
Text("Create your own lists on ") +
Text("Listr ")
.foregroundStyle(Color.accent) +
Text(Image(systemName: "link"))
.foregroundStyle(Color.accent)
}
.onTapGesture {
if let url = URL(string: "https://listr.lol/feed") {
UIApplication.shared.open(url)
}
}
} else {
SecondaryActionButton(
"manageYourLists",
font: .clarity(.semibold, textStyle: .footnote),
image: Image(systemName: "slider.horizontal.3")
) {
shouldNavigateToLists = true
}
}
}
.padding()
},
noContent: {
Text("noLists")
Expand Down
21 changes: 20 additions & 1 deletion Nos/Views/Home/HomeFeedView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ struct HomeFeedView: View {
/// to get some data from relay. The amount of time is defined in `staticLoadTime`.
@State private var showTimedLoadingIndicator = true

@State private var shouldNavigateToListsOnAppear = false
@State private var shouldNavigateToRelaysOnAppear = false

/// The amount of time (in seconds) the loading indicator will be shown when showTimedLoadingIndicator is set to
Expand Down Expand Up @@ -132,7 +133,11 @@ struct HomeFeedView: View {
.transition(.opacity)

VStack {
FeedCustomizerView(author: user, shouldNavigateToRelays: $shouldNavigateToRelaysOnAppear)
FeedCustomizerView(
author: user,
shouldNavigateToLists: $shouldNavigateToListsOnAppear,
shouldNavigateToRelays: $shouldNavigateToRelaysOnAppear
)
Spacer()
}
.transition(.move(edge: .top))
Expand Down Expand Up @@ -189,6 +194,17 @@ struct HomeFeedView: View {
GoToFeedTip.viewedFeed.sendDonation()
}
}
.onChange(of: shouldNavigateToListsOnAppear) {
if shouldNavigateToListsOnAppear {
showFeedSelector = false

DispatchQueue.main.asyncAfter(deadline: .now() + .milliseconds(300)) {
router.push(ListsDestination(author: user))
}

shouldNavigateToListsOnAppear = false
}
}
.onChange(of: shouldNavigateToRelaysOnAppear) {
if shouldNavigateToRelaysOnAppear {
showFeedSelector = false
Expand All @@ -200,6 +216,9 @@ struct HomeFeedView: View {
shouldNavigateToRelaysOnAppear = false
}
}
.navigationDestination(for: ListsDestination.self) { destination in
AuthorListsView(author: destination.author)
}
.navigationDestination(for: RelaysDestination.self) { destination in
RelayView(author: destination.author)
}
Expand Down
Loading
Loading