Fix room not loaded when joining
This commit is contained in:
parent
29acde8604
commit
0e8039f02d
2 changed files with 21 additions and 5 deletions
|
|
@ -50,7 +50,7 @@ export default {
|
||||||
return this.$matrix.matrixClient.joinRoom(this.roomId);
|
return this.$matrix.matrixClient.joinRoom(this.roomId);
|
||||||
})
|
})
|
||||||
.then((room) => {
|
.then((room) => {
|
||||||
this.$matrix.setCurrentRoomId(room.roomId);
|
this.$matrix.setCurrentRoom(room);
|
||||||
this.loading = false;
|
this.loading = false;
|
||||||
this.loadingMessage = null;
|
this.loadingMessage = null;
|
||||||
this.$router.replace({ name: "Chat" });
|
this.$router.replace({ name: "Chat" });
|
||||||
|
|
|
||||||
|
|
@ -176,12 +176,14 @@ export default {
|
||||||
addMatrixClientListeners(client) {
|
addMatrixClientListeners(client) {
|
||||||
if (client) {
|
if (client) {
|
||||||
client.on("event", this.onEvent);
|
client.on("event", this.onEvent);
|
||||||
|
client.on("Room", this.onRoom);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
removeMatrixClientListeners(client) {
|
removeMatrixClientListeners(client) {
|
||||||
if (client) {
|
if (client) {
|
||||||
client.off("event", this.onEvent);
|
client.off("event", this.onEvent);
|
||||||
|
client.off("Room", this.onRoom);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
@ -205,6 +207,10 @@ export default {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
onRoom(ignoredroom) {
|
||||||
|
this.reloadRooms();
|
||||||
|
},
|
||||||
|
|
||||||
reloadRooms() {
|
reloadRooms() {
|
||||||
this.rooms = this.matrixClient.getVisibleRooms();
|
this.rooms = this.matrixClient.getVisibleRooms();
|
||||||
this.rooms.forEach(room => {
|
this.rooms.forEach(room => {
|
||||||
|
|
@ -212,15 +218,25 @@ export default {
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
|
setCurrentRoom(room) {
|
||||||
|
// If we don't know about this room yet (e.g. we just joined)
|
||||||
|
// add it to our list.
|
||||||
|
if (!this.getRoom(room.roomId)) {
|
||||||
|
this.rooms.push(room);
|
||||||
|
}
|
||||||
|
this.setCurrentRoomId(room.roomId);
|
||||||
|
},
|
||||||
|
|
||||||
setCurrentRoomId(roomId) {
|
setCurrentRoomId(roomId) {
|
||||||
this.$store.commit("setCurrentRoomId", roomId);
|
this.$store.commit("setCurrentRoomId", roomId);
|
||||||
},
|
},
|
||||||
|
|
||||||
getRoom(roomId) {
|
getRoom(roomId) {
|
||||||
// if (this.matrixClient) {
|
var room = this.rooms.find(room => room.roomId == roomId);
|
||||||
// return this.matrixClient.getRoom(roomId);
|
if (!room && this.matrixClient) {
|
||||||
// }
|
room = this.matrixClient.getRoom(roomId);
|
||||||
return this.rooms.find(room => room.roomId == roomId);
|
}
|
||||||
|
return room;
|
||||||
},
|
},
|
||||||
|
|
||||||
on(event, handler) {
|
on(event, handler) {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue