From 7d264566f2ba3e4d30f150d0426edb485dc30172 Mon Sep 17 00:00:00 2001 From: natyusha Date: Sun, 10 Dec 2023 02:30:40 -0500 Subject: [PATCH] Add includeRestricted to RecommendedAnime Dashboard Panel (#712) --- src/core/rtkQuery/splitV3Api/seriesApi.ts | 2 +- src/pages/dashboard/panels/RecommendedAnime.tsx | 15 +++++++++++++-- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/src/core/rtkQuery/splitV3Api/seriesApi.ts b/src/core/rtkQuery/splitV3Api/seriesApi.ts index d45ef3fa7..90666652d 100644 --- a/src/core/rtkQuery/splitV3Api/seriesApi.ts +++ b/src/core/rtkQuery/splitV3Api/seriesApi.ts @@ -149,7 +149,7 @@ const seriesApi = splitV3Api.injectEndpoints({ }), // Gets anidb recommendation for the user - getAniDBRecommendedAnime: build.query({ + getAniDBRecommendedAnime: build.query({ query: params => ({ url: 'Series/AniDB/RecommendedForYou', params: { ...params, showAll: true } }), transformResponse: (response: ListResultType) => response.List, }), diff --git a/src/pages/dashboard/panels/RecommendedAnime.tsx b/src/pages/dashboard/panels/RecommendedAnime.tsx index d3f93befd..a6c0be21e 100644 --- a/src/pages/dashboard/panels/RecommendedAnime.tsx +++ b/src/pages/dashboard/panels/RecommendedAnime.tsx @@ -1,4 +1,4 @@ -import React from 'react'; +import React, { useMemo } from 'react'; import { useSelector } from 'react-redux'; import { mdiEyeArrowRightOutline } from '@mdi/js'; import { Icon } from '@mdi/react'; @@ -6,6 +6,8 @@ import { Icon } from '@mdi/react'; import BackgroundImagePlaceholderDiv from '@/components/BackgroundImagePlaceholderDiv'; import ShokoPanel from '@/components/Panels/ShokoPanel'; import { useGetAniDBRecommendedAnimeQuery } from '@/core/rtkQuery/splitV3Api/seriesApi'; +import { useGetSettingsQuery } from '@/core/rtkQuery/splitV3Api/settingsApi'; +import { initialSettings } from '@/pages/settings/SettingsPage'; import type { RootState } from '@/core/store'; import type { SeriesAniDBType } from '@/core/types/api/series'; @@ -13,7 +15,16 @@ import type { SeriesAniDBType } from '@/core/types/api/series'; const RecommendedAnime = () => { const layoutEditMode = useSelector((state: RootState) => state.mainpage.layoutEditMode); - const items = useGetAniDBRecommendedAnimeQuery({ pageSize: 20 }); + const settingsQuery = useGetSettingsQuery(); + const { hideR18Content } = useMemo( + () => settingsQuery.data?.WebUI_Settings.dashboard ?? initialSettings.WebUI_Settings.dashboard, + [settingsQuery], + ); + + const items = useGetAniDBRecommendedAnimeQuery({ + includeRestricted: !hideR18Content, + pageSize: 20, + }); const renderItem = (series: SeriesAniDBType, matches: number) => (