1
0
mirror of https://github.com/matrix-org/matrix-js-sdk.git synced 2025-11-28 05:03:59 +03:00

check if lazy loading was enabled before in startClient

This commit is contained in:
Bruno Windels
2018-09-25 15:32:10 +01:00
parent 76175abea2
commit 28184b4a29

View File

@@ -3115,7 +3115,16 @@ MatrixClient.prototype.startClient = async function(opts) {
opts.lazyLoadMembers = false;
}
}
// need to vape the store when enabling LL and wasn't enabled before
let hadLLEnabledBefore = false;
const prevClientOptions = await this.store.getClientOptions();
if (prevClientOptions) {
hadLLEnabledBefore = !!prevClientOptions.lazyLoadMembers;
}
if (!hadLLEnabledBefore && opts.lazyLoadMembers) {
await this.store.deleteAllData();
throw new Error("vaped the store, you need to resync");
}
if (opts.lazyLoadMembers && this._crypto) {
this._crypto.enableLazyLoading();
}
@@ -3128,6 +3137,7 @@ MatrixClient.prototype.startClient = async function(opts) {
return this._canResetTimelineCallback(roomId);
};
this._clientOpts = opts;
await this.store.storeClientOptions(this._clientOpts);
this._syncApi = new SyncApi(this, opts);
this._syncApi.sync();