Properly filter available sources
- Make searching case insensitive - Fix catalog title not hiding when searching an installed source name
This commit is contained in:
parent
ff35ab7cfa
commit
dc8bba3cd8
1 changed files with 24 additions and 21 deletions
|
|
@ -73,26 +73,10 @@ struct SourcesView: View {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if !filteredAvailableSources.isEmpty, sourceManager.availableSources.contains(where: { availableSource in
|
if !filteredAvailableSources.isEmpty {
|
||||||
!sources.contains(
|
|
||||||
where: {
|
|
||||||
availableSource.name == $0.name &&
|
|
||||||
availableSource.listId == $0.listId &&
|
|
||||||
availableSource.author == $0.author
|
|
||||||
}
|
|
||||||
)
|
|
||||||
}) {
|
|
||||||
Section(header: InlineHeader("Catalog")) {
|
Section(header: InlineHeader("Catalog")) {
|
||||||
ForEach(filteredAvailableSources, id: \.self) { availableSource in
|
ForEach(filteredAvailableSources, id: \.self) { availableSource in
|
||||||
if !sources.contains(
|
SourceCatalogButtonView(availableSource: availableSource)
|
||||||
where: {
|
|
||||||
availableSource.name == $0.name &&
|
|
||||||
availableSource.listId == $0.listId &&
|
|
||||||
availableSource.author == $0.author
|
|
||||||
}
|
|
||||||
) {
|
|
||||||
SourceCatalogButtonView(availableSource: availableSource)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -109,7 +93,15 @@ struct SourcesView: View {
|
||||||
filteredUpdatedSources = updatedSources
|
filteredUpdatedSources = updatedSources
|
||||||
viewTask = Task {
|
viewTask = Task {
|
||||||
await sourceManager.fetchSourcesFromUrl()
|
await sourceManager.fetchSourcesFromUrl()
|
||||||
filteredAvailableSources = sourceManager.availableSources
|
filteredAvailableSources = sourceManager.availableSources.filter { availableSource in
|
||||||
|
!sources.contains(
|
||||||
|
where: {
|
||||||
|
availableSource.name == $0.name &&
|
||||||
|
availableSource.listId == $0.listId &&
|
||||||
|
availableSource.author == $0.author
|
||||||
|
}
|
||||||
|
)
|
||||||
|
}
|
||||||
checkedForSources = true
|
checkedForSources = true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -125,8 +117,19 @@ struct SourcesView: View {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
.onChange(of: searchText) { _ in
|
.onChange(of: searchText) { _ in
|
||||||
filteredAvailableSources = sourceManager.availableSources.filter { searchText.isEmpty ? true : $0.name.contains(searchText) }
|
filteredAvailableSources = sourceManager.availableSources.filter { availableSource in
|
||||||
filteredUpdatedSources = updatedSources.filter { searchText.isEmpty ? true : $0.name.contains(searchText) }
|
searchText.isEmpty ? true : availableSource.name.lowercased().contains(searchText.lowercased())
|
||||||
|
&& !sources.contains(
|
||||||
|
where: {
|
||||||
|
availableSource.name == $0.name &&
|
||||||
|
availableSource.listId == $0.listId &&
|
||||||
|
availableSource.author == $0.author
|
||||||
|
}
|
||||||
|
)
|
||||||
|
}
|
||||||
|
filteredUpdatedSources = updatedSources.filter {
|
||||||
|
searchText.isEmpty ? true : $0.name.lowercased().contains(searchText.lowercased())
|
||||||
|
}
|
||||||
if #available(iOS 15.0, *) {
|
if #available(iOS 15.0, *) {
|
||||||
if searchText.isEmpty {
|
if searchText.isEmpty {
|
||||||
sources.nsPredicate = nil
|
sources.nsPredicate = nil
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue