[O] Encapsulate update history in updateIndex()

This commit is contained in:
Hykilpikonna
2019-10-20 21:31:05 -04:00
parent e6a4a04bb4
commit 6bbbe9cece
+12 -7
View File
@@ -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);
}
/**