update to use the modern crypto store and session store implementation

This commit is contained in:
Gigiaj 2025-06-20 16:13:44 -05:00
parent b1793832a3
commit 9095d3b479

View file

@ -1,30 +1,25 @@
import { createClient, MatrixClient, IndexedDBStore, IndexedDBCryptoStore } from 'matrix-js-sdk'; import { createClient, MatrixClient, IndexedDBStore, IndexedDBCryptoStore } from 'matrix-js-sdk';
import { cryptoCallbacks } from './state/secretStorageKeys'; import { cryptoCallbacks } from './state/secretStorageKeys';
import { clearNavToActivePathStore } from '../app/state/navToActivePath'; import { clearNavToActivePathStore } from '../app/state/navToActivePath';
import { Session, getSessionStoreName } from '../app/state/sessions';
type Session = {
baseUrl: string;
accessToken: string;
userId: string;
deviceId: string;
};
export const initClient = async (session: Session): Promise<MatrixClient> => { export const initClient = async (session: Session): Promise<MatrixClient> => {
const storeName = getSessionStoreName(session);
const indexedDBStore = new IndexedDBStore({ const indexedDBStore = new IndexedDBStore({
indexedDB: global.indexedDB, indexedDB: global.indexedDB,
localStorage: global.localStorage, localStorage: global.localStorage,
dbName: 'web-sync-store', dbName: storeName.sync,
}); });
const legacyCryptoStore = new IndexedDBCryptoStore(global.indexedDB, 'crypto-store'); const cryptoStore = new IndexedDBCryptoStore(global.indexedDB, storeName.crypto); // 4. USE THE DYNAMIC NAME
const mx = createClient({ const mx = createClient({
baseUrl: session.baseUrl, baseUrl: session.baseUrl,
accessToken: session.accessToken, accessToken: session.accessToken,
userId: session.userId, userId: session.userId,
store: indexedDBStore, store: indexedDBStore,
cryptoStore: legacyCryptoStore, cryptoStore,
deviceId: session.deviceId, deviceId: session.deviceId,
timelineSupport: true, timelineSupport: true,
cryptoCallbacks: cryptoCallbacks as any, cryptoCallbacks: cryptoCallbacks as any,