Fix "first message does not send"

Issue #55
This commit is contained in:
N-Pex 2021-03-01 13:06:46 +01:00
parent 3b3e21b8da
commit 929b81d4b4
2 changed files with 22 additions and 1 deletions

View file

@ -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);

View file

@ -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);
},