mirror of
https://github.com/vector-im/element-web.git
synced 2024-11-16 13:14:58 +08:00
Improve performance of tag panel selection (when tags are selected)
Deselecting all tags is now slightly less performant than selecting a tag but mostly due to the number of RoomTiles being rendered. Swapping between different tags (a supposed common use-case) feels much more spritely!
This commit is contained in:
parent
63335f70e5
commit
5c5307c665
@ -311,11 +311,6 @@ module.exports = React.createClass({
|
||||
});
|
||||
},
|
||||
|
||||
isRoomInSelectedTags: function(room) {
|
||||
// No selected tags = every room is visible in the list
|
||||
return this.state.selectedTags.length === 0 || this._visibleRooms.includes(room.roomId);
|
||||
},
|
||||
|
||||
refreshRoomList: function() {
|
||||
// TODO: ideally we'd calculate this once at start, and then maintain
|
||||
// any changes to it incrementally, updating the appropriate sublists
|
||||
@ -344,7 +339,26 @@ module.exports = React.createClass({
|
||||
lists["im.vector.fake.archived"] = [];
|
||||
|
||||
const dmRoomMap = DMRoomMap.shared();
|
||||
MatrixClientPeg.get().getRooms().forEach((room) => {
|
||||
|
||||
// If there are any tags selected, constrain the rooms listed to the
|
||||
// visible rooms as determined by this._visibleRooms. Here, we
|
||||
// de-duplicate and filter out rooms that the client doesn't know
|
||||
// about (hence the Set and the null-guard on `room`).
|
||||
let rooms = [];
|
||||
if (this.state.selectedTags.length > 0) {
|
||||
const roomSet = new Set();
|
||||
this._visibleRooms.forEach((roomId) => {
|
||||
const room = MatrixClientPeg.get().getRoom(roomId);
|
||||
if (room) {
|
||||
roomSet.add(room);
|
||||
}
|
||||
});
|
||||
rooms = Array.from(roomSet);
|
||||
} else {
|
||||
rooms = MatrixClientPeg.get().getRooms();
|
||||
}
|
||||
|
||||
rooms.forEach((room, index) => {
|
||||
const me = room.getMember(MatrixClientPeg.get().credentials.userId);
|
||||
if (!me) return;
|
||||
|
||||
@ -362,11 +376,6 @@ module.exports = React.createClass({
|
||||
// Used to split rooms via tags
|
||||
const tagNames = Object.keys(room.tags);
|
||||
|
||||
// Apply TagPanel filtering, derived from FilterStore
|
||||
if (!this.isRoomInSelectedTags(room)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (tagNames.length) {
|
||||
for (let i = 0; i < tagNames.length; i++) {
|
||||
const tagName = tagNames[i];
|
||||
|
Loading…
Reference in New Issue
Block a user