diff --git a/src/components/views/rooms/PinnedEventTile.tsx b/src/components/views/rooms/PinnedEventTile.tsx index 2874256540..3aa3677a25 100644 --- a/src/components/views/rooms/PinnedEventTile.tsx +++ b/src/components/views/rooms/PinnedEventTile.tsx @@ -80,18 +80,22 @@ export default class PinnedEventTile extends React.Component { await Promise.all( [M_POLL_RESPONSE.name, M_POLL_RESPONSE.altName, M_POLL_END.name, M_POLL_END.altName] .map(async eventType => { - const { events } = await this.context.relations( - roomId, eventId, RelationType.Reference, eventType, - ); - const relations = new Relations(RelationType.Reference, eventType, room); + relations.setTargetEvent(this.props.event); + if (!this.relations.has(RelationType.Reference)) { this.relations.set(RelationType.Reference, new Map()); } this.relations.get(RelationType.Reference).set(eventType, relations); - relations.setTargetEvent(this.props.event); - events.forEach(event => relations.addEvent(event)); + let nextBatch: string | undefined; + do { + const page = await this.context.relations( + roomId, eventId, RelationType.Reference, eventType, { from: nextBatch }, + ); + nextBatch = page.nextBatch; + page.events.forEach(event => relations.addEvent(event)); + } while (nextBatch); }), ); } catch (err) { diff --git a/test/components/views/right_panel/PinnedMessagesCard-test.tsx b/test/components/views/right_panel/PinnedMessagesCard-test.tsx index a8301a2de0..4ea5d8d351 100644 --- a/test/components/views/right_panel/PinnedMessagesCard-test.tsx +++ b/test/components/views/right_panel/PinnedMessagesCard-test.tsx @@ -234,11 +234,16 @@ describe("", () => { }); // Make the responses available - cli.relations.mockImplementation((roomId, eventId, relationType, eventType) => { + cli.relations.mockImplementation((roomId, eventId, relationType, eventType, { from }) => { if (eventId === poll.getId() && relationType === RelationType.Reference) { switch (eventType) { - case M_POLL_RESPONSE.name: return { events: responses }; - case M_POLL_END.name: return { events: [end] }; + case M_POLL_RESPONSE.name: + // Paginate the results, for added challenge + return (from === "page2") ? + { events: responses.slice(2) } : + { events: responses.slice(0, 2), nextBatch: "page2" }; + case M_POLL_END.name: + return { events: [end] }; } } return { events: [] };