From 05fc3b7aabf2bab5e858b5a249fe7fedc746b3c5 Mon Sep 17 00:00:00 2001 From: Johannes Millan Date: Wed, 7 Jul 2021 13:54:26 +0200 Subject: [PATCH] feat: improve handling for InvalidStateError #1323 #398 --- src/app/core/persistence/database.service.ts | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/src/app/core/persistence/database.service.ts b/src/app/core/persistence/database.service.ts index 48a5f1d898a..721c12bb228 100644 --- a/src/app/core/persistence/database.service.ts +++ b/src/app/core/persistence/database.service.ts @@ -55,15 +55,6 @@ export class DatabaseService { return await (this.db as IDBPDatabase).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); } } @@ -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) {