feat: ChannelDetail now initializes view mode from the channel's platfo…
- "src/frontend/src/pages/ChannelDetail.tsx" GSD-Task: S04/T03
This commit is contained in:
parent
d8d876e9b8
commit
f8916d2cc3
1 changed files with 16 additions and 0 deletions
|
|
@ -30,6 +30,7 @@ import { useChannel, useUpdateChannel, useDeleteChannel, useScanChannel, useCanc
|
||||||
import { useChannelContentPaginated, useContentTypeCounts, useDownloadContent, useToggleMonitored, useBulkMonitored, useCollectMonitored, useUpdateContentRating, type ChannelContentFilters } from '../api/hooks/useContent';
|
import { useChannelContentPaginated, useContentTypeCounts, useDownloadContent, useToggleMonitored, useBulkMonitored, useCollectMonitored, useUpdateContentRating, type ChannelContentFilters } from '../api/hooks/useContent';
|
||||||
import { useChannelPlaylists, useRefreshPlaylists } from '../api/hooks/usePlaylists';
|
import { useChannelPlaylists, useRefreshPlaylists } from '../api/hooks/usePlaylists';
|
||||||
import { useFormatProfiles } from '../api/hooks/useFormatProfiles';
|
import { useFormatProfiles } from '../api/hooks/useFormatProfiles';
|
||||||
|
import { usePlatformSetting } from '../api/hooks/usePlatformSettings';
|
||||||
import { Table, type Column } from '../components/Table';
|
import { Table, type Column } from '../components/Table';
|
||||||
import { PlatformBadge } from '../components/PlatformBadge';
|
import { PlatformBadge } from '../components/PlatformBadge';
|
||||||
import { StatusBadge } from '../components/StatusBadge';
|
import { StatusBadge } from '../components/StatusBadge';
|
||||||
|
|
@ -82,6 +83,7 @@ export function ChannelDetail() {
|
||||||
const { data: formatProfiles } = useFormatProfiles();
|
const { data: formatProfiles } = useFormatProfiles();
|
||||||
const { data: playlistData } = useChannelPlaylists(channelId);
|
const { data: playlistData } = useChannelPlaylists(channelId);
|
||||||
const { data: contentTypeCounts } = useContentTypeCounts(channelId);
|
const { data: contentTypeCounts } = useContentTypeCounts(channelId);
|
||||||
|
const { data: platformSettings } = usePlatformSetting(channel?.platform ?? null);
|
||||||
|
|
||||||
// ── Content type tab (URL-driven) ──
|
// ── Content type tab (URL-driven) ──
|
||||||
const activeTab = searchParams.get('tab') ?? 'all';
|
const activeTab = searchParams.get('tab') ?? 'all';
|
||||||
|
|
@ -108,6 +110,7 @@ export function ChannelDetail() {
|
||||||
const [sortDirection, setSortDirection] = usePersistedState<'asc' | 'desc'>('tubearr-sort-dir', 'asc');
|
const [sortDirection, setSortDirection] = usePersistedState<'asc' | 'desc'>('tubearr-sort-dir', 'asc');
|
||||||
const [groupBy, setGroupBy] = usePersistedState<GroupByKey>('tubearr-group-by', 'none');
|
const [groupBy, setGroupBy] = usePersistedState<GroupByKey>('tubearr-group-by', 'none');
|
||||||
const [viewMode, setViewMode] = usePersistedState<'table' | 'card' | 'list'>('tubearr-content-view', 'table');
|
const [viewMode, setViewMode] = usePersistedState<'table' | 'card' | 'list'>('tubearr-content-view', 'table');
|
||||||
|
const viewModeOverriddenRef = useRef(false);
|
||||||
|
|
||||||
// Derive contentType filter from active tab
|
// Derive contentType filter from active tab
|
||||||
const contentTypeFilter = activeTab === 'all' ? '' : activeTab;
|
const contentTypeFilter = activeTab === 'all' ? '' : activeTab;
|
||||||
|
|
@ -176,6 +179,18 @@ export function ChannelDetail() {
|
||||||
return () => observer.disconnect();
|
return () => observer.disconnect();
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
|
// Reset view-mode override when navigating to a different channel
|
||||||
|
useEffect(() => {
|
||||||
|
viewModeOverriddenRef.current = false;
|
||||||
|
}, [channelId]);
|
||||||
|
|
||||||
|
// Apply platform default view when settings load (only if user hasn't manually switched)
|
||||||
|
useEffect(() => {
|
||||||
|
if (!platformSettings?.defaultView || viewModeOverriddenRef.current) return;
|
||||||
|
const mapped = platformSettings.defaultView === 'poster' ? 'card' : platformSettings.defaultView;
|
||||||
|
setViewMode(mapped);
|
||||||
|
}, [platformSettings?.defaultView, setViewMode]);
|
||||||
|
|
||||||
// Sync local check interval from channel data
|
// Sync local check interval from channel data
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (channel?.checkInterval != null) {
|
if (channel?.checkInterval != null) {
|
||||||
|
|
@ -344,6 +359,7 @@ export function ChannelDetail() {
|
||||||
}, [groupBy]);
|
}, [groupBy]);
|
||||||
|
|
||||||
const handleSetViewMode = useCallback((mode: 'table' | 'card' | 'list') => {
|
const handleSetViewMode = useCallback((mode: 'table' | 'card' | 'list') => {
|
||||||
|
viewModeOverriddenRef.current = true;
|
||||||
setViewMode(mode);
|
setViewMode(mode);
|
||||||
}, [setViewMode]);
|
}, [setViewMode]);
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue