@@ -70,41 +70,25 @@ impl OlmMachine {
70
70
71
71
future_to_promise ( async move {
72
72
let store = match ( store_name, store_passphrase) {
73
- // We need this `#[cfg]` because `IndexeddbCryptoStore`
74
- // implements `CryptoStore` only on `target_arch =
75
- // "wasm32"`. Without that, we could have a compilation
76
- // error when checking the entire workspace. In
77
- // practise, it doesn't impact this crate because it's
78
- // always compiled for `wasm32`.
79
- #[ cfg( target_arch = "wasm32" ) ]
80
73
( Some ( store_name) , Some ( mut store_passphrase) ) => {
81
- use std:: sync:: Arc ;
82
-
83
74
use zeroize:: Zeroize ;
84
75
85
76
let store = Some (
86
77
matrix_sdk_indexeddb:: IndexeddbCryptoStore :: open_with_passphrase (
87
78
& store_name,
88
79
& store_passphrase,
89
80
)
90
- . await
91
- . map ( Arc :: new) ?,
81
+ . await ?,
92
82
) ;
93
83
94
84
store_passphrase. zeroize ( ) ;
95
85
96
86
store
97
87
}
98
88
99
- #[ cfg( target_arch = "wasm32" ) ]
100
- ( Some ( store_name) , None ) => {
101
- use std:: sync:: Arc ;
102
- Some (
103
- matrix_sdk_indexeddb:: IndexeddbCryptoStore :: open_with_name ( & store_name)
104
- . await
105
- . map ( Arc :: new) ?,
106
- )
107
- }
89
+ ( Some ( store_name) , None ) => Some (
90
+ matrix_sdk_indexeddb:: IndexeddbCryptoStore :: open_with_name ( & store_name) . await ?,
91
+ ) ,
108
92
109
93
( None , Some ( _) ) => {
110
94
return Err ( anyhow:: Error :: msg (
@@ -113,11 +97,18 @@ impl OlmMachine {
113
97
) )
114
98
}
115
99
116
- _ => None ,
100
+ ( None , None ) => None ,
117
101
} ;
118
102
119
103
Ok ( OlmMachine {
120
104
inner : match store {
105
+ // We need this `#[cfg]` because `IndexeddbCryptoStore`
106
+ // implements `CryptoStore` only on `target_arch =
107
+ // "wasm32"`. Without that, we could have a compilation
108
+ // error when checking the entire workspace. In practice,
109
+ // it doesn't impact this crate because it's always
110
+ // compiled for `wasm32`.
111
+ #[ cfg( target_arch = "wasm32" ) ]
121
112
Some ( store) => {
122
113
matrix_sdk_crypto:: OlmMachine :: with_store (
123
114
user_id. as_ref ( ) ,
@@ -126,7 +117,7 @@ impl OlmMachine {
126
117
)
127
118
. await ?
128
119
}
129
- None => {
120
+ _ => {
130
121
matrix_sdk_crypto:: OlmMachine :: new ( user_id. as_ref ( ) , device_id. as_ref ( ) )
131
122
. await
132
123
}
0 commit comments