@@ -196,6 +196,7 @@ export abstract class WidgetDriver {
196196 * the client will return all the events.
197197 * @param eventType The event type to be read.
198198 * @param msgtype The msgtype of the events to be read, if applicable/defined.
199+ * @param stateKey The state key of the events to be read, if applicable/defined.
199200 * @param limit The maximum number of events to retrieve per room. Will be zero to denote "as many
200201 * as possible".
201202 * @param roomIds When null, the user's currently viewed room. Otherwise, the list of room IDs
@@ -204,6 +205,7 @@ export abstract class WidgetDriver {
204205 * Otherwise, the event ID at which only subsequent events will be returned, as many as specified
205206 * in "limit".
206207 * @returns {Promise<IRoomEvent[]> } Resolves to the room events, or an empty array.
208+ * @deprecated Clients are advised to implement {@link WidgetDriver.readRoomTimeline} instead.
207209 */
208210 public readRoomEvents (
209211 eventType : string ,
@@ -229,6 +231,7 @@ export abstract class WidgetDriver {
229231 * @param roomIds When null, the user's currently viewed room. Otherwise, the list of room IDs
230232 * to look within, possibly containing Symbols.AnyRoom to denote all known rooms.
231233 * @returns {Promise<IRoomEvent[]> } Resolves to the state events, or an empty array.
234+ * @deprecated Clients are advised to implement {@link WidgetDriver.readRoomTimeline} instead.
232235 */
233236 public readStateEvents (
234237 eventType : string ,
@@ -239,6 +242,46 @@ export abstract class WidgetDriver {
239242 return Promise . resolve ( [ ] ) ;
240243 }
241244
245+ /**
246+ * Reads all events of the given type, and optionally `msgtype` (if applicable/defined),
247+ * the user has access to. The widget API will have already verified that the widget is
248+ * capable of receiving the events. Less events than the limit are allowed to be returned,
249+ * but not more. If `roomIds` is supplied, it may contain `Symbols.AnyRoom` to denote that
250+ * `limit` in each of the client's known rooms should be returned. When `null`, only the
251+ * room the user is currently looking at should be considered. If `since` is specified but
252+ * the event ID isn't present in the number of events fetched by the client due to `limit`,
253+ * the client will return all the events.
254+ * @param roomId The ID of the room to look within.
255+ * @param eventType The event type to be read.
256+ * @param msgtype The msgtype of the events to be read, if applicable/defined.
257+ * @param stateKey The state key of the events to be read, if applicable/defined.
258+ * @param limit The maximum number of events to retrieve per room. Will be zero to denote "as many
259+ * as possible".
260+ * @param since When null, retrieves the number of events specified by the "limit" parameter.
261+ * Otherwise, the event ID at which only subsequent events will be returned, as many as specified
262+ * in "limit".
263+ * @returns {Promise<IRoomEvent[]> } Resolves to the room events, or an empty array.
264+ */
265+ public readRoomTimeline (
266+ roomId : string ,
267+ eventType : string ,
268+ msgtype : string | undefined ,
269+ stateKey : string | undefined ,
270+ limit : number ,
271+ since : string | undefined ,
272+ ) : Promise < IRoomEvent [ ] > {
273+ if ( stateKey === undefined ) return this . readRoomEvents ( eventType , msgtype , limit , [ roomId ] , since ) ;
274+ else return this . readStateEvents ( eventType , stateKey , limit , [ roomId ] ) ;
275+ }
276+
277+ public readRoomState (
278+ roomId : string ,
279+ eventType : string ,
280+ stateKey : string | undefined ,
281+ ) : Promise < IRoomEvent [ ] > {
282+ return Promise . resolve ( [ ] ) ;
283+ }
284+
242285 /**
243286 * Reads all events that are related to a given event. The widget API will
244287 * have already verified that the widget is capable of receiving the event,
@@ -360,6 +403,15 @@ export abstract class WidgetDriver {
360403 throw new Error ( "Download file is not implemented" ) ;
361404 }
362405
406+ /**
407+ * Gets the IDs of all joined or invited rooms currently known to the
408+ * client.
409+ * @returns The room IDs.
410+ */
411+ public getKnownRooms ( ) : string [ ] {
412+ throw new Error ( "Querying known rooms is not implemented" ) ;
413+ }
414+
363415 /**
364416 * Expresses an error thrown by this driver in a format compatible with the Widget API.
365417 * @param error The error to handle.
0 commit comments