From d204ae4e6e6ef71e15bb26a09709f238e86d75c5 Mon Sep 17 00:00:00 2001 From: Julian Kniephoff Date: Mon, 25 Nov 2024 12:50:10 +0100 Subject: [PATCH] Make behavior of forward button more intuitive This patch makes the forward button jump to the end of the video if you are currently in the last segment. The previous behavior, jumping to the **beginning** of the last segment, made it so that the forward button sometimes made you go backwards in the video. This is especially confusing if there is only one segment, in which case the forward button put you at the beginning of the video. --- src/redux/videoSlice.ts | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/redux/videoSlice.ts b/src/redux/videoSlice.ts index e8884c8eb..cb693f07c 100644 --- a/src/redux/videoSlice.ts +++ b/src/redux/videoSlice.ts @@ -171,14 +171,17 @@ const videoSlice = createSlice({ state.jumpTriggered = true; }, jumpToNextSegment: state => { - let nextSegmentIndex = state.activeSegmentIndex + 1; + const nextSegmentIndex = state.activeSegmentIndex + 1; + let jumpTarget = 0; if (state.activeSegmentIndex + 1 >= state.segments.length) { - // Jump to start of last segment - nextSegmentIndex = state.activeSegmentIndex; + // Jump to end of last segment + jumpTarget = state.segments[state.activeSegmentIndex].end; + } else { + jumpTarget = state.segments[nextSegmentIndex].start; } - updateCurrentlyAt(state, state.segments[nextSegmentIndex].start); + updateCurrentlyAt(state, jumpTarget); state.jumpTriggered = true; }, addSegment: (state, action: PayloadAction) => {