From acde0685b5510d1f8f358c74fa9e0e57d28fd4be Mon Sep 17 00:00:00 2001 From: viown <48097677+viown@users.noreply.github.com> Date: Mon, 28 Oct 2024 17:36:10 +0300 Subject: [PATCH] Use a constant for defaults --- .../features/playback/utils/mediaSegmentSettings.ts | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/apps/stable/features/playback/utils/mediaSegmentSettings.ts b/src/apps/stable/features/playback/utils/mediaSegmentSettings.ts index d2106ac21e9..45a3b835810 100644 --- a/src/apps/stable/features/playback/utils/mediaSegmentSettings.ts +++ b/src/apps/stable/features/playback/utils/mediaSegmentSettings.ts @@ -5,14 +5,16 @@ import { UserSettings } from 'scripts/settings/userSettings'; import { MediaSegmentAction } from '../constants/mediaSegmentAction'; const PREFIX = 'segmentTypeAction'; +const DEFAULT_ACTIONS: Partial> = { + [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; }