mirror of
https://github.com/Novaloop-AG/healthchat-web.git
synced 2026-11-07 06:58:25 +00:00
Room List - Implement a minimal view model (#29357)
* Implement enough of the new store to get a list of rooms * Make it possible to swap sorting algorithm * Don't attach to window object We don't want the store to be created if the labs flag is off * Remove the store class Probably best to include this PR with the minimal vm implmentation * Create a new room list store that wraps around the skip list * Create a minimal view model * Fix CI * Add some basic tests for the store * Write more tests * Add some jsdoc comments * Add more documentation * Add more docs
This commit is contained in:
@@ -7,26 +7,15 @@ Please see LICENSE files in the repository root for full details.
|
||||
|
||||
import { shuffle } from "lodash";
|
||||
|
||||
import type { MatrixClient, Room } from "matrix-js-sdk/src/matrix";
|
||||
import type { Room } from "matrix-js-sdk/src/matrix";
|
||||
import type { Sorter } from "../../../../../src/stores/room-list-v3/skip-list/sorters";
|
||||
import { mkMessage, mkStubRoom, stubClient } from "../../../../test-utils";
|
||||
import { mkMessage, stubClient } from "../../../../test-utils";
|
||||
import { RoomSkipList } from "../../../../../src/stores/room-list-v3/skip-list/RoomSkipList";
|
||||
import { RecencySorter } from "../../../../../src/stores/room-list-v3/skip-list/sorters/RecencySorter";
|
||||
import { AlphabeticSorter } from "../../../../../src/stores/room-list-v3/skip-list/sorters/AlphabeticSorter";
|
||||
import { getMockedRooms } from "./getMockedRooms";
|
||||
|
||||
describe("RoomSkipList", () => {
|
||||
function getMockedRooms(client: MatrixClient, roomCount: number = 100): Room[] {
|
||||
const rooms: Room[] = [];
|
||||
for (let i = 0; i < roomCount; ++i) {
|
||||
const roomId = `!foo${i}:matrix.org`;
|
||||
const room = mkStubRoom(roomId, `Foo Room ${i}`, client);
|
||||
const event = mkMessage({ room: roomId, user: `@foo${i}:matrix.org`, ts: i + 1, event: true });
|
||||
room.timeline.push(event);
|
||||
rooms.push(room);
|
||||
}
|
||||
return rooms;
|
||||
}
|
||||
|
||||
function generateSkipList(roomCount?: number): {
|
||||
skipList: RoomSkipList;
|
||||
rooms: Room[];
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
/*
|
||||
Copyright 2025 New Vector Ltd.
|
||||
|
||||
SPDX-License-Identifier: AGPL-3.0-only OR GPL-3.0-only OR LicenseRef-Element-Commercial
|
||||
Please see LICENSE files in the repository root for full details.
|
||||
*/
|
||||
|
||||
import type { MatrixClient, Room } from "matrix-js-sdk/src/matrix";
|
||||
import { mkMessage, mkStubRoom } from "../../../../test-utils";
|
||||
|
||||
export function getMockedRooms(client: MatrixClient, roomCount: number = 100): Room[] {
|
||||
const rooms: Room[] = [];
|
||||
for (let i = 0; i < roomCount; ++i) {
|
||||
const roomId = `!foo${i}:matrix.org`;
|
||||
const room = mkStubRoom(roomId, `Foo Room ${i}`, client);
|
||||
const event = mkMessage({ room: roomId, user: `@foo${i}:matrix.org`, ts: i + 1, event: true });
|
||||
room.timeline.push(event);
|
||||
rooms.push(room);
|
||||
}
|
||||
return rooms;
|
||||
}
|
||||
Reference in New Issue
Block a user