use console.log instead of console.error if indexeddb is not available as this behaviour is expected

This commit is contained in:
schlagmichdoch 2023-01-22 17:34:33 +01:00
parent 35aac22fae
commit bf79f72741
2 changed files with 10 additions and 10 deletions

View file

@ -118,7 +118,7 @@ class ServerConnection {
// make peerId persistent when pwa installed // make peerId persistent when pwa installed
PersistentStorage.set('peerId', msg.message.peerId).then(peerId => { PersistentStorage.set('peerId', msg.message.peerId).then(peerId => {
console.log(`peerId saved to indexedDB: ${peerId}`); console.log(`peerId saved to indexedDB: ${peerId}`);
}).catch(e => console.error(e)); }).catch(_ => _ => PersistentStorage.logBrowserNotCapable());
} }
Events.fire('display-name', msg); Events.fire('display-name', msg);
} }

View file

@ -818,7 +818,7 @@ class PairDeviceDialog extends Dialog {
PersistentStorage.getAllRoomSecrets().then(roomSecrets => { PersistentStorage.getAllRoomSecrets().then(roomSecrets => {
Events.fire('room-secrets', roomSecrets); Events.fire('room-secrets', roomSecrets);
this._evaluateNumberRoomSecrets(); this._evaluateNumberRoomSecrets();
}).catch((e) => console.error(e)); }).catch(_ => PersistentStorage.logBrowserNotCapable());
} }
_pairDeviceInitiate() { _pairDeviceInitiate() {
@ -872,7 +872,7 @@ class PairDeviceDialog extends Dialog {
}).finally(_ => { }).finally(_ => {
this._cleanUp() this._cleanUp()
}) })
.catch((e) => console.error(e)); .catch(_ => PersistentStorage.logBrowserNotCapable());
} }
_pairDeviceJoinKeyInvalid() { _pairDeviceJoinKeyInvalid() {
@ -901,7 +901,7 @@ class PairDeviceDialog extends Dialog {
PersistentStorage.deleteRoomSecret(roomSecret).then(_ => { PersistentStorage.deleteRoomSecret(roomSecret).then(_ => {
Events.fire('room-secret-deleted', roomSecret) Events.fire('room-secret-deleted', roomSecret)
this._evaluateNumberRoomSecrets(); this._evaluateNumberRoomSecrets();
}).catch((e) => console.error(e)); }).catch(_ => PersistentStorage.logBrowserNotCapable());
} }
_onClearRoomSecrets() { _onClearRoomSecrets() {
@ -911,7 +911,7 @@ class PairDeviceDialog extends Dialog {
Events.fire('notify-user', 'All Devices unpaired.') Events.fire('notify-user', 'All Devices unpaired.')
this._evaluateNumberRoomSecrets(); this._evaluateNumberRoomSecrets();
}) })
}).catch((e) => console.error(e)); }).catch(_ => PersistentStorage.logBrowserNotCapable());
} }
_onSecretRoomDeleted(roomSecret) { _onSecretRoomDeleted(roomSecret) {
@ -929,7 +929,7 @@ class PairDeviceDialog extends Dialog {
this.$clearSecretsBtn.setAttribute('hidden', ''); this.$clearSecretsBtn.setAttribute('hidden', '');
this.$footerInstructions.innerText = "You can be discovered by everyone on this network"; this.$footerInstructions.innerText = "You can be discovered by everyone on this network";
} }
}).catch((e) => console.error(e)); }).catch(_ => PersistentStorage.logBrowserNotCapable());
} }
} }
@ -1323,14 +1323,14 @@ class NoSleepUI {
class PersistentStorage { class PersistentStorage {
constructor() { constructor() {
if (!('indexedDB' in window)) { if (!('indexedDB' in window)) {
this.logBrowserNotCapable(); PersistentStorage.logBrowserNotCapable();
return; return;
} }
const DBOpenRequest = window.indexedDB.open('pairdrop_store', 2); const DBOpenRequest = window.indexedDB.open('pairdrop_store', 2);
DBOpenRequest.onerror = (e) => { DBOpenRequest.onerror = (e) => {
this.logBrowserNotCapable(); PersistentStorage.logBrowserNotCapable();
console.log('Error initializing database: '); console.log('Error initializing database: ');
console.error(e) console.log(e)
}; };
DBOpenRequest.onsuccess = () => { DBOpenRequest.onsuccess = () => {
console.log('Database initialised.'); console.log('Database initialised.');
@ -1359,7 +1359,7 @@ class PersistentStorage {
} }
} }
logBrowserNotCapable() { static logBrowserNotCapable() {
console.log("This browser does not support IndexedDB. Paired devices will be gone after the browser is closed."); console.log("This browser does not support IndexedDB. Paired devices will be gone after the browser is closed.");
} }