Skip to content

Commit a284c9c

Browse files
Merge pull request #110 from element-hq/midhun/multiroom/stores-api
Allow modules to access RLS from element-web
2 parents 734d8a9 + 0b38fa8 commit a284c9c

File tree

4 files changed

+55
-0
lines changed

4 files changed

+55
-0
lines changed

packages/element-web-module-api/element-web-module-api.api.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ export interface Api extends LegacyModuleApiExtension, LegacyCustomisationsApiEx
5454
readonly i18n: I18nApi;
5555
readonly navigation: NavigationApi;
5656
readonly rootNode: HTMLElement;
57+
readonly stores: StoresApi;
5758
}
5859

5960
// @alpha
@@ -337,6 +338,12 @@ export interface RoomListCustomisations<Room> {
337338
isRoomVisible?(room: Room): boolean;
338339
}
339340

341+
// @public
342+
export interface RoomListStoreApi {
343+
getRooms(): Watchable<Room[]>;
344+
waitForReady(): Promise<void>;
345+
}
346+
340347
// @alpha
341348
export interface RoomViewProps {
342349
roomId?: string;
@@ -355,6 +362,11 @@ export interface SpacePanelItemProps {
355362
tooltip?: string;
356363
}
357364

365+
// @public
366+
export interface StoresApi {
367+
roomListStore: RoomListStoreApi;
368+
}
369+
358370
// @public
359371
export type Translations = Record<string, {
360372
[ietfLanguageTag: string]: string;

packages/element-web-module-api/src/api/index.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import { AccountAuthApiExtension } from "./auth.ts";
1717
import { ProfileApiExtension } from "./profile.ts";
1818
import { ExtrasApi } from "./extras.ts";
1919
import { BuiltinsApi } from "./builtins.ts";
20+
import { StoresApi } from "./stores.ts";
2021
import { ClientApi } from "./client.ts";
2122

2223
/**
@@ -124,6 +125,11 @@ export interface Api
124125
*/
125126
readonly extras: ExtrasApi;
126127

128+
/**
129+
* Allows modules to access a limited functionality of certain stores from Element Web.
130+
*/
131+
readonly stores: StoresApi;
132+
127133
/**
128134
* Access some very specific functionality from the client.
129135
*/
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
/*
2+
Copyright 2025 New Vector Ltd.
3+
4+
SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Element-Commercial
5+
Please see LICENSE files in the repository root for full details.
6+
*/
7+
8+
import type { Room } from "../models/Room";
9+
import { Watchable } from "./watchable";
10+
11+
/**
12+
* Provides some basic functionality of the Room List Store from element-web.
13+
* @public
14+
*/
15+
export interface RoomListStoreApi {
16+
/**
17+
* Returns a watchable holding a flat list of sorted room.
18+
*/
19+
getRooms(): Watchable<Room[]>;
20+
21+
/**
22+
* Returns a promise that resolves when RLS is ready.
23+
*/
24+
waitForReady(): Promise<void>;
25+
}
26+
27+
/**
28+
* Provides access to certain stores from element-web.
29+
* @public
30+
*/
31+
export interface StoresApi {
32+
/**
33+
* Use this to access limited functionality of the RLS from element-web.
34+
*/
35+
roomListStore: RoomListStoreApi;
36+
}

packages/element-web-module-api/src/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,5 +20,6 @@ export type * from "./api/dialog";
2020
export type * from "./api/profile";
2121
export type * from "./api/navigation";
2222
export type * from "./api/builtins";
23+
export type * from "./api/stores";
2324
export type * from "./api/client";
2425
export * from "./api/watchable";

0 commit comments

Comments
 (0)