Skip to content

Commit d2fe291

Browse files
committed
fix: file upload indicators in composer
1 parent e91b028 commit d2fe291

4 files changed

Lines changed: 15 additions & 18 deletions

File tree

examples/SampleApp/App.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -341,6 +341,7 @@ const DrawerNavigatorWrapper: React.FC<{
341341
enableOfflineSupport
342342
isMessageAIGenerated={isMessageAIGenerated}
343343
i18nInstance={i18nInstance}
344+
useNativeMultipartUpload
344345
>
345346
<StreamChatProvider>
346347
<AppOverlayProvider>

package/src/components/MessageInput/components/AttachmentPreview/AttachmentUploadProgressIndicator.tsx

Lines changed: 6 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { Pressable, StyleSheet, Text, View } from 'react-native';
33

44
import { LocalAttachmentUploadMetadata } from 'stream-chat';
55

6+
import { AttachmentFileUploadProgressIndicator } from '../../../../components/Attachment/AttachmentFileUploadProgressIndicator';
67
import { useComponentsContext } from '../../../../contexts/componentsContext/ComponentsContext';
78
import { useTheme } from '../../../../contexts/themeContext/ThemeContext';
89
import { ExclamationCircle } from '../../../../icons/exclamation-circle-fill';
@@ -13,26 +14,26 @@ import { RetryBadge } from '../../../ui/Badge/RetryBadge';
1314
export type UploadInProgressIndicatorProps = {
1415
localId?: string;
1516
sourceUrl?: string;
17+
totalBytes?: number | string | null;
1618
};
1719

1820
export const FileUploadInProgressIndicator = ({
1921
localId,
2022
sourceUrl,
23+
totalBytes,
2124
}: UploadInProgressIndicatorProps = {}) => {
2225
const {
2326
theme: {
2427
messageComposer: { fileUploadInProgressIndicator },
2528
},
2629
} = useTheme();
27-
const { AttachmentUploadIndicator } = useComponentsContext();
2830

2931
return (
30-
<AttachmentUploadIndicator
32+
<AttachmentFileUploadProgressIndicator
3133
containerStyle={[styles.activityIndicatorContainer, fileUploadInProgressIndicator.container]}
3234
localId={localId}
3335
sourceUrl={sourceUrl}
34-
style={[styles.activityIndicator, fileUploadInProgressIndicator.indicator]}
35-
testID='upload-progress-indicator'
36+
totalBytes={totalBytes}
3637
/>
3738
);
3839
};
@@ -116,14 +117,7 @@ export const ImageUploadInProgressIndicator = ({
116117
}: UploadInProgressIndicatorProps = {}) => {
117118
const { AttachmentUploadIndicator } = useComponentsContext();
118119

119-
return (
120-
<AttachmentUploadIndicator
121-
localId={localId}
122-
sourceUrl={sourceUrl}
123-
testID='upload-progress-indicator'
124-
variant='overlay'
125-
/>
126-
);
120+
return <AttachmentUploadIndicator localId={localId} sourceUrl={sourceUrl} variant='overlay' />;
127121
};
128122

129123
export type ImageUploadRetryIndicatorProps = {
@@ -227,8 +221,4 @@ const styles = StyleSheet.create({
227221
alignItems: 'center',
228222
justifyContent: 'center',
229223
},
230-
activityIndicator: {
231-
alignItems: 'flex-start',
232-
justifyContent: 'flex-start',
233-
},
234224
});

package/src/components/MessageInput/components/AttachmentPreview/AudioAttachmentUploadPreview.tsx

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,11 @@ export const AudioAttachmentUploadPreview = ({
6464
const renderIndicator = useMemo(() => {
6565
if (indicatorType === ProgressIndicatorTypes.IN_PROGRESS) {
6666
return (
67-
<FileUploadInProgressIndicator localId={attachment.localMetadata.id} sourceUrl={assetUrl} />
67+
<FileUploadInProgressIndicator
68+
localId={attachment.localMetadata.id}
69+
sourceUrl={assetUrl}
70+
totalBytes={attachment.file_size}
71+
/>
6872
);
6973
}
7074
if (indicatorType === ProgressIndicatorTypes.RETRY) {
@@ -74,7 +78,7 @@ export const AudioAttachmentUploadPreview = ({
7478
return <FileUploadNotSupportedIndicator localMetadata={attachment.localMetadata} />;
7579
}
7680
return null;
77-
}, [assetUrl, attachment.localMetadata, indicatorType, onRetryHandler]);
81+
}, [assetUrl, attachment.file_size, attachment.localMetadata, indicatorType, onRetryHandler]);
7882

7983
return (
8084
<View style={styles.wrapper} testID={'audio-attachment-upload-preview'}>

package/src/components/MessageInput/components/AttachmentPreview/FileAttachmentUploadPreview.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ export const FileAttachmentUploadPreview = ({
6767
<FileUploadInProgressIndicator
6868
localId={attachment.localMetadata.id}
6969
sourceUrl={sourceUrl}
70+
totalBytes={attachment.file_size}
7071
/>
7172
);
7273
}
@@ -82,6 +83,7 @@ export const FileAttachmentUploadPreview = ({
8283
FileUploadNotSupportedIndicator,
8384
FileUploadRetryIndicator,
8485
attachment.localMetadata,
86+
attachment.file_size,
8587
indicatorType,
8688
onRetryHandler,
8789
sourceUrl,

0 commit comments

Comments
 (0)