Skip to content

Commit

Permalink
fix: Init levels every time we click select level to update hearts
Browse files Browse the repository at this point in the history
  • Loading branch information
johnedvard committed Sep 12, 2022
1 parent 678ece5 commit 5028c0a
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/menu.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ let hasRemovedDisableOnBonusEls = false;
export const initMenu = () => {
addButtonListeners();
listenForGameEvents();
initLevels();
initBonusContent();
focusLevelSelectButton();
};
Expand All @@ -45,6 +44,7 @@ const focusLevelSelectButton = () => {

const initLevels = () => {
const levelsGridEl = document.getElementById('levels-grid');
levelsGridEl.innerHTML = '';
for (let i = 1; i < levels + 1; i++) {
const collectedHearts = localStorage.getItem('hearts-' + i) || 0;
const levelEl = document.createElement('button');
Expand Down Expand Up @@ -159,6 +159,7 @@ const onContainerClick = (e) => {
const classList = e.target.classList;
switch (id) {
case 'lv':
initLevels();
showOverlay('levels');
document.getElementsByClassName('level-item')[0].focus();
break;
Expand Down

0 comments on commit 5028c0a

Please sign in to comment.