From 02b5ed6917f51ce977f04208ca66dab076a27b75 Mon Sep 17 00:00:00 2001 From: Jurrer <72750942+Jurrer@users.noreply.github.com> Date: Mon, 2 Jun 2025 16:41:48 +0200 Subject: [PATCH] Add Ignored tab to Channel page (#927) * Add Ignored tab to Channel page * fix for Ignored button action * use ignored parameter as bool --------- Co-authored-by: Simon --- backend/channel/serializers.py | 1 + backend/channel/src/nav.py | 19 +++++++++++++++++++ frontend/src/api/loader/loadChannelNav.ts | 1 + .../src/configuration/routes/RouteList.ts | 3 ++- frontend/src/pages/ChannelBase.tsx | 7 ++++++- frontend/src/pages/Download.tsx | 7 ++++++- 6 files changed, 35 insertions(+), 3 deletions(-) diff --git a/backend/channel/serializers.py b/backend/channel/serializers.py index 568e4eed..7b2a9ec8 100644 --- a/backend/channel/serializers.py +++ b/backend/channel/serializers.py @@ -90,6 +90,7 @@ class ChannelNavSerializer(serializers.Serializer): """serialize channel navigation""" has_pending = serializers.BooleanField() + has_ignored = serializers.BooleanField() has_playlists = serializers.BooleanField() has_videos = serializers.BooleanField() has_streams = serializers.BooleanField() diff --git a/backend/channel/src/nav.py b/backend/channel/src/nav.py index 6ff3e047..44b15f8b 100644 --- a/backend/channel/src/nav.py +++ b/backend/channel/src/nav.py @@ -13,6 +13,7 @@ class ChannelNav: """build nav items""" nav = { "has_pending": self._get_has_pending(), + "has_ignored": self._get_has_ignored(), "has_playlists": self._get_has_playlists(), } nav.update(self._get_vid_types()) @@ -63,6 +64,24 @@ class ChannelNav: return bool(response["hits"]["hits"]) + def _get_has_ignored(self): + """Check if there are ignored videos in the download queue""" + data = { + "size": 1, + "query": { + "bool": { + "must": [ + {"term": {"status": {"value": "ignore"}}}, + {"term": {"channel_id": {"value": self.channel_id}}}, + ] + } + }, + "_source": False, + } + response, _ = ElasticWrap("ta_download/_search").get(data=data) + + return bool(response["hits"]["hits"]) + def _get_has_playlists(self): """check if channel has playlists""" path = "ta_playlist/_search" diff --git a/frontend/src/api/loader/loadChannelNav.ts b/frontend/src/api/loader/loadChannelNav.ts index 26c97c10..361e0d38 100644 --- a/frontend/src/api/loader/loadChannelNav.ts +++ b/frontend/src/api/loader/loadChannelNav.ts @@ -5,6 +5,7 @@ export type ChannelNavResponseType = { has_shorts: boolean; has_playlists: boolean; has_pending: boolean; + has_ignored: boolean; }; const loadChannelNav = async (youtubeChannelId: string) => { diff --git a/frontend/src/configuration/routes/RouteList.ts b/frontend/src/configuration/routes/RouteList.ts index 41f36558..df1513a5 100644 --- a/frontend/src/configuration/routes/RouteList.ts +++ b/frontend/src/configuration/routes/RouteList.ts @@ -10,7 +10,8 @@ const Routes = { Playlists: '/playlist/', Playlist: (id: string) => `/playlist/${id}`, Downloads: '/downloads/', - DownloadsByChannelId: (channelId: string) => `/downloads/?channel=${channelId}`, + DownloadsByChannelId: (channelId: string) => `/downloads/?channel=${channelId}&ignored=false`, + IgnoredByChannelId: (channelId: string) => `/downloads/?channel=${channelId}&ignored=true`, Search: '/search/', SettingsDashboard: '/settings/', SettingsUser: '/settings/user/', diff --git a/frontend/src/pages/ChannelBase.tsx b/frontend/src/pages/ChannelBase.tsx index 05bf21af..aba6e579 100644 --- a/frontend/src/pages/ChannelBase.tsx +++ b/frontend/src/pages/ChannelBase.tsx @@ -27,7 +27,7 @@ const ChannelBase = () => { const { data: channelNavData } = channelNav ?? {}; const channel = channelResponseData; - const { has_streams, has_shorts, has_playlists, has_pending } = channelNavData || {}; + const { has_streams, has_shorts, has_playlists, has_pending, has_ignored } = channelNavData || {}; useEffect(() => { (async () => { @@ -84,6 +84,11 @@ const ChannelBase = () => {

Downloads

)} + {has_ignored && isAdmin && ( + +

Ignored

+ + )} { const { currentPage, setCurrentPage } = useOutletContext() as OutletContextType; const channelFilterFromUrl = searchParams.get('channel'); + const ignoredOnlyParam = searchParams.get('ignored'); const [refresh, setRefresh] = useState(false); const [showHiddenForm, setShowHiddenForm] = useState(false); @@ -82,7 +83,8 @@ const Download = () => { const view = userConfig.view_style_downloads; const gridItems = userConfig.grid_items; - const showIgnored = userConfig.show_ignored_only; + const showIgnored = + ignoredOnlyParam !== null ? ignoredOnlyParam === 'true' : userConfig.show_ignored_only; const isGridView = view === ViewStyles.grid; const gridView = isGridView ? `boxed-${gridItems}` : ''; const gridViewGrid = isGridView ? `grid-${gridItems}` : ''; @@ -234,6 +236,9 @@ const Download = () => { id="showIgnored" onChange={() => { handleUserConfigUpdate({ show_ignored_only: !showIgnored }); + const newParams = new URLSearchParams(searchParams.toString()); + newParams.set('ignored', String(!showIgnored)); + setSearchParams(newParams); setRefresh(true); }} type="checkbox"