Skip to content

Commit

Permalink
avoid the "duplicated promise" error which comes from the vue-router (
Browse files Browse the repository at this point in the history
…fix #252 )
  • Loading branch information
vincent-lee90 authored and Gregory Saive committed Apr 23, 2020
1 parent c627df6 commit 9bcd49f
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/components/PageNavigator/PageNavigator.vue
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
$route.matched.map(({path}) => path).includes(route.path) ? 'active' : '',
!currentAccount ? 'un_click' : '',
]"
@click="!currentAccount ? '' : $router.push({name: route.name})"
@click="onPageNavigate(route)"
>
<div class="navigator-icon-container">
<img :src="route.meta.icon" class="navigator-icon">
Expand Down
6 changes: 6 additions & 0 deletions src/components/PageNavigator/PageNavigatorTs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import {Component, Vue} from 'vue-property-decorator'
import {mapGetters} from 'vuex'
// internal dependencies
import {AccountModel} from '@/core/database/entities/AccountModel'
import { Route } from 'vue-router'

@Component({
computed: {
Expand All @@ -41,4 +42,9 @@ export class PageNavigatorTs extends Vue {
await this.$store.dispatch('account/LOG_OUT')
this.$router.push({name: 'accounts.login'})
}

public onPageNavigate(route: Route) {
const isDuplicatedRoute = this.$route.matched.map(({ path }) => path).includes(route.path)
!isDuplicatedRoute && this.currentAccount && this.$router.push({ name: route.name }).catch(() => {/**/ })
}
}

0 comments on commit 9bcd49f

Please sign in to comment.