1
0
Fork 0
mirror of https://github.com/jellyfin/jellyfin-web synced 2025-03-30 19:56:21 +00:00
jellyfin-web/src/apps/stable/features/playback/utils/mediaSegmentSettings.ts
2024-10-28 17:36:10 +03:00

20 lines
858 B
TypeScript

import { MediaSegmentType } from '@jellyfin/sdk/lib/generated-client/models/media-segment-type';
import { UserSettings } from 'scripts/settings/userSettings';
import { MediaSegmentAction } from '../constants/mediaSegmentAction';
const PREFIX = 'segmentTypeAction';
const DEFAULT_ACTIONS: Partial<Record<MediaSegmentType, MediaSegmentAction>> = {
[MediaSegmentType.Intro]: MediaSegmentAction.AskToSkip,
[MediaSegmentType.Outro]: MediaSegmentAction.AskToSkip
};
export const getId = (type: MediaSegmentType) => `${PREFIX}__${type}`;
export function getMediaSegmentAction(userSettings: UserSettings, type: MediaSegmentType): MediaSegmentAction {
const action = userSettings.get(getId(type), false);
const defaultAction = DEFAULT_ACTIONS[type] || MediaSegmentAction.None;
return action ? action as MediaSegmentAction : defaultAction;
}