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

fixed: tapping a user on a list causes a crash #172 #1746

Merged
merged 2 commits into from
Jan 31, 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 @@ -20,6 +20,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Added analytics for feed source selection and lists. [#129](https://github.com/verse-pbc/issues/issues/129)
- Fixed: while searching for users to add to a list, NIP-05 searches dismiss the view. [#165](https://github.com/verse-pbc/issues/issues/165)
- Fixed a crash when processing a malformed delete (kind 5) event. [#170](https://github.com/verse-pbc/issues/issues/170)
- Fixed: tapping a user on a list causes a crash. [#172](https://github.com/verse-pbc/issues/issues/172)

### 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
1 change: 1 addition & 0 deletions Nos/Models/NosNavigationDestination.swift
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import Foundation
enum NosNavigationDestination: Hashable {
case note(NoteIdentifiable)
case author(RawAuthorID?)
case list(AuthorList)
case url(URL)
case replyTo(RawEventID?)
}
Expand Down
4 changes: 4 additions & 0 deletions Nos/Router.swift
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,10 @@ import Dependencies
}
}

func pushList(_ list: AuthorList) {
push(.list(list))
}

/// Pushes a web view for the given url.
func push(_ url: URL) {
push(.url(url))
Expand Down
2 changes: 2 additions & 0 deletions Nos/Views/Components/NosNavigationStack.swift
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ struct NosNavigationStack<Content: View>: View {
AuthorObservationView(authorID: authorID) { author in
ProfileView(author: author)
}
case .list(let list):
AuthorListDetailView(list: list)
case .url(let url):
URLView(url: url)
case .replyTo(let eventID):
Expand Down
35 changes: 18 additions & 17 deletions Nos/Views/Lists/AuthorListDetailView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -42,27 +42,28 @@ struct AuthorListDetailView: View {

LazyVStack {
ForEach(list.allAuthors.sorted(by: { ($0.displayName ?? "") < ($1.displayName ?? "") })) { author in
NavigationLink {
ProfileView(author: author)
} label: {
AuthorObservationView(authorID: author.hexadecimalPublicKey) { author in
AuthorCard(author: author, avatarOverlayView: { EmptyView() })
.padding(.horizontal, 13)
.padding(.top, 5)
.readabilityPadding()
.task {
subscriptions[author.id] =
await relayService.requestMetadata(
for: author.hexadecimalPublicKey,
since: author.lastUpdatedMetadata
)
}
.disabled(true) // skips the onTap action in AuthorCard
AuthorObservationView(authorID: author.hexadecimalPublicKey) { author in
AuthorCard(
author: author,
avatarOverlayView: { EmptyView() },
onTap: {
router.push(author)
}
)
.padding(.horizontal, 13)
.padding(.top, 5)
.readabilityPadding()
.task {
subscriptions[author.id] =
await relayService.requestMetadata(
for: author.hexadecimalPublicKey,
since: author.lastUpdatedMetadata
)
}
}
}
.padding(.vertical, 12)
}
.padding(.vertical, 12)
}
.nosNavigationBar("")
.background(Color.appBg)
Expand Down
34 changes: 17 additions & 17 deletions Nos/Views/Lists/AuthorListsView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ struct ListsDestination: Hashable {
/// A view that displays a list of an ``Author``'s ``AuthorList``s.
struct AuthorListsView: View {

@EnvironmentObject private var router: Router
let author: Author

@FetchRequest var lists: FetchedResults<AuthorList>
Expand Down Expand Up @@ -41,25 +42,24 @@ struct AuthorListsView: View {
ScrollView {
VStack(spacing: 0) {
ForEach(lists) { list in
NavigationLink {
AuthorListDetailView(list: list)
} label: {
HStack {
VStack(alignment: .leading) {
Text(list.title ?? "")
.font(.body)

Text(list.rowDescription)
.foregroundStyle(Color.secondaryTxt)
.font(.footnote)
.lineLimit(1)
}
HStack {
VStack(alignment: .leading) {
Text(list.title ?? "")
.font(.body)

Spacer()
Text(list.rowDescription)
.foregroundStyle(Color.secondaryTxt)
.font(.footnote)
.lineLimit(1)
}
.padding(.leading, 16)
.padding(.vertical, 12)
.frame(minHeight: 50)

Spacer()
}
.padding(.leading, 16)
.padding(.vertical, 12)
.frame(minHeight: 50)
.onTapGesture {
router.pushList(list)
}

BeveledSeparator()
Expand Down