Skip to content

Commit

Permalink
Merge pull request #56 from lonevvolf/master
Browse files Browse the repository at this point in the history
Real fix for the Change Color button not working on first load (from …
  • Loading branch information
cracrayol authored Aug 26, 2024
2 parents 7ea1602 + b0c3e71 commit a3179d7
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 7 deletions.
1 change: 0 additions & 1 deletion src/ts/controller/mainMenuController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ export const mainMenuController = {
*/
changeColor() {
settingsController.changeColorTheme(state.color === Color.Light ? Color.Dark : Color.Light);
mainMenuController.index();
},

/** Return page */
Expand Down
2 changes: 0 additions & 2 deletions src/ts/controller/settingsController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ export const settingsController = {
*/
changeColorTheme(color: Color): void {
template.changeColorTheme( color );
state.updateColorTheme( color );
},

/**
Expand All @@ -35,7 +34,6 @@ export const settingsController = {
*/
changeTextSize(textSize: TextSize): void {
template.changeTextSize( textSize );
state.updateTextSize( textSize );
},

/**
Expand Down
8 changes: 5 additions & 3 deletions src/ts/routing.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,10 @@ export const routing = {
}
routing.redirect(initialHash);

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

/**
Expand Down Expand Up @@ -118,7 +120,7 @@ export const routing = {

let controller;

// Notify the previous controler that we leave
// Notify the previous controller that we leave
try {
if ( routing.lastControllerName ) {
controller = routing.getController(routing.lastControllerName);
Expand Down
2 changes: 1 addition & 1 deletion src/ts/views/mainMenuView.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export const mainMenuView = {
e.preventDefault();
routing.redirect("loadGame");
});
$("#menu-color-theme").one("click", (e) => {
$("#menu-color-theme").on("click", (e) => {
e.preventDefault();
mainMenuController.changeColor();
});
Expand Down

0 comments on commit a3179d7

Please sign in to comment.