Skip to content

Commit

Permalink
Move searching into ArtistList / VenueList (#805)
Browse files Browse the repository at this point in the history
- #794 broke when there were "no items" in that it was confused if there
were none by location filter or if by search not finding anything
  • Loading branch information
bolsinga committed Jun 8, 2024
1 parent dab56e1 commit 969776b
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 22 deletions.
28 changes: 12 additions & 16 deletions Sources/Site/Music/UI/ArchiveCategoryDetail.swift
Original file line number Diff line number Diff line change
Expand Up @@ -37,23 +37,19 @@ struct ArchiveCategoryDetail: View {
ShowYearList(decadesMap: decadesMap)
.locationFilter(nearbyModel, filteredDataIsEmpty: decadesMap.isEmpty)
case .venues:
let venueDigests = model.filteredVenueDigests(nearbyModel).names(
filteredBy: venueSearchString)
VenueList(venueDigests: venueDigests, sectioner: vault.sectioner, sort: $venueSort)
.archiveSearchable(
searchPrompt: String(localized: "Venue Names", bundle: .module),
searchString: $venueSearchString, contentsEmpty: venueDigests.isEmpty
)
.locationFilter(nearbyModel, filteredDataIsEmpty: venueDigests.isEmpty)
let venueDigests = model.filteredVenueDigests(nearbyModel)
VenueList(
venueDigests: venueDigests, sectioner: vault.sectioner, sort: $venueSort,
searchString: $venueSearchString
)
.locationFilter(nearbyModel, filteredDataIsEmpty: venueDigests.isEmpty)
case .artists:
let artistDigests = model.filteredArtistDigests(nearbyModel).names(
filteredBy: artistSearchString)
ArtistList(artistDigests: artistDigests, sectioner: vault.sectioner, sort: $artistSort)
.archiveSearchable(
searchPrompt: String(localized: "Artist Names", bundle: .module),
searchString: $artistSearchString, contentsEmpty: artistDigests.isEmpty
)
.locationFilter(nearbyModel, filteredDataIsEmpty: artistDigests.isEmpty)
let artistDigests = model.filteredArtistDigests(nearbyModel)
ArtistList(
artistDigests: artistDigests, sectioner: vault.sectioner, sort: $artistSort,
searchString: $artistSearchString
)
.locationFilter(nearbyModel, filteredDataIsEmpty: artistDigests.isEmpty)
}
}
.shareCategory(category, url: url)
Expand Down
13 changes: 10 additions & 3 deletions Sources/Site/Music/UI/ArtistList.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,21 +11,28 @@ struct ArtistList: View {
let artistDigests: [ArtistDigest]
let sectioner: LibrarySectioner
@Binding var sort: RankingSort
@Binding var searchString: String

var body: some View {
let digests = artistDigests.names(filteredBy: searchString)
RankableSortList(
items: artistDigests, sectioner: sectioner,
items: digests, sectioner: sectioner,
title: String(localized: "Artists", bundle: .module),
associatedRankName: String(localized: "Sort By Venue Count", bundle: .module),
associatedRankSectionHeader: { $0.venuesCountView }, sort: $sort)
associatedRankSectionHeader: { $0.venuesCountView }, sort: $sort
)
.archiveSearchable(
searchPrompt: String(localized: "Artist Names", bundle: .module),
searchString: $searchString, contentsEmpty: digests.isEmpty
)
}
}

#Preview {
NavigationStack {
ArtistList(
artistDigests: vaultPreviewData.artistDigests, sectioner: vaultPreviewData.sectioner,
sort: .constant(.alphabetical)
sort: .constant(.alphabetical), searchString: .constant("")
)
.musicDestinations(vaultPreviewData)
}
Expand Down
13 changes: 10 additions & 3 deletions Sources/Site/Music/UI/VenueList.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,21 +11,28 @@ struct VenueList: View {
let venueDigests: [VenueDigest]
let sectioner: LibrarySectioner
@Binding var sort: RankingSort
@Binding var searchString: String

var body: some View {
let digests = venueDigests.names(filteredBy: searchString)
RankableSortList(
items: venueDigests, sectioner: sectioner,
items: digests, sectioner: sectioner,
title: String(localized: "Venues", bundle: .module),
associatedRankName: String(localized: "Sort By Artist Count", bundle: .module),
associatedRankSectionHeader: { $0.artistsCountView }, sort: $sort)
associatedRankSectionHeader: { $0.artistsCountView }, sort: $sort
)
.archiveSearchable(
searchPrompt: String(localized: "Venue Names", bundle: .module),
searchString: $searchString, contentsEmpty: digests.isEmpty
)
}
}

#Preview {
NavigationStack {
VenueList(
venueDigests: vaultPreviewData.venueDigests, sectioner: vaultPreviewData.sectioner,
sort: .constant(.alphabetical)
sort: .constant(.alphabetical), searchString: .constant("")
)
.musicDestinations(vaultPreviewData)
}
Expand Down

0 comments on commit 969776b

Please sign in to comment.