Skip to content

Commit

Permalink
Merge pull request #1267 from Arnei/fix-subtitles-not-getting-saved-t…
Browse files Browse the repository at this point in the history
…o-opencast-for-new-subtitles

Fix subtiles not saved for new subtitles
  • Loading branch information
geichelberger authored Feb 29, 2024
2 parents 1b5028b + 1681ee8 commit 6581d0f
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 6581d0f

Please sign in to comment.