Improve global search

Add options to show only searches for
- pinned sources
- all sources
- sources with results
This commit is contained in:
schroda
2025-05-18 00:59:01 +02:00
parent 1e1489df75
commit 7885bcda98
6 changed files with 117 additions and 22 deletions

View File

@@ -80,7 +80,8 @@ export class Sources {
showNsfw,
languages,
keepLocalSource,
}: { showNsfw?: boolean; languages?: string[]; keepLocalSource?: boolean } = {},
pinned,
}: { showNsfw?: boolean; languages?: string[]; keepLocalSource?: boolean; pinned?: boolean } = {},
): Source[] {
const normalizedLanguages = toComparableLanguages(toUniqueLanguageCodes(languages ?? []));
@@ -97,6 +98,13 @@ export class Sources {
!languages ||
normalizedLanguages.includes(toComparableLanguage(Sources.getLanguage(source))) ||
(keepLocalSource && Sources.isLocalSource(source)),
)
.filter(
(source) =>
pinned === undefined ||
!pinned ||
getSourceMetadata(source).isPinned ||
(keepLocalSource && Sources.isLocalSource(source)),
);
}