mirror of
https://github.com/streamyfin/streamyfin.git
synced 2026-07-07 04:53:01 +01:00
The close-first + runAfterInteractions pattern is needed only in the player, where selecting a subtitle can navigate (replacePlayer for a burn-in switch while transcoding). On the item detail page the selection just updates state, so deferring it until after the modal is dismissed re-renders the page after focus returns and yanks TV focus — leaving navigation stuck. Gate the deferral behind deferApplyUntilDismissed (set by the in-player caller only); the detail page runs the selection before closing, preserving focus.
25 lines
1.0 KiB
TypeScript
25 lines
1.0 KiB
TypeScript
import type { BaseItemDto } from "@jellyfin/sdk/lib/generated-client";
|
|
import { atom } from "jotai";
|
|
import type { Track } from "@/components/video-player/controls/types";
|
|
|
|
export type TVSubtitleModalState = {
|
|
item: BaseItemDto;
|
|
mediaSourceId?: string | null;
|
|
subtitleTracks: Track[];
|
|
currentSubtitleIndex: number;
|
|
onDisableSubtitles?: () => void;
|
|
onServerSubtitleDownloaded?: () => void;
|
|
onLocalSubtitleDownloaded?: (path: string) => void;
|
|
refreshSubtitleTracks?: () => Promise<Track[]>;
|
|
/**
|
|
* Run the selection callback AFTER the modal route is dismissed. Needed when
|
|
* `setTrack` navigates (the player's replacePlayer for a burn-in switch),
|
|
* which would be swallowed by the still-active modal route. Leave false for
|
|
* callers whose selection only updates state (the item detail page), so the
|
|
* update runs before dismissal and doesn't yank focus after it returns.
|
|
*/
|
|
deferApplyUntilDismissed?: boolean;
|
|
} | null;
|
|
|
|
export const tvSubtitleModalAtom = atom<TVSubtitleModalState>(null);
|