From 19d25f37c6dcb49aedd76aa02b89d0e734dbd26f Mon Sep 17 00:00:00 2001 From: SergeantPanda Date: Fri, 16 Jan 2026 14:03:48 -0600 Subject: [PATCH] Bug Fix: Fixed VOD logo cleanup button count: The "Cleanup Unused" button now displays the total count of all unused logos across all pages instead of only counting unused logos on the current page. --- CHANGELOG.md | 1 + .../src/components/tables/VODLogosTable.jsx | 30 ++++++++++++++----- frontend/src/store/vodLogos.jsx | 15 ++++++++++ 3 files changed, 39 insertions(+), 7 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7f273a20..c636e281 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -20,6 +20,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Fixed +- Fixed VOD logo cleanup button count: The "Cleanup Unused" button now displays the total count of all unused logos across all pages instead of only counting unused logos on the current page. - Fixed VOD refresh failures when logos are deleted: Changed logo comparisons to use `logo_id` (raw FK integer) instead of `logo` (related object) to avoid Django's lazy loading, which triggers a database fetch that fails if the referenced logo no longer exists. Also improved orphaned logo detection to properly clear stale references when logo URLs exist but logos are missing from the database. - Fixed channel profile filtering to properly restrict content based on assigned channel profiles for all non-admin users (user_level < 10) instead of only streamers (user_level == 0). This corrects the XtreamCodes API endpoints (`get_live_categories` and `get_live_streams`) along with M3U and EPG generation, ensuring standard users (level 1) are properly restricted by their assigned channel profiles. Previously, "Standard" users with channel profiles assigned would see all channels instead of only those in their assigned profiles. - Fixed NumPy baseline detection in Docker entrypoint. Now calls `numpy.show_config()` directly with case-insensitive grep instead of incorrectly wrapping the output. diff --git a/frontend/src/components/tables/VODLogosTable.jsx b/frontend/src/components/tables/VODLogosTable.jsx index 75b322f5..b5529a57 100644 --- a/frontend/src/components/tables/VODLogosTable.jsx +++ b/frontend/src/components/tables/VODLogosTable.jsx @@ -64,6 +64,7 @@ export default function VODLogosTable() { deleteVODLogo, deleteVODLogos, cleanupUnusedVODLogos, + getUnusedLogosCount, } = useVODLogosStore(); const [currentPage, setCurrentPage] = useState(1); @@ -77,14 +78,9 @@ export default function VODLogosTable() { const [deleting, setDeleting] = useState(false); const [paginationString, setPaginationString] = useState(''); const [isCleaningUp, setIsCleaningUp] = useState(false); + const [unusedLogosCount, setUnusedLogosCount] = useState(0); + const [loadingUnusedCount, setLoadingUnusedCount] = useState(false); const tableRef = React.useRef(null); - - // Calculate unused logos count - const unusedLogosCount = useMemo(() => { - return logos.filter( - (logo) => logo.movie_count === 0 && logo.series_count === 0 - ).length; - }, [logos]); useEffect(() => { fetchVODLogos({ page: currentPage, @@ -94,6 +90,23 @@ export default function VODLogosTable() { }); }, [currentPage, pageSize, nameFilter, usageFilter, fetchVODLogos]); + // Fetch the total count of unused logos + useEffect(() => { + const fetchUnusedCount = async () => { + setLoadingUnusedCount(true); + try { + const count = await getUnusedLogosCount(); + setUnusedLogosCount(count); + } catch (error) { + console.error('Failed to fetch unused logos count:', error); + } finally { + setLoadingUnusedCount(false); + } + }; + + fetchUnusedCount(); + }, [getUnusedLogosCount]); + const handleSelectAll = useCallback( (checked) => { if (checked) { @@ -185,6 +198,9 @@ export default function VODLogosTable() { message: `Cleaned up ${result.deleted_count} unused VOD logos`, color: 'green', }); + // Refresh the unused count after cleanup + const newCount = await getUnusedLogosCount(); + setUnusedLogosCount(newCount); } catch (error) { notifications.show({ title: 'Error', diff --git a/frontend/src/store/vodLogos.jsx b/frontend/src/store/vodLogos.jsx index 4df2dd17..70c81293 100644 --- a/frontend/src/store/vodLogos.jsx +++ b/frontend/src/store/vodLogos.jsx @@ -116,6 +116,21 @@ const useVODLogosStore = create((set) => ({ } }, + getUnusedLogosCount: async () => { + try { + const response = await api.getVODLogos({ + used: 'false', + page_size: 1, // Fetch only 1 item to minimize data transfer + }); + + // Return the count from the paginated response + return response.count || 0; + } catch (error) { + console.error('Failed to fetch unused logos count:', error); + throw error; + } + }, + clearVODLogos: () => { set({ vodLogos: {},