Signed-off-by: Šimon Brandner <simon.bra.ag@gmail.com>
This commit is contained in:
Šimon Brandner 2022-10-26 10:47:44 +02:00
commit fcaa126147
No known key found for this signature in database
GPG key ID: D1D45825D60C24D2
7 changed files with 2105 additions and 81 deletions

View file

@ -14,7 +14,9 @@ See the License for the specific language governing permissions and
limitations under the License.
*/
import React, { Suspense } from "react";
import Olm from "@matrix-org/olm";
import olmWasmPath from "@matrix-org/olm/olm.wasm?url";
import React, { Suspense, useState } from "react";
import { BrowserRouter as Router, Switch, Route } from "react-router-dom";
import * as Sentry from "@sentry/react";
import { OverlayProvider } from "@react-aria/overlays";
@ -28,7 +30,7 @@ import { ClientProvider } from "./ClientContext";
import { usePageFocusStyle } from "./usePageFocusStyle";
import { SequenceDiagramViewerPage } from "./SequenceDiagramViewerPage";
import { InspectorContextProvider } from "./room/GroupCallInspector";
import { CrashView } from "./FullScreenView";
import { CrashView, LoadingView } from "./FullScreenView";
const SentryRoute = Sentry.withSentryRouting(Route);
@ -37,10 +39,20 @@ interface AppProps {
}
export default function App({ history }: AppProps) {
const [loadingOlm, setLoadingOlm] = useState(false);
usePageFocusStyle();
// TODO: https://gitlab.matrix.org/matrix-org/olm/-/issues/10
window.OLM_OPTIONS = {};
Olm.init({ locateFile: () => olmWasmPath }).then(() => setLoadingOlm(false));
const errorPage = <CrashView />;
if (loadingOlm) {
return <LoadingView />;
}
return (
<Router history={history}>
<Suspense fallback={null}>

View file

@ -1,5 +1,3 @@
import Olm from "@matrix-org/olm";
import olmWasmPath from "@matrix-org/olm/olm.wasm?url";
import { IndexedDBStore } from "matrix-js-sdk/src/store/indexeddb";
import { MemoryStore } from "matrix-js-sdk/src/store/memory";
import { IndexedDBCryptoStore } from "matrix-js-sdk/src/crypto/store/indexeddb-crypto-store";
@ -72,10 +70,6 @@ export async function initClient(
clientOptions: ICreateClientOpts,
restore: boolean
): Promise<MatrixClient> {
// TODO: https://gitlab.matrix.org/matrix-org/olm/-/issues/10
window.OLM_OPTIONS = {};
await Olm.init({ locateFile: () => olmWasmPath });
let indexedDB: IDBFactory;
try {