diff --git a/src/plugins/utils.js b/src/plugins/utils.js index ba866ab..5439ba4 100644 --- a/src/plugins/utils.js +++ b/src/plugins/utils.js @@ -188,7 +188,7 @@ class Util { Promise.all(setAsKnownPromises) .then(() => { // All devices now marked as "known", try to resend - matrixClient.resendEvent(err.event) + matrixClient.resendEvent(err.event, matrixClient.getRoom(err.event.getRoomId())) .then((result) => { console.log("Message sent: ", result); resolve(true); diff --git a/src/services/matrix.service.js b/src/services/matrix.service.js index 05ec052..27f8f9f 100644 --- a/src/services/matrix.service.js +++ b/src/services/matrix.service.js @@ -114,13 +114,34 @@ export default { }) }, + clearCryptoStore() { + // Clear crypto related data + // TODO - for some reason "clearStores" called in "logout" only clears the "account" crypto + // data item, not all sessions etc. Why? We need to do that manually here! + const toRemove = []; + for (let i = 0; i < localStorage.length; ++i) { + const key = localStorage.key(i); + if (key.startsWith("crypto.")) toRemove.push(key); + } + for (const key of toRemove) { + localStorage.removeItem(key); + } + }, + logout() { if (this.matrixClient) { this.removeMatrixClientListeners(this.matrixClient); this.matrixClient.stopClient(); + this.matrixClient.clearStores().then(() => { + this.clearCryptoStore() + }) this.matrixClient = null; this.matrixClientReady = false; + } else { + this.clearCryptoStore(); } + + localStorage.removeItem('user'); this.$store.commit("setCurrentRoomId", null); },