Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix subtiles not saved for new subtitles #1267

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/main/SubtitleEditor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ const SubtitleEditor: React.FC = () => {
const [getError, setGetError] = useState<string | undefined>(undefined);
const subtitle = useAppSelector(selectSelectedSubtitleById);
const selectedId = useAppSelector(selectSelectedSubtitleId);
const captionTrack = useAppSelector(selectSubtitlesFromOpencastById(selectedId));
const captionTrack = useAppSelector(state => selectSubtitlesFromOpencastById(state, selectedId));
const theme = useTheme();

// Prepare subtitle in redux
Expand Down
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
Loading