Skip to content

Commit 3e8fb88

Browse files
committed
chore: resolve colflicts
2 parents e3d6782 + 6064447 commit 3e8fb88

File tree

6 files changed

+99
-43
lines changed

6 files changed

+99
-43
lines changed

package/src/components/Avatar/Avatar.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ export type AvatarProps = {
4747
};
4848

4949
/**
50-
* Avatar - A round avatar image with fallback to user's initials
50+
* Avatar - A round avatar image with fallback to user's initials.
5151
*/
5252
export const Avatar: React.FC<AvatarProps> = (props) => {
5353
const {

package/src/components/ImageGallery/components/ImageGalleryHeader.tsx

Lines changed: 23 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import { useOverlayContext } from '../../../contexts/overlayContext/OverlayConte
1717
import { useTheme } from '../../../contexts/themeContext/ThemeContext';
1818
import {
1919
isDayOrMoment,
20+
TDateTimeParserOutput,
2021
useTranslationContext,
2122
} from '../../../contexts/translationContext/TranslationContext';
2223
import { Close } from '../../../icons';
@@ -114,16 +115,29 @@ export const ImageGalleryHeader = <
114115
const parsedDate = photo ? tDateTimeParser(photo?.created_at) : null;
115116

116117
/**
117-
* .calendar is required on moment types, but in reality it
118-
* is unavailable on first render. We therefore check if it
119-
* is available and call it, otherwise we call .fromNow.
118+
* .calendar and .fromNow can be initialized after the first render,
119+
* and attempting to access them at that time will cause an error
120+
* to be thrown.
121+
*
122+
* This falls back to null if neither exist.
120123
*/
121-
const date =
122-
parsedDate && isDayOrMoment(parsedDate)
123-
? parsedDate.calendar
124-
? parsedDate.calendar()
125-
: parsedDate.fromNow()
126-
: null;
124+
const getDateObject = (date: TDateTimeParserOutput | null) => {
125+
if (date === null || !isDayOrMoment(date)) {
126+
return null;
127+
}
128+
129+
if (date.calendar) {
130+
return date.calendar();
131+
}
132+
133+
if (date.fromNow) {
134+
return date.fromNow();
135+
}
136+
137+
return null;
138+
};
139+
140+
const date = getDateObject(parsedDate);
127141

128142
const headerStyle = useAnimatedStyle<ViewStyle>(() => ({
129143
opacity: opacity.value,
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
import React from 'react';
2+
3+
import type Animated from 'react-native-reanimated';
4+
5+
import { render } from '@testing-library/react-native';
6+
7+
import { ThemeProvider } from '../../../../contexts/themeContext/ThemeContext';
8+
import { ImageGalleryHeader } from '../ImageGalleryHeader';
9+
10+
it('doesnt fail if fromNow is not available on first render', () => {
11+
try {
12+
const { getAllByText } = render(
13+
<ThemeProvider>
14+
<ImageGalleryHeader
15+
opacity={1 as unknown as Animated.SharedValue<number>}
16+
photo={{
17+
id: 'id',
18+
uri: 'file:///bogus/uri/to/photo.jpg',
19+
}}
20+
visible={1 as unknown as Animated.SharedValue<number>}
21+
/>
22+
</ThemeProvider>,
23+
);
24+
25+
expect(getAllByText('Unknown User')).toBeTruthy();
26+
} catch (error: unknown) {
27+
if (error instanceof Error) {
28+
throw new Error(`Error encountered on first render of ImageGalleryHeader: ${error.message}`);
29+
}
30+
}
31+
});

package/src/components/Message/MessageSimple/ReactionList.tsx

Lines changed: 31 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -179,34 +179,7 @@ const ReactionListWithContext = <
179179
: x2 - (reactionSize * reactions.length) / 2 - strokeSize;
180180

181181
return (
182-
<TouchableOpacity
183-
disabled={preventPress}
184-
onLongPress={(event) => {
185-
if (onLongPress) {
186-
onLongPress({
187-
emitter: 'reactionList',
188-
event,
189-
});
190-
}
191-
}}
192-
onPress={(event) => {
193-
if (onPress) {
194-
onPress({
195-
defaultHandler: () => showMessageOverlay(true),
196-
emitter: 'reactionList',
197-
event,
198-
});
199-
}
200-
}}
201-
onPressIn={(event) => {
202-
if (onPressIn) {
203-
onPressIn({
204-
defaultHandler: () => showMessageOverlay(true),
205-
emitter: 'reactionList',
206-
event,
207-
});
208-
}
209-
}}
182+
<View
210183
style={[
211184
styles.container,
212185
{
@@ -247,7 +220,34 @@ const ReactionListWithContext = <
247220
<Circle cx={x2} cy={y2} fill={alignmentLeft ? fill : white} r={radius * 2} />
248221
</Svg>
249222
</View>
250-
<View
223+
<TouchableOpacity
224+
disabled={preventPress}
225+
onLongPress={(event) => {
226+
if (onLongPress) {
227+
onLongPress({
228+
emitter: 'reactionList',
229+
event,
230+
});
231+
}
232+
}}
233+
onPress={(event) => {
234+
if (onPress) {
235+
onPress({
236+
defaultHandler: () => showMessageOverlay(true),
237+
emitter: 'reactionList',
238+
event,
239+
});
240+
}
241+
}}
242+
onPressIn={(event) => {
243+
if (onPressIn) {
244+
onPressIn({
245+
defaultHandler: () => showMessageOverlay(true),
246+
emitter: 'reactionList',
247+
event,
248+
});
249+
}
250+
}}
251251
style={[
252252
styles.reactionBubble,
253253
{
@@ -271,10 +271,10 @@ const ReactionListWithContext = <
271271
type={reaction.type}
272272
/>
273273
))}
274-
</View>
274+
</TouchableOpacity>
275275
</View>
276276
) : null}
277-
</TouchableOpacity>
277+
</View>
278278
);
279279
};
280280

package/src/components/Message/MessageSimple/utils/renderText.tsx

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,13 @@ export const renderText = <StreamChatClient extends ExtendableGenerics = Default
230230
};
231231

232232
const list: ReactNodeOutput = (node, output, state) => (
233-
<ListOutput node={node} output={output} state={state} styles={styles} />
233+
<ListOutput
234+
key={`list-${state.key}`}
235+
node={node}
236+
output={output}
237+
state={state}
238+
styles={styles}
239+
/>
234240
);
235241

236242
const customRules = {

package/yarn.lock

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5544,11 +5544,16 @@ flush-write-stream@^1.0.0:
55445544
inherits "^2.0.3"
55455545
readable-stream "^2.3.6"
55465546

5547-
follow-redirects@^1.0.0, follow-redirects@^1.14.4:
5547+
follow-redirects@^1.0.0:
55485548
version "1.14.7"
55495549
resolved "https://registry.yarnpkg.com/follow-redirects/-/follow-redirects-1.14.7.tgz#2004c02eb9436eee9a21446a6477debf17e81685"
55505550
integrity sha512-+hbxoLbFMbRKDwohX8GkTataGqO6Jb7jGwpAlwgy2bIz25XtRm7KEzJM76R1WiNT5SwZkX4Y75SwBolkpmE7iQ==
55515551

5552+
follow-redirects@^1.14.4:
5553+
version "1.14.8"
5554+
resolved "https://registry.yarnpkg.com/follow-redirects/-/follow-redirects-1.14.8.tgz#016996fb9a11a100566398b1c6839337d7bfa8fc"
5555+
integrity sha512-1x0S9UVJHsQprFcEC/qnNzBLcIxsjAV905f/UkQxbclCsoTWlacCNOpQa/anodLl2uaEKFhfWOvM2Qg77+15zA==
5556+
55525557
for-in@^1.0.2:
55535558
version "1.0.2"
55545559
resolved "https://registry.yarnpkg.com/for-in/-/for-in-1.0.2.tgz#81068d295a8142ec0ac726c6e2200c30fb6d5e80"

0 commit comments

Comments
 (0)