From 9e4de4a5df64f6b85e527f0e132967e6a62bbc4a Mon Sep 17 00:00:00 2001 From: James Perrin Date: Wed, 4 Oct 2023 15:24:45 +0100 Subject: [PATCH] fix #997, correct workflow ordering including when displayOrder undefined --- src/main/WorkflowSelection.tsx | 7 ++++++- src/redux/videoSlice.ts | 4 +--- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/src/main/WorkflowSelection.tsx b/src/main/WorkflowSelection.tsx index e8d0ad96c..8a64d1487 100644 --- a/src/main/WorkflowSelection.tsx +++ b/src/main/WorkflowSelection.tsx @@ -31,7 +31,12 @@ const WorkflowSelection : React.FC = () => { const dispatch = useDispatch(); // Initialite redux states - const workflows = useSelector(selectWorkflows) + let workflows = useSelector(selectWorkflows) + // Need to make copy to handle undefined displayOrder values + workflows = [...workflows].sort((a, b) => { + return (b.displayOrder - a.displayOrder) + }) + const finishState = useSelector(selectFinishState) const pageNumber = useSelector(selectPageNumber) const theme = useTheme() diff --git a/src/redux/videoSlice.ts b/src/redux/videoSlice.ts index 86cf7f524..ee3a996fe 100644 --- a/src/redux/videoSlice.ts +++ b/src/redux/videoSlice.ts @@ -217,9 +217,7 @@ const videoSlice = createSlice({ state.duration = action.payload.duration state.title = action.payload.title state.segments = parseSegments(action.payload.segments, action.payload.duration) - state.workflows = action.payload.workflows.sort((n1: { displayOrder: number; }, n2: { displayOrder: number; }) => { - return n1.displayOrder - n2.displayOrder; - }); + state.workflows = action.payload.workflows state.waveformImages = action.payload.waveformURIs ? action.payload.waveformURIs : state.waveformImages state.originalThumbnails = state.tracks.map((track: Track) => { return {id: track.id, uri: track.thumbnailUri} })