Use the most recent version of the room in breadcrumbs
Fixes https://github.com/vector-im/riot-web/issues/8662
This commit is contained in:
parent
37afa9fc0e
commit
68fc04d9f6
1 changed files with 22 additions and 7 deletions
|
@ -77,9 +77,9 @@ export default class RoomBreadcrumbs extends React.Component {
|
||||||
const rooms = this.state.rooms.slice();
|
const rooms = this.state.rooms.slice();
|
||||||
|
|
||||||
if (rooms.length) {
|
if (rooms.length) {
|
||||||
const {room, animated} = rooms[0];
|
const roomModel = rooms[0];
|
||||||
if (!animated) {
|
if (!roomModel.animated) {
|
||||||
rooms[0] = {room, animated: true};
|
roomModel.animated = true;
|
||||||
setTimeout(() => this.setState({rooms}), 0);
|
setTimeout(() => this.setState({rooms}), 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -159,16 +159,31 @@ export default class RoomBreadcrumbs extends React.Component {
|
||||||
}
|
}
|
||||||
|
|
||||||
_appendRoomId(roomId) {
|
_appendRoomId(roomId) {
|
||||||
const room = MatrixClientPeg.get().getRoom(roomId);
|
let room = MatrixClientPeg.get().getRoom(roomId);
|
||||||
if (!room) {
|
if (!room) return;
|
||||||
return;
|
|
||||||
}
|
|
||||||
const rooms = this.state.rooms.slice();
|
const rooms = this.state.rooms.slice();
|
||||||
|
|
||||||
|
// If the room is upgraded, use that room instead. We'll also splice out
|
||||||
|
// any children of the room.
|
||||||
|
const history = MatrixClientPeg.get().getRoomUpgradeHistory(roomId);
|
||||||
|
if (history.length > 1) {
|
||||||
|
room = history[history.length - 1]; // Last room is most recent
|
||||||
|
|
||||||
|
// Take out any room that isn't the most recent room
|
||||||
|
for (let i = 0; i < history.length - 1; i++) {
|
||||||
|
const idx = rooms.findIndex((r) => r.room.roomId === history[i].roomId);
|
||||||
|
if (idx !== -1) rooms.splice(idx, 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
const existingIdx = rooms.findIndex((r) => r.room.roomId === room.roomId);
|
const existingIdx = rooms.findIndex((r) => r.room.roomId === room.roomId);
|
||||||
if (existingIdx !== -1) {
|
if (existingIdx !== -1) {
|
||||||
rooms.splice(existingIdx, 1);
|
rooms.splice(existingIdx, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
rooms.splice(0, 0, {room, animated: false});
|
rooms.splice(0, 0, {room, animated: false});
|
||||||
|
|
||||||
if (rooms.length > MAX_ROOMS) {
|
if (rooms.length > MAX_ROOMS) {
|
||||||
rooms.splice(MAX_ROOMS, rooms.length - MAX_ROOMS);
|
rooms.splice(MAX_ROOMS, rooms.length - MAX_ROOMS);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue