Leave character page before deleting to prevent UI errors

This commit is contained in:
Stefan Zermatten
2021-04-13 10:50:35 +02:00
parent 15d593db79
commit 52e7deedc6
2 changed files with 5 additions and 4 deletions

View File

@@ -6,7 +6,7 @@ let lastSnackbarId = 0;
function snackbar(data) {
globalState.queue.push({
data,
data, //{text OR content, callback, callbackName} // content is logContent
id: ++lastSnackbarId,
enqueuedAt: new Date(),
shown: false,

View File

@@ -34,6 +34,7 @@
import Creatures from '/imports/api/creature/Creatures.js';
import DialogBase from '/imports/ui/dialogStack/DialogBase.vue';
import removeCreature from '/imports/api/creature/removeCreature.js';
import { snackbar } from '/imports/ui/components/snackbars/SnackbarQueue.js';
export default {
components: {
@@ -61,12 +62,12 @@ export default {
},
methods: {
remove(){
this.$router.push('/characterList');
this.$store.dispatch('popDialogStack');
removeCreature.call({charId: this.id}, (error) => {
if (error) {
console.error(error);
} else {
this.$router.push('/characterList');
this.$store.dispatch('popDialogStack');
snackbar({text: error.message || error.toString()});
}
});
}