mirror of
https://github.com/romancm/gamebrary
synced 2025-02-17 19:48:24 +00:00
catch error when adding game, also update mutation prop
This commit is contained in:
parent
2906835701
commit
105db012d5
1 changed files with 6 additions and 3 deletions
|
@ -45,12 +45,15 @@ export default {
|
|||
|
||||
methods: {
|
||||
async addGame() {
|
||||
const { list, gameId, board } = this;
|
||||
const { list, game, board } = this;
|
||||
|
||||
const listIndex = board.lists.findIndex(({ name }) => name === list.name);
|
||||
|
||||
this.$store.commit('ADD_GAME_TO_LIST', { listIndex, gameId });
|
||||
await this.$store.dispatch('SAVE_BOARD');
|
||||
this.$store.commit('ADD_GAME_TO_LIST', { listIndex, game });
|
||||
await this.$store.dispatch('SAVE_BOARD')
|
||||
.catch(() => {
|
||||
this.$bvToast.toast(`There was an error adding ${this.game.name}`, { title: list.name, variant: 'danger' });
|
||||
});
|
||||
|
||||
// TODO: CUSTOMIZE TO SHOW GAME COVER
|
||||
this.$bvToast.toast(`${this.game.name} added`, { title: list.name, variant: 'success' });
|
||||
|
|
Loading…
Add table
Reference in a new issue