[F] Fix history refresh problem
This commit is contained in:
@@ -18,15 +18,23 @@ export default class NavController
|
|||||||
|
|
||||||
constructor()
|
constructor()
|
||||||
{
|
{
|
||||||
// Set history state
|
// Check history from last session
|
||||||
let url = '/' + window.location.hash;
|
if (window.history.state.hash == undefined)
|
||||||
if (url == '/' || url == '') url = '/#overall';
|
{
|
||||||
window.history.replaceState(this.convertIndex('overall'), '', url);
|
// 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
|
// Update initial index after loading is done
|
||||||
// TODO: Test this
|
// TODO: Test this
|
||||||
//pWaitFor(() => this.courses.length > 1 && App.instance.loading != '').then(() =>
|
//pWaitFor(() => this.courses.length > 1 && App.instance.loading != '').then(() =>
|
||||||
this.updateIndex(url.substring(2), false);
|
this.updateIndex(url.substring(2), false);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
this.index = window.history.state;
|
||||||
|
}
|
||||||
|
|
||||||
// Create history state listener
|
// Create history state listener
|
||||||
window.onpopstate = (e: any) =>
|
window.onpopstate = (e: any) =>
|
||||||
@@ -34,7 +42,7 @@ export default class NavController
|
|||||||
if (e.state)
|
if (e.state)
|
||||||
{
|
{
|
||||||
// Restore previous tab
|
// 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);
|
this.updateIndex(e.state, false);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@@ -56,6 +64,8 @@ export default class NavController
|
|||||||
// Record history or not
|
// Record history or not
|
||||||
if (history)
|
if (history)
|
||||||
{
|
{
|
||||||
|
//console.log(`history: Current: ${this.index.hash}, New: ${index.hash}`);
|
||||||
|
|
||||||
// Check url
|
// Check url
|
||||||
let url = `/#${index.hash}`;
|
let url = `/#${index.hash}`;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user