Skip to content

Commit

Permalink
feat: improve handling for InvalidStateError #1323 #398
Browse files Browse the repository at this point in the history
  • Loading branch information
johannesjo committed Jul 7, 2021
1 parent fd69dec commit 05fc3b7
Showing 1 changed file with 7 additions and 9 deletions.
16 changes: 7 additions & 9 deletions src/app/core/persistence/database.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,15 +55,6 @@ export class DatabaseService {
return await (this.db as IDBPDatabase<MyDb>).put(DB_MAIN_NAME, data, key);
} catch (e) {
console.warn('DB Save Error: Last Params,', this._lastParams);
if (
e?.error?.name === 'InvalidStateError' &&
confirm(
'Unable to save your data. Is there enough free disk space? Press confirm to reload the app.',
)
) {
window.location.reload();
}

throw new Error(e);
}
}
Expand Down Expand Up @@ -113,6 +104,13 @@ export class DatabaseService {
// eslint-disable-next-line prefer-arrow/prefer-arrow-functions
terminated() {
alert('IDB TERMINATED');
if (
confirm(
'App database was terminated :( Is there enough free disk space or some process messing with the data? Press OK to reload the app.',
)
) {
window.location.reload();
}
},
});
} catch (e) {
Expand Down

0 comments on commit 05fc3b7

Please sign in to comment.