fix(room list): fix visible-range reporting to the room list view model (#34112)
Virtuoso's rangeChanged was forwarded to updateVisibleRooms unmapped: - In grouped mode the range is in entry space (one slot per section header), while updateVisibleRooms slices the rooms-only array. The retained window was shifted down by the number of headers above it, so the view models of the top rendered rooms were disposed and recreated on every range change. - Virtuoso's endIndex is inclusive but slice() is end-exclusive, so the boundary row's view model was disposed and recreated on nearly every range change.
This commit is contained in:
@@ -332,10 +332,13 @@ export class RoomListViewModel
|
||||
* Update which rooms are currently visible.
|
||||
* Called by the view when scroll position changes.
|
||||
* Disposes of view models for rooms no longer visible.
|
||||
*
|
||||
* Indices are in room-index space (section header entries excluded):
|
||||
* startIndex is inclusive, endIndex is exclusive.
|
||||
*/
|
||||
public updateVisibleRooms(startIndex: number, endIndex: number): void {
|
||||
const allRoomIds = this.roomIds;
|
||||
const newVisibleIds = allRoomIds.slice(startIndex, Math.min(endIndex, allRoomIds.length));
|
||||
const newVisibleIds = allRoomIds.slice(startIndex, endIndex);
|
||||
|
||||
const newVisibleSet = new Set(newVisibleIds);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user