From d11035788af06ab1c3f57b4b429a76028bb76e19 Mon Sep 17 00:00:00 2001 From: Gamebrary Date: Thu, 18 Feb 2021 10:13:15 -0700 Subject: [PATCH] combine SET_ACTIVE_BOARD and UPDATE_BOARDS mutations --- src/components/Board/BoardBackgroundModal.vue | 1 - src/components/Board/EditBoardModal.vue | 1 - src/components/Dock.vue | 1 - src/store/mutations.js | 15 +++++++-------- 4 files changed, 7 insertions(+), 11 deletions(-) diff --git a/src/components/Board/BoardBackgroundModal.vue b/src/components/Board/BoardBackgroundModal.vue index 9dec2220..b95405dd 100644 --- a/src/components/Board/BoardBackgroundModal.vue +++ b/src/components/Board/BoardBackgroundModal.vue @@ -166,7 +166,6 @@ export default { }; this.$store.commit('SET_ACTIVE_BOARD', payload); - this.$store.commit('UPDATE_BOARDS', payload); await this.$store.dispatch('SAVE_BOARD') .catch(() => { diff --git a/src/components/Board/EditBoardModal.vue b/src/components/Board/EditBoardModal.vue index 72cc548b..000c77af 100644 --- a/src/components/Board/EditBoardModal.vue +++ b/src/components/Board/EditBoardModal.vue @@ -219,7 +219,6 @@ export default { }; this.$store.commit('SET_ACTIVE_BOARD', payload); - this.$store.commit('UPDATE_BOARDS', payload); await this.$store.dispatch('SAVE_BOARD') .catch(() => { diff --git a/src/components/Dock.vue b/src/components/Dock.vue index 1295676b..d9fcdb47 100755 --- a/src/components/Dock.vue +++ b/src/components/Dock.vue @@ -174,7 +174,6 @@ export default { }; this.$store.commit('SET_ACTIVE_BOARD', payload); - this.$store.commit('UPDATE_BOARDS', payload); await this.$store.dispatch('SAVE_BOARD') .catch(() => { diff --git a/src/store/mutations.js b/src/store/mutations.js index 389439dc..5bbd9378 100644 --- a/src/store/mutations.js +++ b/src/store/mutations.js @@ -28,20 +28,19 @@ export default { SET_ACTIVE_BOARD(state, board) { state.board = board; + + // Update board in boards + const boardIndex = state.boards.findIndex(({ id }) => board.id === id); + + if (boardIndex) { + Vue.set(state.boards, boardIndex, board); + } }, SET_PUBLIC_BOARDS(state, publicBoards) { state.publicBoards = publicBoards; }, - UPDATE_BOARDS(state, updatedBoard) { - const boardIndex = state.boards.findIndex(({ id }) => updatedBoard.id === id); - - if (!boardIndex) return; - - Vue.set(state.boards, boardIndex, updatedBoard); - }, - SET_GAME_BOARD(state, board) { state.board = board; },