Skip to content

Commit 4d28989

Browse files
committed
feat: force flat list on view model
This is an intermediary step before implementing sections in the vm. We force the flat list but we use the underneath the view supporting sections.
1 parent 874d3e9 commit 4d28989

1 file changed

Lines changed: 16 additions & 2 deletions

File tree

apps/web/src/viewmodels/room-list/RoomListViewViewModel.ts

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,8 @@ export class RoomListViewViewModel
6161
const roomsResult = RoomListStoreV3.instance.getSortedRoomsInActiveSpace(undefined);
6262
const canCreateRoom = hasCreateRoomRights(props.client, activeSpace);
6363
const filterIds = [...filterKeyToIdMap.values()];
64+
const roomIds = roomsResult.rooms.map((room) => room.roomId);
65+
const sections = [{ id: "all", roomIds }];
6466

6567
super(props, {
6668
// Initial view state - start with empty, will populate in async init
@@ -73,7 +75,9 @@ export class RoomListViewViewModel
7375
spaceId: roomsResult.spaceId,
7476
filterKeys: undefined,
7577
},
76-
roomIds: roomsResult.rooms.map((room) => room.roomId),
78+
// Until we implement sections, this view model only supports the flat list mode
79+
isFlatList: true,
80+
sections,
7781
canCreateRoom,
7882
});
7983

@@ -195,6 +199,15 @@ export class RoomListViewViewModel
195199
return viewModel;
196200
}
197201

202+
/**
203+
* Not implemented - this view model does not support sections.
204+
* Flat list mode is forced so this method is never be called.
205+
* @throw Error if called
206+
*/
207+
public getSectionViewModel(): never {
208+
throw new Error("Sections are not supported in this room list");
209+
}
210+
198211
/**
199212
* Update which rooms are currently visible.
200213
* Called by the view when scroll position changes.
@@ -408,6 +421,7 @@ export class RoomListViewViewModel
408421
// Build the complete state atomically to ensure consistency
409422
// roomIds and roomListState must always be in sync
410423
const roomIds = this.roomIds;
424+
const sections = [{ id: "all", roomIds }];
411425

412426
// Update filter keys - only update if they have actually changed to prevent unnecessary re-renders of the room list
413427
const previousFilterKeys = this.snapshot.current.roomListState.filterKeys;
@@ -428,7 +442,7 @@ export class RoomListViewViewModel
428442
isRoomListEmpty,
429443
activeFilterId,
430444
roomListState,
431-
roomIds,
445+
sections,
432446
});
433447
}
434448

0 commit comments

Comments
 (0)