Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/fix-pinned-events-timeline-crash.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
default: patch
---

Fixed crash when rendering some `m.room.pinned_events` timeline rows (old/malformed pin state edge case).
41 changes: 19 additions & 22 deletions src/app/hooks/timeline/useTimelineEventRenderer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -1060,6 +1060,9 @@ export function useTimelineEventRenderer({
const pinsRemoved =
(prevPinned && pinned && prevPinned.filter((x: string) => !pinned.includes(x))) || [];

const pinPreviewIds = (pinsAdded ?? []).concat(...(pinsRemoved ?? []));
const pinnedSet = new Set(pinned ?? []);

const timeJSX = (
<Time
ts={mEvent.getTs()}
Expand Down Expand Up @@ -1104,28 +1107,22 @@ export function useTimelineEventRenderer({
`has not changed the pins`) ||
`:`}
</Text>
{(pinsAdded || pinsRemoved) &&
pinsAdded
.concat(...pinsRemoved)
.slice(0, 4)
.map((x: string) => (
<Reply
key={x}
style={{ opacity: '80%' }}
room={room}
replyEventId={x}
onClick={handleOpenReply}
replyIcon={
<>
<Icon size="100" src={Icons.Pin} />
<Icon
size="100"
src={pinned.includes(x) ? Icons.Plus : Icons.Minus}
/>
</>
}
/>
))}
{pinPreviewIds.length > 0 &&
pinPreviewIds.slice(0, 4).map((x: string) => (
<Reply
key={x}
style={{ opacity: '80%' }}
room={room}
replyEventId={x}
onClick={handleOpenReply}
replyIcon={
<>
<Icon size="100" src={Icons.Pin} />
<Icon size="100" src={pinnedSet.has(x) ? Icons.Plus : Icons.Minus} />
</>
}
/>
))}
</Box>
}
/>
Expand Down
Loading