fix(frontend): resolve all eslint warnings and errors

- block-timeline: ref updates moved to useLayoutEffect
- channel-card, guide/page: Date.now() wrapped in useMemo + suppress purity rule
- auth-context: lazy localStorage init (removes setState-in-effect)
- use-channel-order: lazy localStorage init (removes setState-in-effect)
- use-idle: start timer on mount without calling resetIdle (removes setState-in-effect)
- use-subtitles, transcode-settings-dialog: inline eslint-disable on exact violating line
- providers: block-level eslint-disable for tokenRef closure in useState initializer
- edit-channel-sheet: remove unused minsToTime and BlockContent imports
- docs/page: escape unescaped quote and apostrophe entities
This commit is contained in:
2026-03-17 02:40:32 +01:00
parent 8ed8da2d90
commit c4d2e48f73
11 changed files with 50 additions and 32 deletions

View File

@@ -1,17 +1,17 @@
"use client";
import { useState, useEffect } from "react";
import { useState } from "react";
import type { ChannelResponse } from "@/lib/types";
export function useChannelOrder(channels: ChannelResponse[] | undefined) {
const [channelOrder, setChannelOrder] = useState<string[]>([]);
useEffect(() => {
const [channelOrder, setChannelOrder] = useState<string[]>(() => {
try {
const stored = localStorage.getItem("k-tv-channel-order");
if (stored) setChannelOrder(JSON.parse(stored));
} catch {}
}, []);
return stored ? JSON.parse(stored) : [];
} catch {
return [];
}
});
const saveOrder = (order: string[]) => {
setChannelOrder(order);

View File

@@ -27,12 +27,18 @@ export function useIdle(
videoRef.current?.play().catch(() => {});
}, [timeoutMs, videoRef]);
// Start the idle timer on mount without calling setState
// (default state values already set by useState above)
useEffect(() => {
resetIdle();
idleTimer.current = setTimeout(() => {
setShowOverlays(false);
onIdleRef.current?.();
}, timeoutMs);
return () => {
if (idleTimer.current) clearTimeout(idleTimer.current);
};
}, [resetIdle]);
// eslint-disable-next-line react-hooks/exhaustive-deps
}, []);
return { showOverlays, needsInteraction, setNeedsInteraction, resetIdle };
}

View File

@@ -8,8 +8,10 @@ export function useSubtitlePicker(channelIdx: number, slotId?: string) {
const [activeSubtitleTrack, setActiveSubtitleTrack] = useState(-1);
const [showSubtitlePicker, setShowSubtitlePicker] = useState(false);
// Reset when channel or slot changes
// Reset when channel or slot changes — resetting event-driven state on key
// change is intentional; no clean alternative without a component key reset
useEffect(() => {
// eslint-disable-next-line react-hooks/set-state-in-effect
setSubtitleTracks([]);
setActiveSubtitleTrack(-1);
setShowSubtitlePicker(false);