Skip to content
This repository was archived by the owner on Sep 11, 2024. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions src/@types/worker-loader.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
/*
Copyright 2021 The Matrix.org Foundation C.I.C.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

declare module "*.worker.ts" {
class WebpackWorker extends Worker {
constructor();
}

export default WebpackWorker;
}
13 changes: 0 additions & 13 deletions src/MatrixClientPeg.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,15 +50,6 @@ export interface IMatrixClientCreds {
export interface IMatrixClientPeg {
opts: IStartClientOpts;

/**
* Sets the script href passed to the IndexedDB web worker
* If set, a separate web worker will be started to run the IndexedDB
* queries on.
*
* @param {string} script href to the script to be passed to the web worker
*/
setIndexedDbWorkerScript(script: string): void;

/**
* Return the server name of the user's homeserver
* Throws an error if unable to deduce the homeserver name
Expand Down Expand Up @@ -133,10 +124,6 @@ class _MatrixClientPeg implements IMatrixClientPeg {
constructor() {
}

public setIndexedDbWorkerScript(script: string): void {
createMatrixClient.indexedDbWorkerScript = script;
}

public get(): MatrixClient {
return this.matrixClient;
}
Expand Down
2 changes: 1 addition & 1 deletion src/components/views/dialogs/ShareDialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ import SettingsStore from "../../../settings/SettingsStore";
import { UIFeature } from "../../../settings/UIFeature";
import { replaceableComponent } from "../../../utils/replaceableComponent";
import BaseDialog from "./BaseDialog";
import GenericTextContextMenu from "../context_menus/GenericTextContextMenu.js";
import GenericTextContextMenu from "../context_menus/GenericTextContextMenu";

const socials = [
{
Expand Down
10 changes: 3 additions & 7 deletions src/utils/createMatrixClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ See the License for the specific language governing permissions and
limitations under the License.
*/

// @ts-ignore - `.ts` is needed here to make TS happy
import IndexedDBWorker from "../workers/indexeddb.worker.ts";
import { createClient, ICreateClientOpts } from "matrix-js-sdk/src/matrix";
import { IndexedDBCryptoStore } from "matrix-js-sdk/src/crypto/store/indexeddb-crypto-store";
import { WebStorageSessionStore } from "matrix-js-sdk/src/store/session/webstorage";
Expand All @@ -35,10 +37,6 @@ try {
* @param {Object} opts options to pass to Matrix.createClient. This will be
* extended with `sessionStore` and `store` members.
*
* @property {string} indexedDbWorkerScript Optional URL for a web worker script
* for IndexedDB store operations. By default, indexeddb ops are done on
* the main thread.
*
* @returns {MatrixClient} the newly-created MatrixClient
*/
export default function createMatrixClient(opts: ICreateClientOpts) {
Expand All @@ -51,7 +49,7 @@ export default function createMatrixClient(opts: ICreateClientOpts) {
indexedDB: indexedDB,
dbName: "riot-web-sync",
localStorage: localStorage,
workerScript: createMatrixClient.indexedDbWorkerScript,
workerFactory: () => new IndexedDBWorker(),
});
}

Expand All @@ -70,5 +68,3 @@ export default function createMatrixClient(opts: ICreateClientOpts) {
...opts,
});
}

createMatrixClient.indexedDbWorkerScript = null;
23 changes: 23 additions & 0 deletions src/workers/indexeddb.worker.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
/*
Copyright 2017 Vector Creations Ltd

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

import { IndexedDBStoreWorker } from "matrix-js-sdk/src/indexeddb-worker";

const ctx: Worker = self as any;

const remoteWorker = new IndexedDBStoreWorker(ctx.postMessage);

ctx.onmessage = remoteWorker.onMessage;