Skip to content

Commit

Permalink
Merge pull request #58 from lonevvolf/master
Browse files Browse the repository at this point in the history
Better fix for initial load
  • Loading branch information
cracrayol authored Aug 26, 2024
2 parents a3179d7 + 14c8bbf commit 15342fc
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions src/ts/routing.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export const routing = {
lastControllerName: null,

/**
* Redirect to some controler / action route
* Redirect to some controller / action route
* @param {string} route The route to redirect. It has a format "controller".
* @param {object} parameters Hash with parameters for the route. It can be null
* @returns True if the redirection can be done. False otherwise
Expand Down Expand Up @@ -50,15 +50,16 @@ export const routing = {
$(window).on("hashchange", routing.onHashChange );

// Call the initial controller
let initialHash = routing.normalizeHash(location.hash);
const initialHash = routing.normalizeHash(location.hash);
if ( initialHash === "" ) {
initialHash = "mainMenu";
routing.redirect("mainMenu");
}
routing.redirect(initialHash);

// Force the initial load if the hashChange event will not fire automatically
if (routing.normalizeHash(location.hash) === initialHash) {
routing.onHashChange();
else {
routing.redirect(initialHash);
// Force the initial load if the hashChange event will not fire automatically
if (routing.normalizeHash(location.hash) === initialHash) {
routing.onHashChange();
}
}
},

Expand Down

0 comments on commit 15342fc

Please sign in to comment.