@@ -17,6 +17,9 @@ limitations under the License.
17
17
import { LocalStorageCryptoStore , IndexedDBStore , IndexedDBCryptoStore } from "matrix-js-sdk/src/matrix" ;
18
18
import { logger } from "matrix-js-sdk/src/logger" ;
19
19
20
+ import SettingsStore from "../settings/SettingsStore" ;
21
+ import { Features } from "../settings/Settings" ;
22
+
20
23
const localStorage = window . localStorage ;
21
24
22
25
// just *accessing* indexedDB throws an exception in firefox with
28
31
29
32
// The JS SDK will add a prefix of "matrix-js-sdk:" to the sync store name.
30
33
const SYNC_STORE_NAME = "riot-web-sync" ;
31
- const CRYPTO_STORE_NAME = "matrix-js-sdk:crypto" ;
34
+ const LEGACY_CRYPTO_STORE_NAME = "matrix-js-sdk:crypto" ;
35
+ const RUST_CRYPTO_STORE_NAME = "matrix-js-sdk::matrix-sdk-crypto" ;
36
+
37
+ function cryptoStoreName ( ) : string {
38
+ if ( SettingsStore . getValue ( Features . RustCrypto ) ) {
39
+ return RUST_CRYPTO_STORE_NAME ;
40
+ } else {
41
+ return LEGACY_CRYPTO_STORE_NAME ;
42
+ }
43
+ }
32
44
33
45
function log ( msg : string ) : void {
34
46
logger . log ( `StorageManager: ${ msg } ` ) ;
@@ -145,7 +157,7 @@ async function checkSyncStore(): Promise<StoreCheck> {
145
157
async function checkCryptoStore ( ) : Promise < StoreCheck > {
146
158
let exists = false ;
147
159
try {
148
- exists = await IndexedDBCryptoStore . exists ( indexedDB , CRYPTO_STORE_NAME ) ;
160
+ exists = await IndexedDBCryptoStore . exists ( indexedDB , cryptoStoreName ( ) ) ;
149
161
log ( `Crypto store using IndexedDB contains data? ${ exists } ` ) ;
150
162
return { exists, healthy : true } ;
151
163
} catch ( e ) {
0 commit comments