[F] Fix history refresh problem

This commit is contained in:
Hykilpikonna
2019-12-21 14:46:06 -05:00
parent 1657330c57
commit b97ca4f699
+19 -9
View File
@@ -18,15 +18,23 @@ export default class NavController
constructor()
{
// Set history state
let url = '/' + window.location.hash;
if (url == '/' || url == '') url = '/#overall';
window.history.replaceState(this.convertIndex('overall'), '', url);
// Check history from last session
if (window.history.state.hash == undefined)
{
// Set history state
let url = '/' + window.location.hash;
if (url == '/') url = '/#overall';
window.history.replaceState(this.convertIndex('overall'), '', url);
// Update initial index after loading is done
// TODO: Test this
//pWaitFor(() => this.courses.length > 1 && App.instance.loading != '').then(() =>
this.updateIndex(url.substring(2), false);
// Update initial index after loading is done
// TODO: Test this
//pWaitFor(() => this.courses.length > 1 && App.instance.loading != '').then(() =>
this.updateIndex(url.substring(2), false);
}
else
{
this.index = window.history.state;
}
// Create history state listener
window.onpopstate = (e: any) =>
@@ -34,7 +42,7 @@ export default class NavController
if (e.state)
{
// Restore previous tab
console.log(`onPopState: Current: ${JSON.stringify(this.index)}, Previous: ${JSON.stringify(e.state)}`);
//console.log(`onPopState: Current: ${this.index.hash}, Previous: ${e.state.hash}`);
this.updateIndex(e.state, false);
}
};
@@ -56,6 +64,8 @@ export default class NavController
// Record history or not
if (history)
{
//console.log(`history: Current: ${this.index.hash}, New: ${index.hash}`);
// Check url
let url = `/#${index.hash}`;