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
Add MatrixClient.clearStores
- to clear both sets of storage on logout
This commit is contained in:
@@ -156,8 +156,9 @@ function MatrixClient(opts) {
|
||||
this._notifTimelineSet = null;
|
||||
|
||||
this._crypto = null;
|
||||
this._cryptoStore = opts.cryptoStore;
|
||||
if (CRYPTO_ENABLED && Boolean(opts.sessionStore) &&
|
||||
Boolean(opts.cryptoStore) &&
|
||||
Boolean(this._cryptoStore) &&
|
||||
userId !== null && this.deviceId !== null) {
|
||||
this._crypto = new Crypto(
|
||||
this, this,
|
||||
@@ -173,6 +174,25 @@ function MatrixClient(opts) {
|
||||
utils.inherits(MatrixClient, EventEmitter);
|
||||
utils.extend(MatrixClient.prototype, MatrixBaseApis.prototype);
|
||||
|
||||
/**
|
||||
* Clear any data out of the persistent stores used by the client.
|
||||
*
|
||||
* @returns {Promise} Promise which resolves when the stores have been cleared.
|
||||
*/
|
||||
MatrixClient.prototype.clearStores = function() {
|
||||
if (this._clientRunning) {
|
||||
throw new Error("Cannot clear stores while client is running");
|
||||
}
|
||||
|
||||
const promises = [];
|
||||
|
||||
promises.push(this.store.deleteAllData());
|
||||
if (this._cryptoStore) {
|
||||
promises.push(this._cryptoStore.deleteAllData());
|
||||
}
|
||||
return q.all(promises);
|
||||
};
|
||||
|
||||
/**
|
||||
* Get the user-id of the logged-in user
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user