Back out of timer app if it is running while timers are changed (so they are reloaded properly)
parent
a8b27df713
commit
611816f08c
|
|
@ -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,9 +333,15 @@
|
||||||
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
|
||||||
|
|
||||||
|
// 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), () => {
|
Util.writeStorage(TIMERS_FILE, JSON.stringify(userTimers), () => {
|
||||||
alert('Timers saved successfully.');
|
alert('Timers saved successfully.');
|
||||||
});
|
});
|
||||||
|
}, 2000);
|
||||||
|
});
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue