From 6bbbe9cececef7481dfde573e8aef67f510dd91f Mon Sep 17 00:00:00 2001 From: Hykilpikonna Date: Sun, 20 Oct 2019 21:31:05 -0400 Subject: [PATCH] [O] Encapsulate update history in updateIndex() --- src/components/navigation/navigation.ts | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/src/components/navigation/navigation.ts b/src/components/navigation/navigation.ts index 9d99570..173863f 100644 --- a/src/components/navigation/navigation.ts +++ b/src/components/navigation/navigation.ts @@ -60,22 +60,27 @@ export default class Navigation extends Vue // Debug output TODO: Remove this console.log(`onNavigate: Previous: ${this.activeIndex}, New: ${index}`); - - // Check url - let url = `/${index}`; - - // Push history state - window.history.pushState({lastTab: index}, '', url); } /** * Update index * * @param newIndex New index + * @param history Record in history or not (Default true) */ - private updateIndex(newIndex: string) + private updateIndex(newIndex: string, history?: boolean) { + // Call custom event this.$emit('update:activeIndex', newIndex); + + // Record or not + if (history == null || !history) return; + + // Check url + let url = `/${newIndex}`; + + // Push history state + window.history.pushState({lastTab: newIndex}, '', url); } /**