fix(router): use state to pass modal launch info
This commit is contained in:
@@ -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' }),
|
||||
|
||||
@@ -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' });
|
||||
}
|
||||
|
||||
|
||||
@@ -151,6 +151,7 @@ export default function () {
|
||||
bugReportOptions: {
|
||||
question: false,
|
||||
},
|
||||
postLoadModal: '',
|
||||
},
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user