feat(blacklist): hide blacklisted items from discover pages for admins (#1601)
* feat(blacklist): add 'Hide Blacklisted Items' setting to general settings and UI * feat(migration): add HideBlacklistedItems migration for PostgreSQL and SQLite * feat(settings): add hideBlacklisted option to application settings * feat(settings): add tooltips for hideAvailable and hideBlacklisted options in settings * chore(migration): remove HideBlacklistedItems migration files for PostgreSQL and SQLite * docs(settings): clarify description of 'Hide Blacklisted Items' setting to specify it affects all users * docs(settings): update tooltip and description for 'Hide Blacklisted Items' to clarify it applies to all users, including administrators * docs(settings): clarify 'Hide Blacklisted Items' functionality to specify it applies only to administrators with the "Manage Blacklist" permission * fix(hooks): update permission check for 'Hide Blacklisted Items' to include 'Manage Blacklist' * fix(settings): update tooltip for 'Hide Blacklisted Items' to clarify it applies to all users with the "Manage Blacklist" permission * feat(settings): add experimental badge to settings tooltip for 'Hide Available' option
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
import { MediaStatus } from '@server/constants/media';
|
||||
import useSWRInfinite from 'swr/infinite';
|
||||
import useSettings from './useSettings';
|
||||
import { Permission, useUser } from './useUser';
|
||||
|
||||
export interface BaseSearchResult<T> {
|
||||
page: number;
|
||||
@@ -53,9 +54,10 @@ const useDiscover = <
|
||||
>(
|
||||
endpoint: string,
|
||||
options?: O,
|
||||
{ hideAvailable = true } = {}
|
||||
{ hideAvailable = true, hideBlacklisted = true } = {}
|
||||
): DiscoverResult<T, S> => {
|
||||
const settings = useSettings();
|
||||
const { hasPermission } = useUser();
|
||||
const { data, error, size, setSize, isValidating, mutate } = useSWRInfinite<
|
||||
BaseSearchResult<T> & S
|
||||
>(
|
||||
@@ -120,6 +122,18 @@ const useDiscover = <
|
||||
);
|
||||
}
|
||||
|
||||
if (
|
||||
settings.currentSettings.hideBlacklisted &&
|
||||
hideBlacklisted &&
|
||||
hasPermission(Permission.MANAGE_BLACKLIST)
|
||||
) {
|
||||
titles = titles.filter(
|
||||
(i) =>
|
||||
(i.mediaType === 'movie' || i.mediaType === 'tv') &&
|
||||
i.mediaInfo?.status !== MediaStatus.BLACKLISTED
|
||||
);
|
||||
}
|
||||
|
||||
const isEmpty = !isLoadingInitialData && titles?.length === 0;
|
||||
const isReachingEnd =
|
||||
isEmpty ||
|
||||
|
||||
Reference in New Issue
Block a user