Remove unused sessionStorage layer (#8834)

* Remove unused sessionStorage layer

* Update global.d.ts

* Fix tests
This commit is contained in:
Michael Telatynski 2022-06-14 21:29:24 +01:00 committed by GitHub
parent 7da8c51c6b
commit d81e2cea14
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 21 additions and 78 deletions

View file

@ -13,10 +13,16 @@ 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 { createClient, ICreateClientOpts } from "matrix-js-sdk/src/matrix";
import {
MatrixClient,
createClient,
ICreateClientOpts,
MemoryCryptoStore,
MemoryStore,
} 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";
import { IndexedDBStore } from "matrix-js-sdk/src/store/indexeddb";
import { LocalStorageCryptoStore } from "matrix-js-sdk/src/crypto/store/localStorage-crypto-store";
// @ts-ignore - `.ts` is needed here to make TS happy
import IndexedDBWorker from "../workers/indexeddb.worker.ts";
@ -39,7 +45,7 @@ try {
*
* @returns {MatrixClient} the newly-created MatrixClient
*/
export default function createMatrixClient(opts: ICreateClientOpts) {
export default function createMatrixClient(opts: ICreateClientOpts): MatrixClient {
const storeOpts: Partial<ICreateClientOpts> = {
useAuthorizationHeader: true,
};
@ -48,19 +54,21 @@ export default function createMatrixClient(opts: ICreateClientOpts) {
storeOpts.store = new IndexedDBStore({
indexedDB: indexedDB,
dbName: "riot-web-sync",
localStorage: localStorage,
localStorage,
workerFactory: () => new IndexedDBWorker(),
});
}
if (localStorage) {
storeOpts.sessionStore = new WebStorageSessionStore(localStorage);
} else if (localStorage) {
storeOpts.store = new MemoryStore({ localStorage });
}
if (indexedDB) {
storeOpts.cryptoStore = new IndexedDBCryptoStore(
indexedDB, "matrix-js-sdk:crypto",
);
} else if (localStorage) {
storeOpts.cryptoStore = new LocalStorageCryptoStore(localStorage);
} else {
storeOpts.cryptoStore = new MemoryCryptoStore();
}
return createClient({