Skip to content

Commit 0e94578

Browse files
committed
chore: resolve conflicts from develop
2 parents 913e154 + 7199f39 commit 0e94578

File tree

21 files changed

+76
-11
lines changed

21 files changed

+76
-11
lines changed

package/src/components/Attachment/Gallery.tsx

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import { Pressable, StyleSheet, Text, View } from 'react-native';
44
import type { Attachment } from 'stream-chat';
55

66
import { GalleryImage } from './GalleryImage';
7-
import { ImageReloadIndicator } from './ImageReloadIndicator';
87
import { buildGallery } from './utils/buildGallery/buildGallery';
98

109
import type { Thumbnail } from './utils/buildGallery/types';
@@ -13,6 +12,7 @@ import { getGalleryImageBorderRadius } from './utils/getGalleryImageBorderRadius
1312
import { openUrlSafely } from './utils/openUrlSafely';
1413

1514
import type { MessageType } from '../../components/MessageList/hooks/useMessageList';
15+
import { useTranslationContext } from '../../contexts';
1616
import { useChatConfigContext } from '../../contexts/chatConfigContext/ChatConfigContext';
1717
import {
1818
ImageGalleryContextValue,
@@ -59,6 +59,7 @@ export type GalleryPropsWithContext = Pick<
5959
| 'VideoThumbnail'
6060
| 'ImageLoadingIndicator'
6161
| 'ImageLoadingFailedIndicator'
62+
| 'ImageReloadIndicator'
6263
| 'myMessageTheme'
6364
> &
6465
Pick<OverlayContextValue, 'setOverlay'> & {
@@ -87,6 +88,7 @@ const GalleryWithContext = (props: GalleryPropsWithContext) => {
8788
hasThreadReplies,
8889
ImageLoadingFailedIndicator,
8990
ImageLoadingIndicator,
91+
ImageReloadIndicator,
9092
images,
9193
legacyImageViewerSwipeBehaviour,
9294
message,
@@ -204,6 +206,7 @@ const GalleryWithContext = (props: GalleryPropsWithContext) => {
204206
colIndex={colIndex}
205207
ImageLoadingFailedIndicator={ImageLoadingFailedIndicator}
206208
ImageLoadingIndicator={ImageLoadingIndicator}
209+
ImageReloadIndicator={ImageReloadIndicator}
207210
imagesAndVideos={imagesAndVideos}
208211
invertedDirections={invertedDirections || false}
209212
key={rowIndex}
@@ -253,6 +256,7 @@ type GalleryThumbnailProps = {
253256
| 'VideoThumbnail'
254257
| 'ImageLoadingIndicator'
255258
| 'ImageLoadingFailedIndicator'
259+
| 'ImageReloadIndicator'
256260
> &
257261
Pick<ImageGalleryContextValue, 'setSelectedMessage' | 'setMessages'> &
258262
Pick<MessageContextValue, 'onLongPress' | 'onPress' | 'onPressIn' | 'preventPress'> &
@@ -264,6 +268,7 @@ const GalleryThumbnail = ({
264268
colIndex,
265269
ImageLoadingFailedIndicator,
266270
ImageLoadingIndicator,
271+
ImageReloadIndicator,
267272
imagesAndVideos,
268273
invertedDirections,
269274
legacyImageViewerSwipeBehaviour,
@@ -296,6 +301,7 @@ const GalleryThumbnail = ({
296301
},
297302
},
298303
} = useTheme();
304+
const { t } = useTranslationContext();
299305

300306
const openImageViewer = () => {
301307
if (!legacyImageViewerSwipeBehaviour && message) {
@@ -387,6 +393,7 @@ const GalleryThumbnail = ({
387393
borderRadius={imageBorderRadius ?? borderRadius}
388394
ImageLoadingFailedIndicator={ImageLoadingFailedIndicator}
389395
ImageLoadingIndicator={ImageLoadingIndicator}
396+
ImageReloadIndicator={ImageReloadIndicator}
390397
thumbnail={thumbnail}
391398
/>
392399
</View>
@@ -401,7 +408,7 @@ const GalleryThumbnail = ({
401408
]}
402409
>
403410
<Text style={[styles.moreImagesText, moreImagesText]}>
404-
{`+${imagesAndVideos.length - 4}`}
411+
{String(t('+{{count}}', { count: imagesAndVideos.length - 4 }))}
405412
</Text>
406413
</View>
407414
) : null}
@@ -413,10 +420,15 @@ const GalleryImageThumbnail = ({
413420
borderRadius,
414421
ImageLoadingFailedIndicator,
415422
ImageLoadingIndicator,
423+
ImageReloadIndicator,
416424
thumbnail,
417425
}: Pick<
418426
GalleryThumbnailProps,
419-
'ImageLoadingFailedIndicator' | 'ImageLoadingIndicator' | 'thumbnail' | 'borderRadius'
427+
| 'ImageLoadingFailedIndicator'
428+
| 'ImageLoadingIndicator'
429+
| 'ImageReloadIndicator'
430+
| 'thumbnail'
431+
| 'borderRadius'
420432
>) => {
421433
const {
422434
isLoadingImage,
@@ -564,6 +576,7 @@ export const Gallery = (props: GalleryProps) => {
564576
hasThreadReplies,
565577
ImageLoadingFailedIndicator: PropImageLoadingFailedIndicator,
566578
ImageLoadingIndicator: PropImageLoadingIndicator,
579+
ImageReloadIndicator: PropImageReloadIndicator,
567580
images: propImages,
568581
message: propMessage,
569582
myMessageTheme: propMyMessageTheme,
@@ -595,6 +608,7 @@ export const Gallery = (props: GalleryProps) => {
595608
additionalPressableProps: contextAdditionalPressableProps,
596609
ImageLoadingFailedIndicator: ContextImageLoadingFailedIndicator,
597610
ImageLoadingIndicator: ContextImageLoadingIndicator,
611+
ImageReloadIndicator: ContextImageReloadIndicator,
598612
legacyImageViewerSwipeBehaviour,
599613
myMessageTheme: contextMyMessageTheme,
600614
VideoThumbnail: ContextVideoThumnbnail,
@@ -624,6 +638,7 @@ export const Gallery = (props: GalleryProps) => {
624638
const ImageLoadingFailedIndicator =
625639
PropImageLoadingFailedIndicator || ContextImageLoadingFailedIndicator;
626640
const ImageLoadingIndicator = PropImageLoadingIndicator || ContextImageLoadingIndicator;
641+
const ImageReloadIndicator = PropImageReloadIndicator || ContextImageReloadIndicator;
627642
const myMessageTheme = propMyMessageTheme || contextMyMessageTheme;
628643

629644
return (
@@ -636,6 +651,7 @@ export const Gallery = (props: GalleryProps) => {
636651
hasThreadReplies: hasThreadReplies || !!message?.reply_count,
637652
ImageLoadingFailedIndicator,
638653
ImageLoadingIndicator,
654+
ImageReloadIndicator,
639655
images,
640656
legacyImageViewerSwipeBehaviour,
641657
message,

package/src/components/Attachment/ImageReloadIndicator.tsx

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,12 @@ import { Refresh } from '../../icons';
66

77
const REFRESH_ICON_SIZE = 24;
88

9-
export const ImageReloadIndicator = ({
10-
onReloadImage,
11-
style,
12-
}: {
9+
export type ImageReloadIndicatorProps = {
1310
onReloadImage: () => void;
1411
style: React.ComponentProps<typeof Pressable>['style'];
15-
}) => {
12+
};
13+
14+
export const ImageReloadIndicator = ({ onReloadImage, style }: ImageReloadIndicatorProps) => {
1615
const {
1716
theme: {
1817
colors: { grey_dark },

package/src/components/Channel/Channel.tsx

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,7 @@ import { Gallery as GalleryDefault } from '../Attachment/Gallery';
119119
import { Giphy as GiphyDefault } from '../Attachment/Giphy';
120120
import { ImageLoadingFailedIndicator as ImageLoadingFailedIndicatorDefault } from '../Attachment/ImageLoadingFailedIndicator';
121121
import { ImageLoadingIndicator as ImageLoadingIndicatorDefault } from '../Attachment/ImageLoadingIndicator';
122+
import { ImageReloadIndicator as ImageReloadIndicatorDefault } from '../Attachment/ImageReloadIndicator';
122123
import { VideoThumbnail as VideoThumbnailDefault } from '../Attachment/VideoThumbnail';
123124
import { AutoCompleteSuggestionHeader as AutoCompleteSuggestionHeaderDefault } from '../AutoCompleteInput/AutoCompleteSuggestionHeader';
124125
import { AutoCompleteSuggestionItem as AutoCompleteSuggestionItemDefault } from '../AutoCompleteInput/AutoCompleteSuggestionItem';
@@ -321,6 +322,7 @@ export type ChannelPropsWithContext = Pick<ChannelContextValue, 'channel'> &
321322
| 'legacyImageViewerSwipeBehaviour'
322323
| 'ImageLoadingFailedIndicator'
323324
| 'ImageLoadingIndicator'
325+
| 'ImageReloadIndicator'
324326
| 'markdownRules'
325327
| 'Message'
326328
| 'MessageActionList'
@@ -552,7 +554,7 @@ const ChannelWithContext = (props: PropsWithChildren<ChannelPropsWithContext>) =
552554
handleRetry,
553555
handleThreadReply,
554556
hasCameraPicker = isImagePickerAvailable(),
555-
hasCommands = true,
557+
hasCommands,
556558
hasCreatePoll,
557559
// If pickDocument isn't available, default to hiding the file picker
558560
hasFilePicker = isDocumentPickerAvailable(),
@@ -561,6 +563,7 @@ const ChannelWithContext = (props: PropsWithChildren<ChannelPropsWithContext>) =
561563
hideStickyDateHeader = false,
562564
ImageLoadingFailedIndicator = ImageLoadingFailedIndicatorDefault,
563565
ImageLoadingIndicator = ImageLoadingIndicatorDefault,
566+
ImageReloadIndicator = ImageReloadIndicatorDefault,
564567
ImageUploadPreview = ImageUploadPreviewDefault,
565568
initialScrollToFirstUnreadMessage = false,
566569
initialValue,
@@ -1808,7 +1811,7 @@ const ChannelWithContext = (props: PropsWithChildren<ChannelPropsWithContext>) =
18081811
FileUploadPreview,
18091812
handleAttachButtonPress,
18101813
hasCameraPicker,
1811-
hasCommands,
1814+
hasCommands: hasCommands ?? (getChannelConfigSafely()?.commands ?? []).length > 0,
18121815
hasFilePicker,
18131816
hasImagePicker,
18141817
ImageUploadPreview,
@@ -1897,6 +1900,7 @@ const ChannelWithContext = (props: PropsWithChildren<ChannelPropsWithContext>) =
18971900
hasCreatePoll === undefined ? pollCreationEnabled : hasCreatePoll && pollCreationEnabled,
18981901
ImageLoadingFailedIndicator,
18991902
ImageLoadingIndicator,
1903+
ImageReloadIndicator,
19001904
initialScrollToFirstUnreadMessage: !messageId && initialScrollToFirstUnreadMessage, // when messageId is set, we scroll to the messageId instead of first unread
19011905
InlineDateSeparator,
19021906
InlineUnreadIndicator,

package/src/components/Channel/__tests__/Channel.test.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,8 @@ describe('Channel', () => {
7777
useMockedApis(chatClient, [getOrCreateChannelApi(mockedChannel)]);
7878
channel = chatClient.channel('messaging', mockedChannel.id);
7979
channel.cid = mockedChannel.channel.cid;
80+
const getConfigSpy = jest.fn();
81+
channel.getConfig = getConfigSpy;
8082
});
8183

8284
afterEach(() => {

package/src/components/Channel/hooks/useCreateMessagesContext.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ export const useCreateMessagesContext = ({
4545
hasCreatePoll,
4646
ImageLoadingFailedIndicator,
4747
ImageLoadingIndicator,
48+
ImageReloadIndicator,
4849
initialScrollToFirstUnreadMessage,
4950
InlineDateSeparator,
5051
InlineUnreadIndicator,
@@ -162,6 +163,7 @@ export const useCreateMessagesContext = ({
162163
hasCreatePoll,
163164
ImageLoadingFailedIndicator,
164165
ImageLoadingIndicator,
166+
ImageReloadIndicator,
165167
initialScrollToFirstUnreadMessage,
166168
InlineDateSeparator,
167169
InlineUnreadIndicator,

package/src/components/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ export * from './Attachment/FileIcon';
88
export * from './Attachment/Gallery';
99
export * from './Attachment/Giphy';
1010
export * from './Attachment/VideoThumbnail';
11+
export * from './Attachment/ImageReloadIndicator';
1112
export * from './Attachment/utils/buildGallery/buildGallery';
1213

1314
export * from './AttachmentPicker/AttachmentPicker';

package/src/contexts/channelsStateContext/useChannelState.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ export function useChannelState(
4545
const cid = channel?.id || 'id'; // in case channel is not initialized, use generic id string for indexing
4646
const { setState, state } = useChannelsStateContext();
4747

48-
const [threadMessages, setThreadMessages] = useStateManager(
48+
const [threadMessages, setThreadMessagesInternal] = useStateManager(
4949
{
5050
cid,
5151
key: 'threadMessages',
@@ -54,6 +54,10 @@ export function useChannelState(
5454
},
5555
(threadId && channel?.state?.threads?.[threadId]) || [],
5656
);
57+
const setThreadMessages = useCallback(
58+
(value: ChannelState['threadMessages']) => setThreadMessagesInternal([...value]),
59+
[setThreadMessagesInternal],
60+
);
5761

5862
return {
5963
setThreadMessages,

package/src/contexts/messagesContext/MessagesContext.tsx

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import type { GalleryProps } from '../../components/Attachment/Gallery';
1616
import type { GiphyProps } from '../../components/Attachment/Giphy';
1717
import type { ImageLoadingFailedIndicatorProps } from '../../components/Attachment/ImageLoadingFailedIndicator';
1818
import type { ImageLoadingIndicatorProps } from '../../components/Attachment/ImageLoadingIndicator';
19+
import { ImageReloadIndicatorProps } from '../../components/Attachment/ImageReloadIndicator';
1920
import type { VideoThumbnailProps } from '../../components/Attachment/VideoThumbnail';
2021
import type {
2122
MessagePressableHandlerPayload,
@@ -151,6 +152,11 @@ export type MessagesContextValue = Pick<MessageContextValue, 'isMessageAIGenerat
151152
*/
152153
ImageLoadingFailedIndicator: React.ComponentType<ImageLoadingFailedIndicatorProps>;
153154

155+
/**
156+
* The indicator rendered at the center of an image whenever its loading fails, used to trigger retries.
157+
*/
158+
ImageReloadIndicator: React.ComponentType<ImageReloadIndicatorProps>;
159+
154160
/**
155161
* The indicator rendered when image is loading. By default renders <ActivityIndicator/>
156162
*/

package/src/hooks/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,4 @@ export * from './useViewport';
44
export * from './useScreenDimensions';
55
export * from './useStateStore';
66
export * from './useStableCallback';
7+
export * from './useLoadingImage';

package/src/i18n/en.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
{
2+
"+{{count}}_many": "+{{count}}",
3+
"+{{count}}_one": "+{{count}}",
4+
"+{{count}}_other": "+{{count}}",
25
"1 Reply": "1 Reply",
36
"1 Thread Reply": "1 Thread Reply",
47
"Add a comment": "Add a comment",

0 commit comments

Comments
 (0)