Skip to content

Commit 95e4f7d

Browse files
committed
fixes for reading room state
1 parent 70326db commit 95e4f7d

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

src/ClientWidgetApi.ts

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -520,14 +520,21 @@ export class ClientWidgetApi extends EventEmitter {
520520
// letting us know the currently viewed room via setViewedRoomId
521521
const events = request.data.room_ids === undefined && askRoomIds.length === 0
522522
? await (
523+
// This returns [] with the current driver of Element Web.
524+
// Add default implementations of the `readRoomEvents` and `readStateEvents`
525+
// methods to use `readRoomTimeline` and `readRoomState` if they are not overwritten.
523526
request.data.state_key === undefined
524527
? this.driver.readRoomEvents(request.data.type, msgtype, limit, null, since)
525528
: this.driver.readStateEvents(request.data.type, stateKey, limit, null)
526529
)
527530
: (
528-
await Promise.all(askRoomIds.map(roomId =>
529-
this.driver.readRoomTimeline(roomId, request.data.type, msgtype, stateKey, limit, since),
530-
))
531+
request.data.state_key === undefined
532+
? await Promise.all(askRoomIds.map(roomId =>
533+
this.driver.readRoomTimeline(roomId, request.data.type, msgtype, stateKey, limit, since),
534+
))
535+
: await Promise.all(askRoomIds.map(roomId =>
536+
this.driver.readRoomState(roomId, request.data.type, stateKey),
537+
))
531538
).flat(1);
532539
this.transport.reply<IReadEventFromWidgetResponseData>(request, { events });
533540
}

0 commit comments

Comments
 (0)