Skip to content

Commit 39bd4a3

Browse files
authored
Merge pull request #126 from sendbird/fix/video-thumbnail
fix: use source as a thumbnail if it is an image
2 parents de3fa98 + f7b468b commit 39bd4a3

File tree

5 files changed

+14
-7
lines changed

5 files changed

+14
-7
lines changed

packages/uikit-react-native-foundation/src/components/VideoThumbnail/index.tsx

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,30 @@
11
import React, { useEffect, useRef, useState } from 'react';
22
import { StyleProp, StyleSheet, ViewStyle } from 'react-native';
33

4+
import { isImage } from '@sendbird/uikit-utils';
5+
46
import createStyleSheet from '../../styles/createStyleSheet';
57
import useUIKitTheme from '../../theme/useUIKitTheme';
68
import Box from '../Box';
79
import Icon from '../Icon';
810
import ImageWithPlaceholder from '../ImageWithPlaceholder';
911

1012
type Props = {
11-
videoSource: string;
13+
source: string;
1214
fetchThumbnailFromVideoSource: (uri: string) => Promise<{ path: string } | null>;
1315

1416
style?: StyleProp<ViewStyle>;
1517
iconSize?: number;
18+
/** @deprecated please use `source` prop **/
19+
videoSource?: string;
1620
};
1721

18-
export const VideoThumbnail = ({ fetchThumbnailFromVideoSource, style, videoSource, iconSize = 28 }: Props) => {
22+
export const VideoThumbnail = ({ fetchThumbnailFromVideoSource, style, source, videoSource, iconSize = 28 }: Props) => {
1923
const { palette, select } = useUIKitTheme();
20-
const { thumbnail, loading } = useRetry(() => fetchThumbnailFromVideoSource(videoSource));
24+
const { thumbnail, loading } = useRetry(async () => {
25+
if (isImage(source ?? videoSource)) return { path: source ?? videoSource };
26+
return fetchThumbnailFromVideoSource(source ?? videoSource);
27+
});
2128

2229
return (
2330
<Box style={style}>

packages/uikit-react-native-foundation/src/ui/GroupChannelMessage/Message.file.video.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ const VideoFileMessage = (props: Props) => {
2828
<PressBox activeOpacity={0.8} onPress={onPress} onLongPress={onLongPress}>
2929
<VideoThumbnail
3030
style={styles.image}
31-
videoSource={uri}
31+
source={uri}
3232
fetchThumbnailFromVideoSource={props.fetchThumbnailFromVideoSource}
3333
/>
3434
</PressBox>

packages/uikit-react-native-foundation/src/ui/OpenChannelMessage/Message.file.video.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ const VideoFileMessage = (props: OpenChannelMessageProps<SendbirdFileMessage, Pr
2222
<PressBox style={styles.container} activeOpacity={0.8} onPress={onPress} onLongPress={onLongPress}>
2323
<VideoThumbnail
2424
style={styles.container}
25-
videoSource={uri}
25+
source={uri}
2626
fetchThumbnailFromVideoSource={props.fetchThumbnailFromVideoSource}
2727
/>
2828
</PressBox>

packages/uikit-react-native/src/components/ChannelInput/SendInput.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ const SendInput = forwardRef<RNTextInput, SendInputProps>(function SendInput(
143143
<VideoThumbnail
144144
style={styles.previewImage}
145145
iconSize={0}
146-
videoSource={url}
146+
source={url}
147147
fetchThumbnailFromVideoSource={(uri) => mediaService.getVideoThumbnail({ url: uri, timeMills: 1000 })}
148148
/>
149149
);

packages/uikit-react-native/src/components/GroupChannelMessageRenderer/GroupChannelMessageParentMessage.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ const GroupChannelMessageParentMessage = ({ variant, message, childMessage, onPr
5757
<VideoThumbnail
5858
style={styles.image}
5959
iconSize={18}
60-
videoSource={url}
60+
source={url}
6161
fetchThumbnailFromVideoSource={(uri) => mediaService.getVideoThumbnail({ url: uri, timeMills: 1000 })}
6262
/>
6363
);

0 commit comments

Comments
 (0)