Skip to content

Commit

Permalink
#1512, improve deletion detection
Browse files Browse the repository at this point in the history
  • Loading branch information
JamesUoM committed Dec 18, 2024
1 parent 382e5c9 commit 95cdcb2
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions src/redux/videoSlice.ts
Original file line number Diff line number Diff line change
@@ -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";
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit 95cdcb2

Please sign in to comment.