Back out of timer app if it is running while timers are changed (so they are reloaded properly)

master
Travis Evans 2025-05-24 17:05:15 -05:00
parent a8b27df713
commit 611816f08c
1 changed files with 9 additions and 2 deletions

View File

@ -56,6 +56,7 @@
<script> <script>
const DATA_VERSION = 0; const DATA_VERSION = 0;
const TIMERS_FILE = 'tevtimer.timers.json'; const TIMERS_FILE = 'tevtimer.timers.json';
const APP_FILE = 'tevtimer.app.js';
const MAX_BUZZ_COUNT = 15; const MAX_BUZZ_COUNT = 15;
var userTimers = []; var userTimers = [];
@ -332,8 +333,14 @@
if (userTimers.length) { if (userTimers.length) {
// Guard in case the user manages to click Save before // Guard in case the user manages to click Save before
// the timers are loaded, or something like that // the timers are loaded, or something like that
Util.writeStorage(TIMERS_FILE, JSON.stringify(userTimers), () => {
alert('Timers saved successfully.'); // Ensure timer app is not running while we replace the timer file
Puck.write("if (global.__FILE__=='" + APP_FILE + "')load();\n", () => {
setTimeout(() => {
Util.writeStorage(TIMERS_FILE, JSON.stringify(userTimers), () => {
alert('Timers saved successfully.');
});
}, 2000);
}); });
}; };
} }