Add option to disable sources of an extension
This commit is contained in:
@@ -27,6 +27,7 @@ export type SavedSourceSearch = { query?: string; filters?: IPos[] };
|
||||
export interface ISourceMetadata {
|
||||
savedSearches?: Record<string, SavedSourceSearch>;
|
||||
isPinned: boolean;
|
||||
isEnabled: boolean;
|
||||
}
|
||||
|
||||
export type SourceFilters = GetSourceBrowseQuery['source']['filters'][number];
|
||||
|
||||
@@ -48,7 +48,13 @@ export function Sources({ tabsMenuHeight }: { tabsMenuHeight: number }) {
|
||||
} = requestManager.useGetSourceList({ notifyOnNetworkStatusChange: true });
|
||||
const sources = data?.sources.nodes;
|
||||
const filteredSources = useMemo(
|
||||
() => SourceService.filter(sources ?? [], { showNsfw, languages: shownLangs, keepLocalSource: true }),
|
||||
() =>
|
||||
SourceService.filter(sources ?? [], {
|
||||
showNsfw,
|
||||
languages: shownLangs,
|
||||
keepLocalSource: true,
|
||||
enabled: true,
|
||||
}),
|
||||
[sources, shownLangs],
|
||||
);
|
||||
const sourcesByLanguage = useMemo(() => {
|
||||
|
||||
@@ -23,6 +23,7 @@ import {
|
||||
const DEFAULT_SOURCE_METADATA: ISourceMetadata = {
|
||||
savedSearches: undefined,
|
||||
isPinned: false,
|
||||
isEnabled: true,
|
||||
};
|
||||
|
||||
const convertAppMetadataToGqlMetadata = (
|
||||
|
||||
@@ -81,7 +81,14 @@ export class Sources {
|
||||
languages,
|
||||
keepLocalSource,
|
||||
pinned,
|
||||
}: { showNsfw?: boolean; languages?: string[]; keepLocalSource?: boolean; pinned?: boolean } = {},
|
||||
enabled,
|
||||
}: {
|
||||
showNsfw?: boolean;
|
||||
languages?: string[];
|
||||
keepLocalSource?: boolean;
|
||||
pinned?: boolean;
|
||||
enabled?: boolean;
|
||||
} = {},
|
||||
): Source[] {
|
||||
const normalizedLanguages = toComparableLanguages(toUniqueLanguageCodes(languages ?? []));
|
||||
|
||||
@@ -105,6 +112,13 @@ export class Sources {
|
||||
!pinned ||
|
||||
getSourceMetadata(source).isPinned ||
|
||||
(keepLocalSource && Sources.isLocalSource(source)),
|
||||
)
|
||||
.filter(
|
||||
(source) =>
|
||||
enabled === undefined ||
|
||||
!enabled ||
|
||||
getSourceMetadata(source).isEnabled ||
|
||||
(keepLocalSource && Sources.isLocalSource(source)),
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user