refactor: remove stop as a possible end action

This commit is contained in:
Carlos Valente
2025-03-23 22:01:33 +01:00
committed by Carlos Valente
parent 69eb9a5eff
commit 4ed38340e0
6 changed files with 3 additions and 12 deletions
@@ -102,7 +102,6 @@ export default function EditorSettingsForm() {
onChange={(event) => setDefaultEndAction(event.target.value as EndAction)}
>
<option value={EndAction.None}>None</option>
<option value={EndAction.Stop}>Stop</option>
<option value={EndAction.LoadNext}>Load next</option>
<option value={EndAction.PlayNext}>Play next</option>
</Select>
@@ -8,7 +8,6 @@ import {
IoPlay,
IoPlayForward,
IoPlaySkipForward,
IoStop,
IoTime,
} from 'react-icons/io5';
import { Tooltip } from '@chakra-ui/react';
@@ -177,9 +176,6 @@ function EndActionIcon(props: { action: EndAction; className: string }) {
if (action === EndAction.PlayNext) {
return <IoPlayForward className={maybeActiveClasses} />;
}
if (action === EndAction.Stop) {
return <IoStop className={maybeActiveClasses} />;
}
return <IoPlay className={className} />;
}
@@ -114,7 +114,6 @@ function EventEditorTimes(props: EventEditorTimesProps) {
variant='ontime'
>
<option value={EndAction.None}>None</option>
<option value={EndAction.Stop}>Stop rundown</option>
<option value={EndAction.LoadNext}>Load next event</option>
<option value={EndAction.PlayNext}>Play next event</option>
</Select>
@@ -134,9 +134,7 @@ class RuntimeService {
// handle end action if there was a timer playing
// actions are added to the queue stack to ensure that the order of operations is maintained
if (newState.eventNow) {
if (newState.eventNow.endAction === EndAction.Stop) {
setTimeout(this.stop.bind(this), 0);
} else if (newState.eventNow.endAction === EndAction.LoadNext) {
if (newState.eventNow.endAction === EndAction.LoadNext) {
setTimeout(this.loadNext.bind(this), 0);
} else if (newState.eventNow.endAction === EndAction.PlayNext) {
setTimeout(this.startNext.bind(this), 0);
@@ -2,5 +2,4 @@ export enum EndAction {
LoadNext = 'load-next',
None = 'none',
PlayNext = 'play-next',
Stop = 'stop',
}
@@ -9,9 +9,9 @@ describe('validateEndAction()', () => {
expect(endAction).toBe(EndAction.LoadNext);
});
it('returns fallback otherwise', () => {
const emptyAction = validateEndAction('', EndAction.Stop);
const emptyAction = validateEndAction('', EndAction.LoadNext);
const invalidAction = validateEndAction('this-does-not-exist', EndAction.PlayNext);
expect(emptyAction).toBe(EndAction.Stop);
expect(emptyAction).toBe(EndAction.LoadNext);
expect(invalidAction).toBe(EndAction.PlayNext);
});
});