From 5028c0a9652f75b858ff6f29e94b5adfbf4408f3 Mon Sep 17 00:00:00 2001 From: John Edvard Reiten Date: Mon, 12 Sep 2022 22:50:31 +0900 Subject: [PATCH] fix: Init levels every time we click select level to update hearts --- src/menu.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/menu.js b/src/menu.js index 42694f7..3799af3 100644 --- a/src/menu.js +++ b/src/menu.js @@ -34,7 +34,6 @@ let hasRemovedDisableOnBonusEls = false; export const initMenu = () => { addButtonListeners(); listenForGameEvents(); - initLevels(); initBonusContent(); focusLevelSelectButton(); }; @@ -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'); @@ -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;