mirror of
https://github.com/jellyfin/jellyfin-web
synced 2025-03-30 19:56:21 +00:00
Use a constant for defaults
This commit is contained in:
parent
37be617523
commit
acde0685b5
1 changed files with 6 additions and 4 deletions
|
@ -5,14 +5,16 @@ 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);
|
||||
let defaultAction = MediaSegmentAction.None;
|
||||
if (type === MediaSegmentType.Intro || type === MediaSegmentType.Outro) {
|
||||
defaultAction = MediaSegmentAction.AskToSkip;
|
||||
}
|
||||
const defaultAction = DEFAULT_ACTIONS[type] || MediaSegmentAction.None;
|
||||
|
||||
return action ? action as MediaSegmentAction : defaultAction;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue