@@ -18,8 +18,6 @@ See the License for the specific language governing permissions and
1818limitations under the License.
1919*/
2020
21- import olmWasmPath from 'olm/olm.wasm' ;
22-
2321import React from 'react' ;
2422// add React and ReactPerf to the global namespace, to make them easier to
2523// access via the console
@@ -44,10 +42,9 @@ import SettingsStore from "matrix-react-sdk/src/settings/SettingsStore";
4442import SdkConfig from "matrix-react-sdk/src/SdkConfig" ;
4543import { setTheme } from "matrix-react-sdk/src/theme" ;
4644
47- import Olm from 'olm' ;
48-
4945import CallHandler from 'matrix-react-sdk/src/CallHandler' ;
5046import { loadConfig , preparePlatform } from "./initial-load" ;
47+ import { loadOlm } from "./init" ;
5148
5249let lastLocationHashSet = null ;
5350
@@ -308,43 +305,6 @@ export async function loadApp() {
308305 }
309306}
310307
311- function loadOlm ( ) {
312- /* Load Olm. We try the WebAssembly version first, and then the legacy,
313- * asm.js version if that fails. For this reason we need to wait for this
314- * to finish before continuing to load the rest of the app. In future
315- * we could somehow pass a promise down to react-sdk and have it wait on
316- * that so olm can be loading in parallel with the rest of the app.
317- *
318- * We also need to tell the Olm js to look for its wasm file at the same
319- * level as index.html. It really should be in the same place as the js,
320- * ie. in the bundle directory, but as far as I can tell this is
321- * completely impossible with webpack. We do, however, use a hashed
322- * filename to avoid caching issues.
323- */
324- return Olm . init ( {
325- locateFile : ( ) => olmWasmPath ,
326- } ) . then ( ( ) => {
327- console . log ( "Using WebAssembly Olm" ) ;
328- } ) . catch ( ( e ) => {
329- console . log ( "Failed to load Olm: trying legacy version" , e ) ;
330- return new Promise ( ( resolve , reject ) => {
331- const s = document . createElement ( 'script' ) ;
332- s . src = 'olm_legacy.js' ; // XXX: This should be cache-busted too
333- s . onload = resolve ;
334- s . onerror = reject ;
335- document . body . appendChild ( s ) ;
336- } ) . then ( ( ) => {
337- // Init window.Olm, ie. the one just loaded by the script tag,
338- // not 'Olm' which is still the failed wasm version.
339- return window . Olm . init ( ) ;
340- } ) . then ( ( ) => {
341- console . log ( "Using legacy Olm" ) ;
342- } ) . catch ( ( e ) => {
343- console . log ( "Both WebAssembly and asm.js Olm failed!" , e ) ;
344- } ) ;
345- } ) ;
346- }
347-
348308async function loadLanguage ( ) {
349309 const prefLang = SettingsStore . getValue ( "language" , null , /*excludeDefault=*/ true ) ;
350310 let langs = [ ] ;
0 commit comments