You've already forked matrix-js-sdk
mirror of
https://github.com/matrix-org/matrix-js-sdk.git
synced 2025-11-28 05:03:59 +03:00
dont clear the store if its a brand new one
This commit is contained in:
@@ -3116,14 +3116,12 @@ MatrixClient.prototype.startClient = async function(opts) {
|
||||
}
|
||||
}
|
||||
// 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) {
|
||||
const shouldClear = await this._shouldClearSyncDataIfLL();
|
||||
if (shouldClear) {
|
||||
await this.store.deleteAllData();
|
||||
throw new Error("vaped the store, you need to resync");
|
||||
}
|
||||
}
|
||||
if (opts.lazyLoadMembers && this._crypto) {
|
||||
this._crypto.enableLazyLoading();
|
||||
@@ -3143,6 +3141,22 @@ MatrixClient.prototype.startClient = async function(opts) {
|
||||
this._syncApi.sync();
|
||||
};
|
||||
|
||||
/** @return {bool} need to clear the store when enabling LL and wasn't enabled before? */
|
||||
MatrixClient.prototype._shouldClearSyncDataIfLL = async function() {
|
||||
let hadLLEnabledBefore = false;
|
||||
const isStoreNewlyCreated = await this.store.isNewlyCreated();
|
||||
if (!isStoreNewlyCreated) {
|
||||
const prevClientOptions = await this.store.getClientOptions();
|
||||
if (prevClientOptions) {
|
||||
hadLLEnabledBefore = !!prevClientOptions.lazyLoadMembers;
|
||||
}
|
||||
if (!hadLLEnabledBefore) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
};
|
||||
|
||||
/**
|
||||
* High level helper method to stop the client from polling and allow a
|
||||
* clean shutdown.
|
||||
|
||||
Reference in New Issue
Block a user