Skip to content

Commit

Permalink
client: Make _tr return the original promise
Browse files Browse the repository at this point in the history
So that `then` handlers only fire on success and we can attach `catch` handlers to it.
  • Loading branch information
jtojnar committed Sep 11, 2020
1 parent dd8d428 commit 35de644
Showing 1 changed file with 15 additions and 13 deletions.
28 changes: 15 additions & 13 deletions assets/js/selfoss-db.js
Original file line number Diff line number Diff line change
Expand Up @@ -317,21 +317,23 @@ selfoss.dbOffline = {


_tr: function() {
return selfoss.db.storage.transaction
.apply(selfoss.db.storage, arguments)
.catch(function(error) {
selfoss.ui.showError(selfoss.ui._('error_offline_storage', [error.message]));
selfoss.db.storage = null;
selfoss.db.reloadList();
let promise = selfoss.db.storage.transaction.apply(selfoss.db.storage, arguments);

// If this is a QuotaExceededError, garbage collect more
// entries and hope it helps.
if (error.name === Dexie.errnames.QuotaExceeded) {
selfoss.dbOffline.GCEntries(true);
}
promise.catch(function(error) {
selfoss.ui.showError(selfoss.ui._('error_offline_storage', [error.message]));
selfoss.db.storage = null;
selfoss.db.reloadList();

throw (error);
});
// If this is a QuotaExceededError, garbage collect more
// entries and hope it helps.
if (error.name === Dexie.errnames.QuotaExceeded) {
selfoss.dbOffline.GCEntries(true);
}

throw error;
});

return promise;
},


Expand Down

0 comments on commit 35de644

Please sign in to comment.