From ac84907a98e3c1f8a5629eef43f880306985e41f Mon Sep 17 00:00:00 2001 From: Hykilpikonna Date: Sat, 2 Nov 2019 20:20:09 -0400 Subject: [PATCH] [F] Update index only after loading --- src/components/navigation/navigation.ts | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/components/navigation/navigation.ts b/src/components/navigation/navigation.ts index 31a7027..0c4c914 100644 --- a/src/components/navigation/navigation.ts +++ b/src/components/navigation/navigation.ts @@ -1,7 +1,8 @@ import {Component, Prop, Vue} from 'vue-property-decorator'; -import {Course} from '@/components/app/app'; +import App, {Course} from '@/components/app/app'; import {CourseUtils} from '@/utils/course-utils'; import {FormatUtils} from '@/utils/format-utils'; +import pWaitFor from 'p-wait-for'; /** * This component is the top navigation bar @@ -21,7 +22,7 @@ export default class Navigation extends Vue /** * This is called when the instance is created. */ - public created() + public mounted() { // Set instance Navigation.instance = this; @@ -31,8 +32,11 @@ export default class Navigation extends Vue if (url == '/' || url == '') url = '/#overall'; window.history.replaceState({lastTab: url.substring(1)}, '', url); - // Update initial index - this.updateIndex(url.substring(2), false); + // Update initial index after loading is done + pWaitFor(() => App.instance.loading != '').then(() => + { + this.updateIndex(url.substring(2), false); + }); // Create history state listener window.onpopstate = e =>