Skip to content

Commit 1c00b36

Browse files
authored
Merge pull request #1769 from GetStream/release-v9.5.2
v9.5.2
2 parents 61aa68d + 6dfa6cc commit 1c00b36

File tree

5 files changed

+47
-44
lines changed

5 files changed

+47
-44
lines changed

.github/workflows/release.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ on:
55
- master
66
- main
77
- beta
8+
- release-v9
89

910
jobs:
1011
release:
@@ -18,7 +19,7 @@ jobs:
1819
- name: Setup Node.js
1920
uses: actions/setup-node@v3
2021
with:
21-
node-version: 'lts/*'
22+
node-version: 16
2223
- name: Install dependencies
2324
run: yarn install --frozen-lockfile
2425
- name: Validate CommonJS bundle

.releaserc.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,10 @@
55
{
66
"name": "beta",
77
"prerelease": true
8+
},
9+
{
10+
"name": "release-v9",
11+
"channel": "v9"
812
}
913
],
1014
"plugins": [

src/components/Attachment/Attachment.tsx

Lines changed: 24 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -80,31 +80,35 @@ export const Attachment = <
8080
]
8181
: attachments;
8282

83-
return (
84-
<>
85-
{newAttachments.map((attachment) => {
86-
if (isGalleryAttachmentType(attachment)) {
87-
return renderGallery({ ...rest, attachment });
88-
}
83+
const getContent = (attachment: StreamAttachment<StreamChatGenerics>) => {
84+
if (isGalleryAttachmentType(attachment)) {
85+
return renderGallery({ ...rest, attachment });
86+
}
87+
88+
if (isImageAttachment(attachment)) {
89+
return renderImage({ ...rest, attachment });
90+
}
8991

90-
if (isImageAttachment(attachment)) {
91-
return renderImage({ ...rest, attachment });
92-
}
92+
if (isAudioAttachment(attachment)) {
93+
return renderAudio({ ...rest, attachment });
94+
}
9395

94-
if (isAudioAttachment(attachment)) {
95-
return renderAudio({ ...rest, attachment });
96-
}
96+
if (isFileAttachment(attachment)) {
97+
return renderFile({ ...rest, attachment });
98+
}
9799

98-
if (isFileAttachment(attachment)) {
99-
return renderFile({ ...rest, attachment });
100-
}
100+
if (isMediaAttachment(attachment)) {
101+
return renderMedia({ ...rest, attachment });
102+
}
101103

102-
if (isMediaAttachment(attachment)) {
103-
return renderMedia({ ...rest, attachment });
104-
}
104+
return renderCard({ ...rest, attachment });
105+
};
105106

106-
return renderCard({ ...rest, attachment });
107-
})}
107+
return (
108+
<>
109+
{newAttachments.map((attachment, i) => (
110+
<React.Fragment key={i}>{getContent(attachment)}</React.Fragment>
111+
))}
108112
</>
109113
);
110114
};

src/components/Attachment/utils.tsx

Lines changed: 10 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import React, { PropsWithChildren } from 'react';
22
import ReactPlayer from 'react-player';
3-
import { nanoid } from 'nanoid';
43

54
import { AttachmentActions as DefaultAttachmentActions } from './AttachmentActions';
65
import { Audio as DefaultAudio } from './Audio';
@@ -100,9 +99,6 @@ export const renderAttachmentWithinContainer = <
10099
className={`str-chat__message-attachment str-chat__message-attachment--${componentType} str-chat__message-attachment--${
101100
attachment?.type || ''
102101
} str-chat__message-attachment--${componentType}--${extra}`}
103-
key={`${isGalleryAttachmentType(attachment) ? '' : attachment?.id || nanoid()}-${
104-
attachment?.type || 'none'
105-
} `}
106102
>
107103
{children}
108104
</div>
@@ -124,7 +120,6 @@ export const renderAttachmentActions = <
124120
actionHandler={(event, name, value) => actionHandler?.(event, name, value)}
125121
actions={attachment.actions}
126122
id={attachment.id || ''}
127-
key={`key-actions-${attachment.id}`}
128123
text={attachment.text || ''}
129124
/>
130125
);
@@ -139,7 +134,7 @@ export const renderGallery = <
139134

140135
return renderAttachmentWithinContainer({
141136
attachment,
142-
children: <Gallery images={attachment.images || []} key='gallery' />,
137+
children: <Gallery images={attachment.images || []} />,
143138
componentType: 'gallery',
144139
});
145140
};
@@ -155,7 +150,7 @@ export const renderImage = <
155150
return renderAttachmentWithinContainer({
156151
attachment,
157152
children: (
158-
<div className='str-chat__attachment' key={`key-image-${attachment.id}`}>
153+
<div className='str-chat__attachment'>
159154
{<Image {...attachment} />}
160155
{renderAttachmentActions(props)}
161156
</div>
@@ -166,7 +161,7 @@ export const renderImage = <
166161

167162
return renderAttachmentWithinContainer({
168163
attachment,
169-
children: <Image {...attachment} key={`key-image-${attachment.id}`} />,
164+
children: <Image {...attachment} />,
170165
componentType: 'image',
171166
});
172167
};
@@ -182,8 +177,8 @@ export const renderCard = <
182177
return renderAttachmentWithinContainer({
183178
attachment,
184179
children: (
185-
<div className='str-chat__attachment' key={`key-image-${attachment.id}`}>
186-
<Card {...attachment} key={`key-card-${attachment.id}`} />
180+
<div className='str-chat__attachment'>
181+
<Card {...attachment} />
187182
{renderAttachmentActions(props)}
188183
</div>
189184
),
@@ -193,7 +188,7 @@ export const renderCard = <
193188

194189
return renderAttachmentWithinContainer({
195190
attachment,
196-
children: <Card {...attachment} key={`key-card-${attachment.id}`} />,
191+
children: <Card {...attachment} />,
197192
componentType: 'card',
198193
});
199194
};
@@ -209,7 +204,7 @@ export const renderFile = <
209204

210205
return renderAttachmentWithinContainer({
211206
attachment,
212-
children: <File attachment={attachment} key={`key-file-${attachment.id}`} />,
207+
children: <File attachment={attachment} />,
213208
componentType: 'file',
214209
});
215210
};
@@ -224,7 +219,7 @@ export const renderAudio = <
224219
return renderAttachmentWithinContainer({
225220
attachment,
226221
children: (
227-
<div className='str-chat__attachment' key={`key-video-${attachment.id}`}>
222+
<div className='str-chat__attachment'>
228223
<Audio og={attachment} />
229224
</div>
230225
),
@@ -243,10 +238,7 @@ export const renderMedia = <
243238
return renderAttachmentWithinContainer({
244239
attachment,
245240
children: (
246-
<div
247-
className='str-chat__attachment str-chat__attachment-media'
248-
key={`key-video-${attachment.id}`}
249-
>
241+
<div className='str-chat__attachment str-chat__attachment-media'>
250242
<div className='str-chat__player-wrapper'>
251243
<Media
252244
className='react-player'
@@ -266,7 +258,7 @@ export const renderMedia = <
266258
return renderAttachmentWithinContainer({
267259
attachment,
268260
children: (
269-
<div className='str-chat__player-wrapper' key={`key-video-${attachment.id}`}>
261+
<div className='str-chat__player-wrapper'>
270262
<Media
271263
className='react-player'
272264
controls

src/components/MessageList/hooks/usePrependMessagesCount.ts

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,17 @@ export function usePrependedMessagesCount<
88
StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics
99
>(messages: StreamMessage<StreamChatGenerics>[], hasDateSeparator: boolean) {
1010
const firstRealMessageIndex = hasDateSeparator ? 1 : 0;
11-
const currentFirstMessageId = messages?.[firstRealMessageIndex]?.id;
12-
const firstMessageId = useRef(currentFirstMessageId);
13-
const earliestMessageId = useRef(currentFirstMessageId);
11+
const firstMessageId = useRef<string>();
12+
const earliestMessageId = useRef<string>();
1413
const previousNumItemsPrepended = useRef(0);
1514

1615
const numItemsPrepended = useMemo(() => {
1716
if (!messages || !messages.length) {
17+
previousNumItemsPrepended.current = 0;
1818
return 0;
1919
}
20+
21+
const currentFirstMessageId = messages?.[firstRealMessageIndex]?.id;
2022
// if no new messages were prepended, return early (same amount as before)
2123
if (currentFirstMessageId === earliestMessageId.current) {
2224
return previousNumItemsPrepended.current;
@@ -35,9 +37,9 @@ export function usePrependedMessagesCount<
3537
}
3638
}
3739

38-
// if no match has found, we have jumped
40+
// if no match has found, we have jumped - reset the prepend item count.
3941
firstMessageId.current = currentFirstMessageId;
40-
42+
previousNumItemsPrepended.current = 0;
4143
return 0;
4244
// TODO: there's a bug here, the messages prop is the same array instance (something mutates it)
4345
// that's why the second dependency is necessary

0 commit comments

Comments
 (0)