mirror of
https://github.com/piskelapp/piskel.git
synced 2023-08-10 21:12:52 +03:00
Delete all extra backup sessions if MAX is reached
This commit is contained in:
parent
35788b54ba
commit
5671eb4782
@ -89,11 +89,17 @@
|
||||
return;
|
||||
}
|
||||
|
||||
var oldestSession = sessions.sort(function (s1, s2) {
|
||||
// Prepare an array containing all the ids of the sessions to be deleted.
|
||||
var sessionIdsToDelete = sessions.sort(function (s1, s2) {
|
||||
return s1.startDate - s2.startDate;
|
||||
})[0].id;
|
||||
}).map(function (s) {
|
||||
return s.id;
|
||||
}).slice(0, sessions.length - MAX_SESSIONS);
|
||||
|
||||
return this.deleteSession(oldestSession);
|
||||
// Delete all the extra sessions.
|
||||
return Q.all(sessionIdsToDelete.map(function (id) {
|
||||
return this.deleteSession(id);
|
||||
}.bind(this)));
|
||||
}.bind(this));
|
||||
}.bind(this));
|
||||
}
|
||||
|
@ -30,6 +30,8 @@
|
||||
};
|
||||
|
||||
ns.BeforeUnloadService.prototype.onBeforeUnload = function (evt) {
|
||||
// Attempt one last backup. Some of it may fail due to the asynchronous
|
||||
// nature of IndexedDB.
|
||||
pskl.app.backupService.backup();
|
||||
if (pskl.app.savedStatusService.isDirty()) {
|
||||
var confirmationMessage = 'Your current sprite has unsaved changes. Are you sure you want to quit?';
|
||||
|
Loading…
Reference in New Issue
Block a user