combine SET_ACTIVE_BOARD and UPDATE_BOARDS mutations

This commit is contained in:
Gamebrary 2021-02-18 10:13:15 -07:00
parent 1c9f84da27
commit d11035788a
4 changed files with 7 additions and 11 deletions

View file

@ -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(() => {

View file

@ -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(() => {

View file

@ -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(() => {

View file

@ -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;
},