From f03a5f13e8166c327f8229233ccdf9a46a4efcaf Mon Sep 17 00:00:00 2001 From: Psychotoxical <171614930+Psychotoxical@users.noreply.github.com> Date: Tue, 30 Jun 2026 19:52:29 +0200 Subject: [PATCH] refactor(cover): move cover-coupled hooks into cover/; drop deprecated usePlaybackCoverArt shim --- src/app/AppShell.tsx | 2 +- src/app/FpsOverlay.tsx | 2 +- src/app/MainApp.tsx | 2 +- src/{hooks => cover}/useCoverCacheEvictTick.ts | 0 src/{hooks => cover}/useCoverNavigationPriority.ts | 2 +- src/{hooks => cover}/useCoverPerfListener.ts | 4 ++-- src/{hooks => cover}/useLibraryCoverBackfill.ts | 10 +++++----- src/{hooks => cover}/useWarmGridCovers.ts | 4 ++-- src/features/artist/pages/ArtistDetail.tsx | 2 +- .../components/FullscreenPlayerStatic.tsx | 2 +- src/features/miniPlayer/components/MiniPlayer.tsx | 2 +- .../nowPlaying/components/MobilePlayerView.tsx | 2 +- src/features/sidebar/hooks/useSidebarPerfProbe.ts | 2 +- src/hooks/usePlaybackCoverArt.ts | 2 -- src/ui/VirtualCardGrid.tsx | 2 +- 15 files changed, 19 insertions(+), 21 deletions(-) rename src/{hooks => cover}/useCoverCacheEvictTick.ts (100%) rename src/{hooks => cover}/useCoverNavigationPriority.ts (94%) rename src/{hooks => cover}/useCoverPerfListener.ts (92%) rename src/{hooks => cover}/useLibraryCoverBackfill.ts (93%) rename src/{hooks => cover}/useWarmGridCovers.ts (94%) delete mode 100644 src/hooks/usePlaybackCoverArt.ts diff --git a/src/app/AppShell.tsx b/src/app/AppShell.tsx index 08fede40..e71265d7 100644 --- a/src/app/AppShell.tsx +++ b/src/app/AppShell.tsx @@ -48,7 +48,7 @@ import { useQueueResizer } from '@/features/queue'; import { useGlobalDndAndSelectionBlockers } from '@/lib/hooks/useGlobalDndAndSelectionBlockers'; import { useAppActivityTracking } from '../hooks/useAppActivityTracking'; import { useMainScrollingIndicator } from '../hooks/useMainScrollingIndicator'; -import { useCoverNavigationPriority } from '../hooks/useCoverNavigationPriority'; +import { useCoverNavigationPriority } from '@/cover/useCoverNavigationPriority'; import { useLiveSearchRouteScope } from '@/features/search'; import { useNowPlayingPrewarm } from '@/features/nowPlaying'; import { useOfflineAutoNav } from '@/features/offline'; diff --git a/src/app/FpsOverlay.tsx b/src/app/FpsOverlay.tsx index be853cbe..d9bf542c 100644 --- a/src/app/FpsOverlay.tsx +++ b/src/app/FpsOverlay.tsx @@ -31,7 +31,7 @@ import { usePerfOverlayMode, } from '@/utils/perf/perfOverlayMode'; import { useAnalysisPerfListener } from '@/hooks/useAnalysisPerfListener'; -import { useCoverPerfListener } from '@/hooks/useCoverPerfListener'; +import { useCoverPerfListener } from '@/cover/useCoverPerfListener'; import { getCoverCachedPerMinute, getCoverUiPerMinute } from '@/utils/perf/coverPerfStore'; const SAMPLE_MS = 500; diff --git a/src/app/MainApp.tsx b/src/app/MainApp.tsx index d2c92f67..e430631b 100644 --- a/src/app/MainApp.tsx +++ b/src/app/MainApp.tsx @@ -26,7 +26,7 @@ import { bootstrapAllIndexedServers } from '@/lib/library/librarySession'; import { hydrateQueueFromIndex } from '@/features/playback/store/queueRestore'; import { useLibraryAnalysisBackfill } from '@/lib/library/hooks/useLibraryAnalysisBackfill'; import { useCoverArtPrefetch } from '../cover/useCoverArtPrefetch'; -import { useLibraryCoverBackfill } from '../hooks/useLibraryCoverBackfill'; +import { useLibraryCoverBackfill } from '@/cover/useLibraryCoverBackfill'; import { useCoverRevalidateScheduler } from '../cover/useCoverRevalidateScheduler'; import { runCoverIdbUpgradeMigration } from '../utils/migrations/coverIdbUpgradeMigration'; import { useMigrationOrchestrator } from '../hooks/useMigrationOrchestrator'; diff --git a/src/hooks/useCoverCacheEvictTick.ts b/src/cover/useCoverCacheEvictTick.ts similarity index 100% rename from src/hooks/useCoverCacheEvictTick.ts rename to src/cover/useCoverCacheEvictTick.ts diff --git a/src/hooks/useCoverNavigationPriority.ts b/src/cover/useCoverNavigationPriority.ts similarity index 94% rename from src/hooks/useCoverNavigationPriority.ts rename to src/cover/useCoverNavigationPriority.ts index 92c1a0bb..a79cc09e 100644 --- a/src/hooks/useCoverNavigationPriority.ts +++ b/src/cover/useCoverNavigationPriority.ts @@ -3,7 +3,7 @@ import { useLocation } from 'react-router-dom'; import { coverTrafficBeginNavigation, coverTrafficEndNavigation, -} from '../cover/coverTraffic'; +} from '@/cover/coverTraffic'; /** * On route change: cancel queued peek/ensure/prefetch from the old page and diff --git a/src/hooks/useCoverPerfListener.ts b/src/cover/useCoverPerfListener.ts similarity index 92% rename from src/hooks/useCoverPerfListener.ts rename to src/cover/useCoverPerfListener.ts index f715119c..264c0889 100644 --- a/src/hooks/useCoverPerfListener.ts +++ b/src/cover/useCoverPerfListener.ts @@ -1,7 +1,7 @@ import { useEffect } from 'react'; import { listen } from '@tauri-apps/api/event'; -import { coverGetPipelineQueueStats } from '../api/coverCache'; -import { recordCoverProgress, recordCoverUiTotal } from '../utils/perf/coverPerfStore'; +import { coverGetPipelineQueueStats } from '@/api/coverCache'; +import { recordCoverProgress, recordCoverUiTotal } from '@/utils/perf/coverPerfStore'; /** How often to sample the backend's cumulative on-demand (UI) ensure count. */ const UI_POLL_MS = 1000; diff --git a/src/hooks/useLibraryCoverBackfill.ts b/src/cover/useLibraryCoverBackfill.ts similarity index 93% rename from src/hooks/useLibraryCoverBackfill.ts rename to src/cover/useLibraryCoverBackfill.ts index 8c8d3c10..ab20bfd5 100644 --- a/src/hooks/useLibraryCoverBackfill.ts +++ b/src/cover/useLibraryCoverBackfill.ts @@ -6,13 +6,13 @@ import { libraryCoverBackfillRunFullPass, libraryCoverBackfillSetBaseUrl, librarySqlServerId, -} from '../api/coverCache'; +} from '@/api/coverCache'; import { coverStrategyAllowsLibraryBackfill } from '@/lib/library/coverStrategy'; -import { useAuthStore } from '../store/authStore'; -import { useCoverStrategyStore } from '../store/coverStrategyStore'; +import { useAuthStore } from '@/store/authStore'; +import { useCoverStrategyStore } from '@/store/coverStrategyStore'; import { subscribeLibraryCoverBackfillWake } from '@/lib/library/coverBackfillWake'; -import { serverIndexKeyForProfile } from '../utils/server/serverIndexKey'; -import { subscribeConnectCache } from '../utils/server/serverEndpoint'; +import { serverIndexKeyForProfile } from '@/utils/server/serverIndexKey'; +import { subscribeConnectCache } from '@/utils/server/serverEndpoint'; /** * Library cover warm-up — configure session in Rust; full pass runs natively. diff --git a/src/hooks/useWarmGridCovers.ts b/src/cover/useWarmGridCovers.ts similarity index 94% rename from src/hooks/useWarmGridCovers.ts rename to src/cover/useWarmGridCovers.ts index d2990305..d7e92cdc 100644 --- a/src/hooks/useWarmGridCovers.ts +++ b/src/cover/useWarmGridCovers.ts @@ -3,8 +3,8 @@ import { collectAlbumCoverWarmItems, ensureAlbumCoverMisses, warmCoverDiskSrcBatch, -} from '../cover/warmDiskPeek'; -import type { CoverSurfaceKind } from '../cover/types'; +} from '@/cover/warmDiskPeek'; +import type { CoverSurfaceKind } from '@/cover/types'; const DEFAULT_LIMIT = 120; diff --git a/src/features/artist/pages/ArtistDetail.tsx b/src/features/artist/pages/ArtistDetail.tsx index 77d1866b..3b4475d9 100644 --- a/src/features/artist/pages/ArtistDetail.tsx +++ b/src/features/artist/pages/ArtistDetail.tsx @@ -34,7 +34,7 @@ import { usePerfProbeFlags } from '@/utils/perf/perfFlags'; import { albumGridWarmCovers, COVER_DENSE_GRID_MIN_CELL_CSS_PX, GRID_COVER_WARM_LIMIT } from '@/cover/layoutSizes'; import { artistDetailCoverWarmAlbums } from '@/features/artist/components/topSongAlbumForCover'; import { useLibraryCoverPrefetch } from '@/cover/useLibraryCoverPrefetch'; -import { useWarmGridCovers } from '@/hooks/useWarmGridCovers'; +import { useWarmGridCovers } from '@/cover/useWarmGridCovers'; import { VirtualCardGrid } from '@/ui/VirtualCardGrid'; import { LOSSLESS_MODE_QUERY } from '@/lib/library/losslessMode'; import { sortArtistAlbumsByYear } from '@/features/artist/utils/sortArtistAlbums'; diff --git a/src/features/fullscreenPlayer/components/FullscreenPlayerStatic.tsx b/src/features/fullscreenPlayer/components/FullscreenPlayerStatic.tsx index 7d33d775..9c973150 100644 --- a/src/features/fullscreenPlayer/components/FullscreenPlayerStatic.tsx +++ b/src/features/fullscreenPlayer/components/FullscreenPlayerStatic.tsx @@ -7,7 +7,7 @@ import { useTranslation } from 'react-i18next'; import { usePlayerStore } from '@/features/playback/store/playerStore'; import { queueSongStar, queueSongRating } from '@/features/playback/store/pendingStarSync'; import { useAlbumCoverRef, useArtistCoverRef } from '@/cover/useLibraryCoverRef'; -import { usePlaybackCoverArt } from '@/hooks/usePlaybackCoverArt'; +import { usePlaybackCoverArt } from '@/cover/usePlaybackCoverArt'; import { useCachedUrl } from '@/ui/CachedImage'; import { useArtistFanart } from '@/cover/useArtistFanart'; import { backdropFromConfig } from '@/cover/artistBackdrop'; diff --git a/src/features/miniPlayer/components/MiniPlayer.tsx b/src/features/miniPlayer/components/MiniPlayer.tsx index 1dc0b08e..47ac7b7a 100644 --- a/src/features/miniPlayer/components/MiniPlayer.tsx +++ b/src/features/miniPlayer/components/MiniPlayer.tsx @@ -1,4 +1,4 @@ -import { usePlaybackCoverArt } from '@/hooks/usePlaybackCoverArt'; +import { usePlaybackCoverArt } from '@/cover/usePlaybackCoverArt'; import { usePlaybackTrackCoverRef } from '@/cover/useLibraryCoverRef'; import { useEffect, useRef, useState } from 'react'; import { emit } from '@tauri-apps/api/event'; diff --git a/src/features/nowPlaying/components/MobilePlayerView.tsx b/src/features/nowPlaying/components/MobilePlayerView.tsx index ee682ea2..c1cca45d 100644 --- a/src/features/nowPlaying/components/MobilePlayerView.tsx +++ b/src/features/nowPlaying/components/MobilePlayerView.tsx @@ -1,5 +1,5 @@ import { queueSongStar } from '@/features/playback/store/pendingStarSync'; -import { usePlaybackCoverArt } from '@/hooks/usePlaybackCoverArt'; +import { usePlaybackCoverArt } from '@/cover/usePlaybackCoverArt'; import { usePlaybackTrackCoverRef } from '@/cover/useLibraryCoverRef'; import type { Track } from '@/lib/media/trackTypes'; import { getPlaybackProgressSnapshot, subscribePlaybackProgress } from '@/features/playback/store/playbackProgress'; diff --git a/src/features/sidebar/hooks/useSidebarPerfProbe.ts b/src/features/sidebar/hooks/useSidebarPerfProbe.ts index bc078a61..31e8f3c3 100644 --- a/src/features/sidebar/hooks/useSidebarPerfProbe.ts +++ b/src/features/sidebar/hooks/useSidebarPerfProbe.ts @@ -3,7 +3,7 @@ import { acquirePerfLivePoll, patchPerfLiveAnalysis } from '@/utils/perf/perfLiv import { setPerfProbeTelemetryActive } from '@/utils/perf/perfTelemetry'; import { useAnalysisPerfLast } from '@/utils/perf/analysisPerfStore'; import { useAnalysisPerfListener } from '@/hooks/useAnalysisPerfListener'; -import { useCoverPerfListener, useCoverUiThroughputPoll } from '@/hooks/useCoverPerfListener'; +import { useCoverPerfListener, useCoverUiThroughputPoll } from '@/cover/useCoverPerfListener'; import { getPerfProbeFlags, subscribePerfProbeFlags, diff --git a/src/hooks/usePlaybackCoverArt.ts b/src/hooks/usePlaybackCoverArt.ts deleted file mode 100644 index 0e2ab813..00000000 --- a/src/hooks/usePlaybackCoverArt.ts +++ /dev/null @@ -1,2 +0,0 @@ -/** @deprecated Import from `src/cover/usePlaybackCoverArt` — `displayCssPx` is CSS px, not tier. */ -export { usePlaybackCoverArt } from '../cover/usePlaybackCoverArt'; diff --git a/src/ui/VirtualCardGrid.tsx b/src/ui/VirtualCardGrid.tsx index 41cce935..c2efddd9 100644 --- a/src/ui/VirtualCardGrid.tsx +++ b/src/ui/VirtualCardGrid.tsx @@ -1,6 +1,6 @@ import React, { useCallback, useMemo, useRef } from 'react'; import { GRID_COVER_WARM_LIMIT } from '@/cover/layoutSizes'; -import { useWarmGridCovers } from '@/hooks/useWarmGridCovers'; +import { useWarmGridCovers } from '@/cover/useWarmGridCovers'; import { useVirtualizer } from '@tanstack/react-virtual'; import { APP_MAIN_SCROLL_VIEWPORT_ID } from '@/constants/appScroll'; import { useElementClientHeightById } from '@/lib/hooks/useResizeClientHeight';