perf(room list): clear room list item vm only when changing space

Clearing all the item vms at every room list change is causing massive
re-render of all the room list items. References to the vms are already
removed when out of view (see RoomListViewMode.updateVisibleRooms) and
handled by GC.
This commit is contained in:
Florian Duros 2026-02-27 10:49:26 +01:00
parent 3fb99fee26
commit 24dc90cc09
No known key found for this signature in database
GPG Key ID: A5BBB4041B493F15

View File

@ -133,9 +133,6 @@ export class RoomListViewViewModel
// Update roomsMap immediately before clearing VMs
this.updateRoomsMap(this.roomsResult);
// Clear view models since room list changed
this.clearViewModels();
this.updateRoomListData();
};
@ -291,11 +288,13 @@ export class RoomListViewViewModel
const newSpaceId = this.roomsResult.spaceId;
// Clear view models since room list structure changed
this.clearViewModels();
// Detect space change
if (oldSpaceId !== newSpaceId) {
// Clear view models when the space changes
// We only want to do this on space changes, not on regular list updates, to preserve view models when possible
// The view models are disposed when scrolling out of view (handled by updateVisibleRooms)
this.clearViewModels();
// Space changed - get the last selected room for the new space to prevent flicker
const lastSelectedRoom = SpaceStore.instance.getLastSelectedRoomIdForSpace(newSpaceId);