Save log on quit and display some kind of alert if error occurs saving

master
Travis Evans 2023-08-21 15:01:42 -05:00
parent 4079123c93
commit a7024aa52b
1 changed files with 10 additions and 0 deletions

View File

@ -110,6 +110,7 @@ class StampLog {
this.isDirty = false;
} else {
console.log('stamplog: save to storage FAILED');
this.emit('saveError');
}
} else {
console.log('stamplog: skipping save to storage because no changes made');
@ -335,6 +336,15 @@ class MainScreen {
}
Bangle.loadWidgets();
Bangle.drawWidgets();
stampLog = new StampLog();
E.on('kill', stampLog.save.bind(stampLog));
stampLog.on('saveError', () => {
E.showAlert('Trouble saving timestamp log: Data may be lost!',
"Can't save log");
});
mainScreen = new MainScreen(stampLog);
mainScreen.start();