mirror of
http://nostr-git-proxy.forgejo.svc.cluster.local/git/45387ca441053e230b2126802005eb03767ab59d84555e8bac86b6e7def14e27/myadhd
synced 2026-09-23 20:23:10 +00:00
fix: persist dopamine menu time selection, prevent double confetti on last step
- Store currentMenuMins in localStorage so reroll works after page reload - Restore selected time button highlight on page load - Add skipCelebration param to nowShowNext() — timer-mark-done already fires celebrateSound()+confetti(), so suppress duplicate when it discovers all steps are done
This commit is contained in:
parent
79d8a5d623
commit
80a4618d95
1 changed files with 15 additions and 5 deletions
|
|
@ -411,7 +411,7 @@
|
||||||
// Clear one-thing and show next step prompt
|
// Clear one-thing and show next step prompt
|
||||||
localStorage.removeItem('myadhd.now');
|
localStorage.removeItem('myadhd.now');
|
||||||
showTab('now');
|
showTab('now');
|
||||||
nowShowNext();
|
nowShowNext(true);
|
||||||
});
|
});
|
||||||
|
|
||||||
timerPaint();
|
timerPaint();
|
||||||
|
|
@ -468,10 +468,11 @@
|
||||||
]
|
]
|
||||||
};
|
};
|
||||||
var lastPick = null;
|
var lastPick = null;
|
||||||
var currentMenuMins = null;
|
var currentMenuMins = store('menu_mins') || null;
|
||||||
|
|
||||||
function menuPick(mins) {
|
function menuPick(mins) {
|
||||||
currentMenuMins = mins;
|
currentMenuMins = mins;
|
||||||
|
store('menu_mins', mins);
|
||||||
// Highlight the selected time button
|
// Highlight the selected time button
|
||||||
$$('.menu-pick').forEach(function (b) {
|
$$('.menu-pick').forEach(function (b) {
|
||||||
b.classList.toggle('on', +b.dataset.min === mins);
|
b.classList.toggle('on', +b.dataset.min === mins);
|
||||||
|
|
@ -514,6 +515,13 @@
|
||||||
});
|
});
|
||||||
paintStreak();
|
paintStreak();
|
||||||
|
|
||||||
|
// Restore menu time selection highlight on page load
|
||||||
|
if (currentMenuMins) {
|
||||||
|
$$('.menu-pick').forEach(function (b) {
|
||||||
|
b.classList.toggle('on', +b.dataset.min === currentMenuMins);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
/* ---------- one thing ---------- */
|
/* ---------- one thing ---------- */
|
||||||
function nowRender() {
|
function nowRender() {
|
||||||
var nowSaved = store('now');
|
var nowSaved = store('now');
|
||||||
|
|
@ -542,7 +550,7 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function nowShowNext() {
|
function nowShowNext(skipCelebration) {
|
||||||
var nextPrompt = $('#now-next');
|
var nextPrompt = $('#now-next');
|
||||||
if (!nextPrompt) return;
|
if (!nextPrompt) return;
|
||||||
var b = store(breakerKey);
|
var b = store(breakerKey);
|
||||||
|
|
@ -576,8 +584,10 @@
|
||||||
// All steps done
|
// All steps done
|
||||||
$('#now-next-step').hidden = true;
|
$('#now-next-step').hidden = true;
|
||||||
$('#now-all-done').hidden = false;
|
$('#now-all-done').hidden = false;
|
||||||
celebrateSound();
|
if (!skipCelebration) {
|
||||||
confetti();
|
celebrateSound();
|
||||||
|
confetti();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue