Skip to content

Commit 4e7f9fb

Browse files
committed
Fix load failure in firefox when indexedDB is disabled
1 parent f3eb661 commit 4e7f9fb

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

browser-index.js

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,19 @@
11
var matrixcs = require("./lib/matrix");
22
matrixcs.request(require("browser-request"));
33

4+
// just *accessing* indexedDB throws an exception in firefox with
5+
// indexeddb disabled.
6+
let indexedDB;
7+
try {
8+
indexedDB = global.indexedDB;
9+
} catch(e) {}
10+
411
// if our browser (appears to) support indexeddb, use an indexeddb crypto store.
5-
if (global.indexedDB) {
12+
if (indexedDB) {
613
matrixcs.setCryptoStoreFactory(
714
function() {
815
return new matrixcs.IndexedDBCryptoStore(
9-
global.indexedDB, "matrix-js-sdk:crypto"
16+
indexedDB, "matrix-js-sdk:crypto"
1017
);
1118
}
1219
);

0 commit comments

Comments
 (0)