diff --git a/src/store/actions.ts b/src/store/actions.ts index 31ccc9a3..c4a235cb 100644 --- a/src/store/actions.ts +++ b/src/store/actions.ts @@ -61,8 +61,10 @@ export const actions: ActionTree = { const snapshot = snapshots[snapshotCursor] const { index, slides } = snapshot + const slideIndex = index > slides.length - 1 ? slides.length - 1 : index + commit(MutationTypes.SET_SLIDES, slides) - commit(MutationTypes.UPDATE_SLIDE_INDEX, index) + commit(MutationTypes.UPDATE_SLIDE_INDEX, slideIndex) commit(MutationTypes.SET_SNAPSHOT_CURSOR, snapshotCursor) commit(MutationTypes.SET_ACTIVE_ELEMENT_ID_LIST, []) }, @@ -75,8 +77,10 @@ export const actions: ActionTree = { const snapshot = snapshots[snapshotCursor] const { index, slides } = snapshot + const slideIndex = index > slides.length - 1 ? slides.length - 1 : index + commit(MutationTypes.SET_SLIDES, slides) - commit(MutationTypes.UPDATE_SLIDE_INDEX, index) + commit(MutationTypes.UPDATE_SLIDE_INDEX, slideIndex) commit(MutationTypes.SET_SNAPSHOT_CURSOR, snapshotCursor) commit(MutationTypes.SET_ACTIVE_ELEMENT_ID_LIST, []) },