Skip to content

Commit de777de

Browse files
committed
Merge branch 'develop' into V7
# Conflicts: # examples/SampleApp/yarn.lock # package/src/components/Attachment/Gallery.tsx
2 parents 948b6db + 76ca4b1 commit de777de

File tree

20 files changed

+70
-10
lines changed

20 files changed

+70
-10
lines changed

package/src/components/Attachment/Gallery.tsx

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,14 @@ import { Pressable, StyleSheet, Text, View } from 'react-native';
44
import type { Attachment, LocalMessage } 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';
1110
import { getGalleryImageBorderRadius } from './utils/getGalleryImageBorderRadius';
1211

1312
import { openUrlSafely } from './utils/openUrlSafely';
1413

14+
import { useTranslationContext } from '../../contexts';
1515
import { useChatConfigContext } from '../../contexts/chatConfigContext/ChatConfigContext';
1616
import {
1717
ImageGalleryContextValue,
@@ -58,6 +58,7 @@ export type GalleryPropsWithContext = Pick<
5858
| 'VideoThumbnail'
5959
| 'ImageLoadingIndicator'
6060
| 'ImageLoadingFailedIndicator'
61+
| 'ImageReloadIndicator'
6162
| 'myMessageTheme'
6263
> &
6364
Pick<OverlayContextValue, 'setOverlay'> & {
@@ -86,6 +87,7 @@ const GalleryWithContext = (props: GalleryPropsWithContext) => {
8687
hasThreadReplies,
8788
ImageLoadingFailedIndicator,
8889
ImageLoadingIndicator,
90+
ImageReloadIndicator,
8991
images,
9092
legacyImageViewerSwipeBehaviour,
9193
message,
@@ -203,6 +205,7 @@ const GalleryWithContext = (props: GalleryPropsWithContext) => {
203205
colIndex={colIndex}
204206
ImageLoadingFailedIndicator={ImageLoadingFailedIndicator}
205207
ImageLoadingIndicator={ImageLoadingIndicator}
208+
ImageReloadIndicator={ImageReloadIndicator}
206209
imagesAndVideos={imagesAndVideos}
207210
invertedDirections={invertedDirections || false}
208211
key={rowIndex}
@@ -252,6 +255,7 @@ type GalleryThumbnailProps = {
252255
| 'VideoThumbnail'
253256
| 'ImageLoadingIndicator'
254257
| 'ImageLoadingFailedIndicator'
258+
| 'ImageReloadIndicator'
255259
> &
256260
Pick<ImageGalleryContextValue, 'setSelectedMessage' | 'setMessages'> &
257261
Pick<MessageContextValue, 'onLongPress' | 'onPress' | 'onPressIn' | 'preventPress'> &
@@ -263,6 +267,7 @@ const GalleryThumbnail = ({
263267
colIndex,
264268
ImageLoadingFailedIndicator,
265269
ImageLoadingIndicator,
270+
ImageReloadIndicator,
266271
imagesAndVideos,
267272
invertedDirections,
268273
legacyImageViewerSwipeBehaviour,
@@ -295,6 +300,7 @@ const GalleryThumbnail = ({
295300
},
296301
},
297302
} = useTheme();
303+
const { t } = useTranslationContext();
298304

299305
const openImageViewer = () => {
300306
if (!legacyImageViewerSwipeBehaviour && message) {
@@ -386,6 +392,7 @@ const GalleryThumbnail = ({
386392
borderRadius={imageBorderRadius ?? borderRadius}
387393
ImageLoadingFailedIndicator={ImageLoadingFailedIndicator}
388394
ImageLoadingIndicator={ImageLoadingIndicator}
395+
ImageReloadIndicator={ImageReloadIndicator}
389396
thumbnail={thumbnail}
390397
/>
391398
</View>
@@ -400,7 +407,7 @@ const GalleryThumbnail = ({
400407
]}
401408
>
402409
<Text style={[styles.moreImagesText, moreImagesText]}>
403-
{`+${imagesAndVideos.length - 4}`}
410+
{String(t('+{{count}}', { count: imagesAndVideos.length - 4 }))}
404411
</Text>
405412
</View>
406413
) : null}
@@ -412,10 +419,15 @@ const GalleryImageThumbnail = ({
412419
borderRadius,
413420
ImageLoadingFailedIndicator,
414421
ImageLoadingIndicator,
422+
ImageReloadIndicator,
415423
thumbnail,
416424
}: Pick<
417425
GalleryThumbnailProps,
418-
'ImageLoadingFailedIndicator' | 'ImageLoadingIndicator' | 'thumbnail' | 'borderRadius'
426+
| 'ImageLoadingFailedIndicator'
427+
| 'ImageLoadingIndicator'
428+
| 'ImageReloadIndicator'
429+
| 'thumbnail'
430+
| 'borderRadius'
419431
>) => {
420432
const {
421433
isLoadingImage,
@@ -563,6 +575,7 @@ export const Gallery = (props: GalleryProps) => {
563575
hasThreadReplies,
564576
ImageLoadingFailedIndicator: PropImageLoadingFailedIndicator,
565577
ImageLoadingIndicator: PropImageLoadingIndicator,
578+
ImageReloadIndicator: PropImageReloadIndicator,
566579
images: propImages,
567580
message: propMessage,
568581
myMessageTheme: propMyMessageTheme,
@@ -594,6 +607,7 @@ export const Gallery = (props: GalleryProps) => {
594607
additionalPressableProps: contextAdditionalPressableProps,
595608
ImageLoadingFailedIndicator: ContextImageLoadingFailedIndicator,
596609
ImageLoadingIndicator: ContextImageLoadingIndicator,
610+
ImageReloadIndicator: ContextImageReloadIndicator,
597611
legacyImageViewerSwipeBehaviour,
598612
myMessageTheme: contextMyMessageTheme,
599613
VideoThumbnail: ContextVideoThumnbnail,
@@ -623,6 +637,7 @@ export const Gallery = (props: GalleryProps) => {
623637
const ImageLoadingFailedIndicator =
624638
PropImageLoadingFailedIndicator || ContextImageLoadingFailedIndicator;
625639
const ImageLoadingIndicator = PropImageLoadingIndicator || ContextImageLoadingIndicator;
640+
const ImageReloadIndicator = PropImageReloadIndicator || ContextImageReloadIndicator;
626641
const myMessageTheme = propMyMessageTheme || contextMyMessageTheme;
627642

628643
return (
@@ -635,6 +650,7 @@ export const Gallery = (props: GalleryProps) => {
635650
hasThreadReplies: hasThreadReplies || !!message?.reply_count,
636651
ImageLoadingFailedIndicator,
637652
ImageLoadingIndicator,
653+
ImageReloadIndicator,
638654
images,
639655
legacyImageViewerSwipeBehaviour,
640656
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: 5 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';
@@ -320,6 +321,7 @@ export type ChannelPropsWithContext = Pick<ChannelContextValue, 'channel'> &
320321
| 'legacyImageViewerSwipeBehaviour'
321322
| 'ImageLoadingFailedIndicator'
322323
| 'ImageLoadingIndicator'
324+
| 'ImageReloadIndicator'
323325
| 'markdownRules'
324326
| 'Message'
325327
| 'MessageActionList'
@@ -551,7 +553,6 @@ const ChannelWithContext = (props: PropsWithChildren<ChannelPropsWithContext>) =
551553
handleRetry,
552554
handleThreadReply,
553555
hasCameraPicker = isImagePickerAvailable(),
554-
hasCommands = true,
555556
hasCreatePoll,
556557
// If pickDocument isn't available, default to hiding the file picker
557558
hasFilePicker = isDocumentPickerAvailable(),
@@ -560,6 +561,7 @@ const ChannelWithContext = (props: PropsWithChildren<ChannelPropsWithContext>) =
560561
hideStickyDateHeader = false,
561562
ImageLoadingFailedIndicator = ImageLoadingFailedIndicatorDefault,
562563
ImageLoadingIndicator = ImageLoadingIndicatorDefault,
564+
ImageReloadIndicator = ImageReloadIndicatorDefault,
563565
ImageUploadPreview = ImageUploadPreviewDefault,
564566
initialScrollToFirstUnreadMessage = false,
565567
initialValue,
@@ -1807,7 +1809,7 @@ const ChannelWithContext = (props: PropsWithChildren<ChannelPropsWithContext>) =
18071809
FileUploadPreview,
18081810
handleAttachButtonPress,
18091811
hasCameraPicker,
1810-
hasCommands,
1812+
hasCommands: (getChannelConfigSafely()?.commands ?? []).length > 0,
18111813
hasFilePicker,
18121814
hasImagePicker,
18131815
ImageUploadPreview,
@@ -1896,6 +1898,7 @@ const ChannelWithContext = (props: PropsWithChildren<ChannelPropsWithContext>) =
18961898
hasCreatePoll === undefined ? pollCreationEnabled : hasCreatePoll && pollCreationEnabled,
18971899
ImageLoadingFailedIndicator,
18981900
ImageLoadingIndicator,
1901+
ImageReloadIndicator,
18991902
initialScrollToFirstUnreadMessage: !messageId && initialScrollToFirstUnreadMessage, // when messageId is set, we scroll to the messageId instead of first unread
19001903
InlineDateSeparator,
19011904
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/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,
@@ -150,6 +151,11 @@ export type MessagesContextValue = Pick<MessageContextValue, 'isMessageAIGenerat
150151
*/
151152
ImageLoadingFailedIndicator: React.ComponentType<ImageLoadingFailedIndicatorProps>;
152153

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

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",

package/src/i18n/es.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 respuesta",
36
"1 Thread Reply": "1 respuesta de hilo",
47
"Add a comment": "Agregar un comentario",

0 commit comments

Comments
 (0)