From 95cdcb2d021db1e1e000dd26ac5c55bac2935f70 Mon Sep 17 00:00:00 2001 From: James Perrin Date: Wed, 18 Dec 2024 11:23:49 +0000 Subject: [PATCH] #1512, improve deletion detection --- src/redux/videoSlice.ts | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/redux/videoSlice.ts b/src/redux/videoSlice.ts index 19947f81d..54dc6a7ab 100644 --- a/src/redux/videoSlice.ts +++ b/src/redux/videoSlice.ts @@ -1,5 +1,5 @@ -import { clamp } from "lodash"; -import { createSlice, nanoid, PayloadAction, createSelector } from "@reduxjs/toolkit"; +import { clamp, forEach } from "lodash"; +import { createSlice, nanoid, createAsyncThunk, PayloadAction, createSelector } from "@reduxjs/toolkit"; import { client } from "../util/client"; import { Segment, httpRequestState, Track, Workflow, SubtitlesFromOpencast } from "../types"; @@ -188,9 +188,15 @@ const videoSlice = createSlice({ state.jumpTriggered = true; }, validateSegments: state => { + let allDeleted = true; + // Test if whole video has been deleted - if (state.segments.length === 1 && state.segments[0].deleted && state.segments[0].start === 0 && - state.segments[0].end === state.duration) { + state.segments.forEach(segment => { + if(!segment.deleted) { + allDeleted = false; + } + }) + if(allDeleted) { state.validSegments = false; } else { state.validSegments = true;