1
0
mirror of https://github.com/matrix-org/matrix-js-sdk.git synced 2025-11-26 17:03:12 +03:00

Ensure setUserCreator is called when a store is assigned (#3867)

* Add method to set store

* Use not null assertion

* Use getter/setter

* No need for check if we use setter
This commit is contained in:
R Midhun Suresh
2023-11-11 12:50:36 +05:30
committed by GitHub
parent 9efc0acb9d
commit 882dc920c3

View File

@@ -1217,7 +1217,7 @@ export class MatrixClient extends TypedEventEmitter<EmittedEvents, ClientEventHa
public reEmitter = new TypedReEmitter<EmittedEvents, ClientEventHandlerMap>(this); public reEmitter = new TypedReEmitter<EmittedEvents, ClientEventHandlerMap>(this);
public olmVersion: [number, number, number] | null = null; // populated after initCrypto public olmVersion: [number, number, number] | null = null; // populated after initCrypto
public usingExternalCrypto = false; public usingExternalCrypto = false;
public store: Store; private _store!: Store;
public deviceId: string | null; public deviceId: string | null;
public credentials: { userId: string | null }; public credentials: { userId: string | null };
@@ -1332,7 +1332,6 @@ export class MatrixClient extends TypedEventEmitter<EmittedEvents, ClientEventHa
this.usingExternalCrypto = opts.usingExternalCrypto ?? false; this.usingExternalCrypto = opts.usingExternalCrypto ?? false;
this.store = opts.store || new StubStore(); this.store = opts.store || new StubStore();
this.store.setUserCreator((userId) => User.createUser(userId, this));
this.deviceId = opts.deviceId || null; this.deviceId = opts.deviceId || null;
this.sessionId = randomString(10); this.sessionId = randomString(10);
@@ -1497,6 +1496,15 @@ export class MatrixClient extends TypedEventEmitter<EmittedEvents, ClientEventHa
this._secretStorage = new ServerSideSecretStorageImpl(this, opts.cryptoCallbacks ?? {}); this._secretStorage = new ServerSideSecretStorageImpl(this, opts.cryptoCallbacks ?? {});
} }
public set store(newStore: Store) {
this._store = newStore;
this._store.setUserCreator((userId) => User.createUser(userId, this));
}
public get store(): Store {
return this._store;
}
/** /**
* High level helper method to begin syncing and poll for new events. To listen for these * High level helper method to begin syncing and poll for new events. To listen for these
* events, add a listener for {@link ClientEvent.Event} * events, add a listener for {@link ClientEvent.Event}