diff --git a/website/client/src/components/tasks/user.vue b/website/client/src/components/tasks/user.vue index 633b8c8da0..8acef03946 100644 --- a/website/client/src/components/tasks/user.vue +++ b/website/client/src/components/tasks/user.vue @@ -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' }), diff --git a/website/client/src/router/index.js b/website/client/src/router/index.js index 3238f17c44..13744b538e 100644 --- a/website/client/src/router/index.js +++ b/website/client/src/router/index.js @@ -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' }); } diff --git a/website/client/src/store/index.js b/website/client/src/store/index.js index 20d2332406..56eaac19d7 100644 --- a/website/client/src/store/index.js +++ b/website/client/src/store/index.js @@ -151,6 +151,7 @@ export default function () { bugReportOptions: { question: false, }, + postLoadModal: '', }, });