Skip to content

Commit 618d71b

Browse files
authored
Fix the first message showing as empty because it is expecting a prevContent (#685)
<!-- Please read https://github.com/SableClient/Sable/blob/dev/CONTRIBUTING.md before submitting your pull request --> ### Description <!-- Please include a summary of the change. Please also include relevant motivation and context. List any dependencies that are required for this change. --> Fixes the first message showing as empty because it is expecting a prevContent Fixes # #### Type of change - [x] Bug fix (non-breaking change which fixes an issue) - [ ] New feature (non-breaking change which adds functionality) - [ ] Breaking change (fix or feature that would cause existing functionality to not work as expected) - [ ] This change requires a documentation update ### Checklist: - [x] My code follows the style guidelines of this project - [x] I have performed a self-review of my own code - [x] My changes generate no new warnings ### AI disclosure: - [ ] Partially AI assisted (clarify which code was AI assisted and briefly explain what it does). - [ ] Fully AI generated (explain what all the generated code does in moderate detail). <!-- Write any explanation required here, but do not generate the explanation using AI!! You must prove you understand what the code in this PR does. --> Having a hard time to think of a pun here made me optimize the fix instead.
2 parents 7783707 + 472b822 commit 618d71b

2 files changed

Lines changed: 11 additions & 5 deletions

File tree

.changeset/fix-initial-pins.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
default: patch
3+
---
4+
5+
Fix the first pin event in a room looking empty

src/app/hooks/timeline/useTimelineEventRenderer.tsx

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1071,10 +1071,11 @@ export function useTimelineEventRenderer({
10711071

10721072
const { pinned } = getContent.call(mEvent);
10731073
const prevPinned = getPrevContent.call(mEvent).pinned;
1074-
const pinsAdded =
1075-
prevPinned && pinned && pinned.filter((x: string) => !prevPinned.includes(x));
1074+
const pinsAdded = prevPinned
1075+
? pinned?.filter((x: string) => !prevPinned.includes(x))
1076+
: pinned?.filter((x: string) => x.length > 0);
10761077
const pinsRemoved =
1077-
prevPinned && pinned && prevPinned.filter((x: string) => !pinned.includes(x));
1078+
(prevPinned && pinned && prevPinned.filter((x: string) => !pinned.includes(x))) || [];
10781079

10791080
const timeJSX = (
10801081
<Time
@@ -1122,13 +1123,13 @@ export function useTimelineEventRenderer({
11221123
</Text>
11231124
{(pinsAdded || pinsRemoved) &&
11241125
pinsAdded
1125-
.concat(pinsRemoved)
1126+
.concat(...pinsRemoved)
11261127
.slice(0, 4)
11271128
.map((x: string) => (
11281129
<Reply
11291130
style={{ opacity: '80%' }}
11301131
room={room}
1131-
replyEventId={x ?? ''}
1132+
replyEventId={x}
11321133
onClick={handleOpenReply}
11331134
replyIcon={
11341135
<>

0 commit comments

Comments
 (0)