Skip to content

Commit

Permalink
Fix subtiles not saved for new subtitles
Browse files Browse the repository at this point in the history
Creating a new subtitle from scratch was broken,
because the text in the cues was not saved to Opencast.
This fixes that.
  • Loading branch information
Arnei committed Feb 1, 2024
1 parent 26e97b1 commit 1681ee8
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
6 changes: 5 additions & 1 deletion src/main/WorkflowConfiguration.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,10 @@ import {
selectPostStatus,
setHasChanges as metadataSetHasChanges,
} from "../redux/metadataSlice";
import { selectSubtitles } from "../redux/subtitleSlice";
import {
selectSubtitles,
setHasChanges as subtitleSetHasChanges,
} from "../redux/subtitleSlice";
import { serializeSubtitle } from "../util/utilityFunctions";
import { useTheme } from "../themes";

Expand Down Expand Up @@ -105,6 +108,7 @@ export const SaveAndProcessButton: React.FC<{ text: string; }> = ({ text }) => {
dispatch(setEnd({ hasEnded: true, value: "success" }));
dispatch(videoSetHasChanges(false));
dispatch(metadataSetHasChanges(false));
dispatch(subtitleSetHasChanges(false));
}
}, [dispatch, metadataStatus, workflowStatus]);

Expand Down
5 changes: 4 additions & 1 deletion src/redux/subtitleSlice.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ export const subtitleSlice = createSlice({
setCueAtIndex: (state, action: PayloadAction<{ identifier: string, cueIndex: number, newCue: SubtitleCue; }>) => {
if (action.payload.cueIndex < 0 ||
action.payload.cueIndex >= state.subtitles[action.payload.identifier].cues.length) {
console.log("WARNING: Tried to set segment for subtitle " + action.payload.identifier +
console.warn("Tried to set segment for subtitle " + action.payload.identifier +
" but was out of range");
return;
}
Expand All @@ -93,6 +93,9 @@ export const subtitleSlice = createSlice({
cue.startTime = Math.round(action.payload.newCue.startTime);
cue.endTime = Math.round(action.payload.newCue.endTime);

if (cue.tree.children.length <= 0) {
cue.tree.children[0] = { type: "text", value: action.payload.newCue.text };
}
cue.tree.children[0].value = action.payload.newCue.text;

state.subtitles[action.payload.identifier].cues[action.payload.cueIndex] = cue;
Expand Down

0 comments on commit 1681ee8

Please sign in to comment.