From 2ac7dd4ca3da3593cbdedc48981ecb728411418e Mon Sep 17 00:00:00 2001 From: "J. Ryan Stinnett" Date: Thu, 21 Mar 2019 15:02:26 +0000 Subject: [PATCH] Explicitly create `cryptoStore` in React SDK The React SDK has a client creation path that starts 2 out of 3 stores, but then leaves the other one for the JS SDK's default value handling. We'll soon be adding additional code to check the health of stores, so it would be simpler to follow and think about if we create them all in one place. --- src/utils/createMatrixClient.js | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/utils/createMatrixClient.js b/src/utils/createMatrixClient.js index 2acd1fae28..040f1e96cb 100644 --- a/src/utils/createMatrixClient.js +++ b/src/utils/createMatrixClient.js @@ -48,10 +48,6 @@ export default function createMatrixClient(opts, useIndexedDb) { useAuthorizationHeader: true, }; - if (localStorage) { - storeOpts.sessionStore = new Matrix.WebStorageSessionStore(localStorage); - } - if (indexedDB && localStorage && useIndexedDb) { storeOpts.store = new Matrix.IndexedDBStore({ indexedDB: indexedDB, @@ -61,6 +57,16 @@ export default function createMatrixClient(opts, useIndexedDb) { }); } + if (localStorage) { + storeOpts.sessionStore = new Matrix.WebStorageSessionStore(localStorage); + } + + if (indexedDB && useIndexedDb) { + storeOpts.cryptoStore = new Matrix.IndexedDBCryptoStore( + indexedDB, "matrix-js-sdk:crypto", + ); + } + opts = Object.assign(storeOpts, opts); return Matrix.createClient(opts);