fix(router): use state to pass modal launch info

This commit is contained in:
SabreCat
2023-10-02 20:51:20 -05:00
parent 541eadd319
commit 3aba0abedd
3 changed files with 12 additions and 7 deletions
@@ -486,6 +486,15 @@ export default {
this.$store.dispatch('common:setTitle', {
section: this.$t('tasks'),
});
if (this.$store.state.postLoadModal) {
const modalToLoad = this.$store.state.postLoadModal;
if (modalToLoad.includes('profile')) {
this.$router.push(modalToLoad);
} else {
this.$root.$emit('bv::show::modal', modalToLoad);
}
this.$store.state.postLoadModal = '';
}
},
methods: {
...mapActions({ setUser: 'user:set' }),
+2 -7
View File
@@ -320,12 +320,7 @@ router.beforeEach(async (to, from, next) => {
startingPage = to.params.startingPage;
}
if (from.name === null) {
setTimeout(() => router.app.$emit('habitica:show-profile', {
userId: to.params.userId,
startingPage,
fromPath: '/',
toPath: to.path,
}), 500);
store.state.postLoadModal = `profile/${to.params.userId}`;
return next({ name: 'tasks' });
}
router.app.$emit('habitica:show-profile', {
@@ -339,7 +334,7 @@ router.beforeEach(async (to, from, next) => {
}
if (to.name === 'tasks' && to.query.openGemsModal === 'true') {
setTimeout(() => router.app.$emit('bv::show::modal', 'buy-gems'), 500);
store.state.postLoadModal = 'buy-gems';
return next({ name: 'tasks' });
}
+1
View File
@@ -151,6 +151,7 @@ export default function () {
bugReportOptions: {
question: false,
},
postLoadModal: '',
},
});