stream-chat-react-native-core 5.16.0-beta.1 → 5.16.0-beta.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/commonjs/components/Attachment/FileAttachmentGroup.js +1 -1
- package/lib/commonjs/components/Attachment/FileAttachmentGroup.js.map +1 -1
- package/lib/commonjs/components/AttachmentPicker/AttachmentPicker.js +1 -1
- package/lib/commonjs/components/AttachmentPicker/AttachmentPicker.js.map +1 -1
- package/lib/commonjs/components/AttachmentPicker/components/AttachmentPickerItem.js +33 -38
- package/lib/commonjs/components/AttachmentPicker/components/AttachmentPickerItem.js.map +1 -1
- package/lib/commonjs/components/Channel/Channel.js +1 -1
- package/lib/commonjs/components/Channel/Channel.js.map +1 -1
- package/lib/commonjs/components/MessageInput/FileUploadPreview.js +4 -4
- package/lib/commonjs/components/MessageInput/FileUploadPreview.js.map +1 -1
- package/lib/commonjs/components/MessageInput/MessageInput.js +1 -1
- package/lib/commonjs/components/MessageInput/MessageInput.js.map +1 -1
- package/lib/commonjs/contexts/messageInputContext/MessageInputContext.js +38 -54
- package/lib/commonjs/contexts/messageInputContext/MessageInputContext.js.map +1 -1
- package/lib/commonjs/contexts/messageInputContext/hooks/useMessageDetailsForState.js +4 -4
- package/lib/commonjs/contexts/messageInputContext/hooks/useMessageDetailsForState.js.map +1 -1
- package/lib/commonjs/native.js.map +1 -1
- package/lib/commonjs/types/types.js.map +1 -1
- package/lib/commonjs/version.json +1 -1
- package/lib/module/components/Attachment/FileAttachmentGroup.js +1 -1
- package/lib/module/components/Attachment/FileAttachmentGroup.js.map +1 -1
- package/lib/module/components/AttachmentPicker/AttachmentPicker.js +1 -1
- package/lib/module/components/AttachmentPicker/AttachmentPicker.js.map +1 -1
- package/lib/module/components/AttachmentPicker/components/AttachmentPickerItem.js +33 -38
- package/lib/module/components/AttachmentPicker/components/AttachmentPickerItem.js.map +1 -1
- package/lib/module/components/Channel/Channel.js +1 -1
- package/lib/module/components/Channel/Channel.js.map +1 -1
- package/lib/module/components/MessageInput/FileUploadPreview.js +4 -4
- package/lib/module/components/MessageInput/FileUploadPreview.js.map +1 -1
- package/lib/module/components/MessageInput/MessageInput.js +1 -1
- package/lib/module/components/MessageInput/MessageInput.js.map +1 -1
- package/lib/module/contexts/messageInputContext/MessageInputContext.js +38 -54
- package/lib/module/contexts/messageInputContext/MessageInputContext.js.map +1 -1
- package/lib/module/contexts/messageInputContext/hooks/useMessageDetailsForState.js +4 -4
- package/lib/module/contexts/messageInputContext/hooks/useMessageDetailsForState.js.map +1 -1
- package/lib/module/native.js.map +1 -1
- package/lib/module/types/types.js.map +1 -1
- package/lib/module/version.json +1 -1
- package/lib/typescript/contexts/messageInputContext/MessageInputContext.d.ts +1 -1
- package/lib/typescript/native.d.ts +1 -1
- package/lib/typescript/types/types.d.ts +6 -4
- package/package.json +1 -1
- package/src/components/Attachment/FileAttachmentGroup.tsx +1 -1
- package/src/components/AttachmentPicker/AttachmentPicker.tsx +1 -1
- package/src/components/AttachmentPicker/components/AttachmentPickerItem.tsx +25 -23
- package/src/components/Channel/Channel.tsx +1 -1
- package/src/components/MessageInput/FileUploadPreview.tsx +3 -3
- package/src/components/MessageInput/MessageInput.tsx +2 -2
- package/src/components/MessageInput/__tests__/FileUploadPreview.test.js +1 -1
- package/src/contexts/messageInputContext/MessageInputContext.tsx +25 -32
- package/src/contexts/messageInputContext/__tests__/__snapshots__/sendMessage.test.tsx.snap +10 -12
- package/src/contexts/messageInputContext/__tests__/pickFile.test.tsx +2 -2
- package/src/contexts/messageInputContext/hooks/useMessageDetailsForState.ts +2 -2
- package/src/native.ts +1 -1
- package/src/types/types.ts +9 -4
- package/src/version.json +1 -1
|
@@ -11,14 +11,16 @@ export declare type Asset = {
|
|
|
11
11
|
id?: string;
|
|
12
12
|
size?: number | string;
|
|
13
13
|
};
|
|
14
|
-
export declare type
|
|
14
|
+
export declare type FileAssetType = {
|
|
15
15
|
name: string;
|
|
16
|
-
|
|
17
|
-
id?: string;
|
|
16
|
+
mimeType?: string;
|
|
18
17
|
size?: number | string;
|
|
19
|
-
type?: string;
|
|
20
18
|
uri?: string;
|
|
21
19
|
};
|
|
20
|
+
export declare type File = FileAssetType & {
|
|
21
|
+
duration?: string | null;
|
|
22
|
+
id?: string;
|
|
23
|
+
};
|
|
22
24
|
export declare type DefaultAttachmentType = UnknownType & {
|
|
23
25
|
file_size?: number | string;
|
|
24
26
|
mime_type?: string;
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "stream-chat-react-native-core",
|
|
3
3
|
"description": "The official React Native and Expo components for Stream Chat, a service for building chat applications",
|
|
4
|
-
"version": "5.16.0-beta.
|
|
4
|
+
"version": "5.16.0-beta.3",
|
|
5
5
|
"author": {
|
|
6
6
|
"company": "Stream.io Inc",
|
|
7
7
|
"name": "Stream.io Inc"
|
|
@@ -104,7 +104,7 @@ const FileAttachmentGroupWithContext = <
|
|
|
104
104
|
setFilesToDisplay((prevFileUploads) =>
|
|
105
105
|
prevFileUploads.map((fileUpload, id) => ({
|
|
106
106
|
...fileUpload,
|
|
107
|
-
paused: id.toString()
|
|
107
|
+
paused: id.toString() !== index,
|
|
108
108
|
})),
|
|
109
109
|
);
|
|
110
110
|
} else {
|
|
@@ -304,7 +304,7 @@ export const AttachmentPicker = React.forwardRef(
|
|
|
304
304
|
data={selectedPhotos}
|
|
305
305
|
keyExtractor={(item) => item.asset.uri}
|
|
306
306
|
numColumns={numberOfAttachmentPickerImageColumns ?? 3}
|
|
307
|
-
onEndReached={getMorePhotos}
|
|
307
|
+
onEndReached={photoError ? undefined : getMorePhotos}
|
|
308
308
|
renderItem={renderAttachmentPickerItem}
|
|
309
309
|
/>
|
|
310
310
|
</BottomSheet>
|
|
@@ -70,14 +70,16 @@ const AttachmentVideo: React.FC<AttachmentVideoProps> = (props) => {
|
|
|
70
70
|
Alert.alert('Maximum number of files reached');
|
|
71
71
|
return files;
|
|
72
72
|
}
|
|
73
|
+
// We need a mime-type to upload a video file.
|
|
74
|
+
const mimeType = lookup(asset.filename) || 'multipart/form-data';
|
|
73
75
|
return [
|
|
74
76
|
...files,
|
|
75
77
|
{
|
|
76
78
|
duration: durationLabel,
|
|
77
79
|
id: asset.id,
|
|
80
|
+
mimeType,
|
|
78
81
|
name: asset.filename,
|
|
79
82
|
size: asset.fileSize,
|
|
80
|
-
type: 'video',
|
|
81
83
|
uri: asset.uri,
|
|
82
84
|
},
|
|
83
85
|
];
|
|
@@ -174,16 +176,6 @@ const AttachmentImage: React.FC<AttachmentImageProps> = (props) => {
|
|
|
174
176
|
);
|
|
175
177
|
};
|
|
176
178
|
|
|
177
|
-
const getFileType = (asset: Asset) => {
|
|
178
|
-
const { filename } = asset;
|
|
179
|
-
if (filename) {
|
|
180
|
-
const contentType = lookup(filename) || 'multipart/form-data';
|
|
181
|
-
return contentType.startsWith('image/') ? 'image' : 'video';
|
|
182
|
-
} else {
|
|
183
|
-
return asset.type === 'video' ? 'video' : 'image';
|
|
184
|
-
}
|
|
185
|
-
};
|
|
186
|
-
|
|
187
179
|
export const renderAttachmentPickerItem = ({ item }: { item: AttachmentPickerItemType }) => {
|
|
188
180
|
const {
|
|
189
181
|
asset,
|
|
@@ -196,9 +188,29 @@ export const renderAttachmentPickerItem = ({ item }: { item: AttachmentPickerIte
|
|
|
196
188
|
setSelectedImages,
|
|
197
189
|
} = item;
|
|
198
190
|
|
|
199
|
-
|
|
191
|
+
/**
|
|
192
|
+
* Expo Media Library - Result of asset type
|
|
193
|
+
* Native Android - Gives mime type(Eg: image/jpeg, video/mp4, etc.)
|
|
194
|
+
* Native iOS - Gives `image` or `video`
|
|
195
|
+
* Expo Android/iOS - Gives `photo` or `video`
|
|
196
|
+
**/
|
|
197
|
+
const isVideoType = asset.type.includes('video');
|
|
198
|
+
|
|
199
|
+
if (isVideoType) {
|
|
200
|
+
return (
|
|
201
|
+
<AttachmentVideo
|
|
202
|
+
asset={asset}
|
|
203
|
+
ImageOverlaySelectedComponent={ImageOverlaySelectedComponent}
|
|
204
|
+
maxNumberOfFiles={maxNumberOfFiles}
|
|
205
|
+
numberOfAttachmentPickerImageColumns={numberOfAttachmentPickerImageColumns}
|
|
206
|
+
numberOfUploads={numberOfUploads}
|
|
207
|
+
selected={selected}
|
|
208
|
+
setSelectedFiles={setSelectedFiles}
|
|
209
|
+
/>
|
|
210
|
+
);
|
|
211
|
+
}
|
|
200
212
|
|
|
201
|
-
return
|
|
213
|
+
return (
|
|
202
214
|
<AttachmentImage
|
|
203
215
|
asset={asset}
|
|
204
216
|
ImageOverlaySelectedComponent={ImageOverlaySelectedComponent}
|
|
@@ -208,16 +220,6 @@ export const renderAttachmentPickerItem = ({ item }: { item: AttachmentPickerIte
|
|
|
208
220
|
selected={selected}
|
|
209
221
|
setSelectedImages={setSelectedImages}
|
|
210
222
|
/>
|
|
211
|
-
) : (
|
|
212
|
-
<AttachmentVideo
|
|
213
|
-
asset={asset}
|
|
214
|
-
ImageOverlaySelectedComponent={ImageOverlaySelectedComponent}
|
|
215
|
-
maxNumberOfFiles={maxNumberOfFiles}
|
|
216
|
-
numberOfAttachmentPickerImageColumns={numberOfAttachmentPickerImageColumns}
|
|
217
|
-
numberOfUploads={numberOfUploads}
|
|
218
|
-
selected={selected}
|
|
219
|
-
setSelectedFiles={setSelectedFiles}
|
|
220
|
-
/>
|
|
221
223
|
);
|
|
222
224
|
};
|
|
223
225
|
|
|
@@ -1324,7 +1324,7 @@ const ChannelWithContext = <
|
|
|
1324
1324
|
) {
|
|
1325
1325
|
const response = doDocUploadRequest
|
|
1326
1326
|
? await doDocUploadRequest(file, channel)
|
|
1327
|
-
: await channel.sendFile(file.uri, file.name, file.
|
|
1327
|
+
: await channel.sendFile(file.uri, file.name, file.mimeType);
|
|
1328
1328
|
attachment.asset_url = response.file;
|
|
1329
1329
|
if (response.thumb_url) {
|
|
1330
1330
|
attachment.thumb_url = response.thumb_url;
|
|
@@ -183,7 +183,7 @@ const FileUploadPreviewWithContext = <
|
|
|
183
183
|
setFileUploads((prevFileUploads) =>
|
|
184
184
|
prevFileUploads.map((fileUpload) => ({
|
|
185
185
|
...fileUpload,
|
|
186
|
-
paused: fileUpload.id
|
|
186
|
+
paused: fileUpload.id !== index,
|
|
187
187
|
})),
|
|
188
188
|
);
|
|
189
189
|
} else {
|
|
@@ -228,7 +228,7 @@ const FileUploadPreviewWithContext = <
|
|
|
228
228
|
style={styles.overlay}
|
|
229
229
|
type={indicatorType}
|
|
230
230
|
>
|
|
231
|
-
{item.file.
|
|
231
|
+
{item.file.mimeType?.startsWith('audio/') && isAudioPackageAvailable() ? (
|
|
232
232
|
<View
|
|
233
233
|
style={[
|
|
234
234
|
{ marginBottom: item.state === FileState.UPLOADED ? 8 : 0 },
|
|
@@ -279,7 +279,7 @@ const FileUploadPreviewWithContext = <
|
|
|
279
279
|
>
|
|
280
280
|
<View style={[styles.fileContentContainer, fileContentContainer]}>
|
|
281
281
|
<View style={styles.fileIcon}>
|
|
282
|
-
<FileAttachmentIcon mimeType={item.file.
|
|
282
|
+
<FileAttachmentIcon mimeType={item.file.mimeType} />
|
|
283
283
|
</View>
|
|
284
284
|
<View style={[styles.fileTextContainer, fileTextContainer]}>
|
|
285
285
|
<Text
|
|
@@ -406,15 +406,15 @@ const MessageInputWithContext = <
|
|
|
406
406
|
} else if (fileUploadsLength > selectedFilesLength) {
|
|
407
407
|
/**
|
|
408
408
|
* User is editing some message which contains video attachments OR
|
|
409
|
-
* video attachment is added from custom image picker (other than the default
|
|
409
|
+
* video attachment is added from custom image picker (other than the default bottom-sheet image picker)
|
|
410
410
|
* using `uploadNewFile` function from `MessageInputContext`.
|
|
411
411
|
**/
|
|
412
412
|
setSelectedFiles(
|
|
413
413
|
fileUploads.map((fileUpload) => ({
|
|
414
414
|
duration: fileUpload.file.duration,
|
|
415
|
+
mimeType: fileUpload.file.mimeType,
|
|
415
416
|
name: fileUpload.file.name,
|
|
416
417
|
size: fileUpload.file.size,
|
|
417
|
-
type: fileUpload.file.type,
|
|
418
418
|
uri: fileUpload.file.uri,
|
|
419
419
|
})),
|
|
420
420
|
);
|
|
@@ -318,8 +318,8 @@ describe('FileUploadPreview', () => {
|
|
|
318
318
|
const fileUploads = [
|
|
319
319
|
generateFileUploadPreview({
|
|
320
320
|
id: 'file-upload-id-1',
|
|
321
|
+
mimeType: 'audio/mp3',
|
|
321
322
|
state: FileState.UPLOADED,
|
|
322
|
-
type: 'audio/mp3',
|
|
323
323
|
}),
|
|
324
324
|
];
|
|
325
325
|
const removeFile = jest.fn();
|
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import React, { PropsWithChildren, useContext, useEffect, useRef, useState } from 'react';
|
|
2
|
-
|
|
3
1
|
import type { LegacyRef } from 'react';
|
|
2
|
+
import React, { PropsWithChildren, useContext, useEffect, useRef, useState } from 'react';
|
|
4
3
|
import type { TextInput, TextInputProps } from 'react-native';
|
|
5
4
|
import { Alert, Keyboard, Platform } from 'react-native';
|
|
6
5
|
|
|
@@ -591,14 +590,14 @@ export const MessageInputProvider = <
|
|
|
591
590
|
const MEGA_BYTES_TO_BYTES = 1024 * 1024;
|
|
592
591
|
const MAX_FILE_SIZE_TO_UPLOAD_IN_MB = 100;
|
|
593
592
|
|
|
594
|
-
if (!result.cancelled && result.
|
|
595
|
-
const totalFileSize = result.
|
|
593
|
+
if (!result.cancelled && result.assets) {
|
|
594
|
+
const totalFileSize = result.assets.reduce((acc, asset) => acc + Number(asset.size), 0);
|
|
596
595
|
if (totalFileSize / MEGA_BYTES_TO_BYTES > MAX_FILE_SIZE_TO_UPLOAD_IN_MB) {
|
|
597
596
|
Alert.alert(
|
|
598
597
|
`Maximum file size upload limit reached, please upload files below ${MAX_FILE_SIZE_TO_UPLOAD_IN_MB}MB.`,
|
|
599
598
|
);
|
|
600
599
|
} else {
|
|
601
|
-
result.
|
|
600
|
+
result.assets.forEach((asset) => {
|
|
602
601
|
/**
|
|
603
602
|
* TODO: The current tight coupling of images to the image
|
|
604
603
|
* picker does not allow images picked from the file picker
|
|
@@ -606,7 +605,7 @@ export const MessageInputProvider = <
|
|
|
606
605
|
* This should be updated alongside allowing image a file
|
|
607
606
|
* uploads together.
|
|
608
607
|
*/
|
|
609
|
-
uploadNewFile(
|
|
608
|
+
uploadNewFile(asset);
|
|
610
609
|
});
|
|
611
610
|
}
|
|
612
611
|
}
|
|
@@ -652,31 +651,30 @@ export const MessageInputProvider = <
|
|
|
652
651
|
};
|
|
653
652
|
|
|
654
653
|
const mapFileUploadToAttachment = (file: FileUpload) => {
|
|
655
|
-
|
|
656
|
-
if (file.file.type?.startsWith('image/')) {
|
|
654
|
+
if (file.file.mimeType?.startsWith('image/')) {
|
|
657
655
|
return {
|
|
658
656
|
fallback: file.file.name,
|
|
659
657
|
image_url: file.url,
|
|
660
|
-
mime_type:
|
|
658
|
+
mime_type: file.file.mimeType,
|
|
661
659
|
originalFile: file.file,
|
|
662
660
|
type: 'image',
|
|
663
661
|
};
|
|
664
|
-
} else if (file.file.
|
|
662
|
+
} else if (file.file.mimeType?.startsWith('audio/')) {
|
|
665
663
|
return {
|
|
666
664
|
asset_url: file.url || file.file.uri,
|
|
667
665
|
duration: file.file.duration,
|
|
668
666
|
file_size: file.file.size,
|
|
669
|
-
mime_type: file.file.
|
|
667
|
+
mime_type: file.file.mimeType,
|
|
670
668
|
originalFile: file.file,
|
|
671
669
|
title: file.file.name,
|
|
672
670
|
type: 'audio',
|
|
673
671
|
};
|
|
674
|
-
} else if (file.file.
|
|
672
|
+
} else if (file.file.mimeType?.startsWith('video/')) {
|
|
675
673
|
return {
|
|
676
674
|
asset_url: file.url || file.file.uri,
|
|
677
675
|
duration: file.file.duration,
|
|
678
676
|
file_size: file.file.size,
|
|
679
|
-
mime_type: file.file.
|
|
677
|
+
mime_type: file.file.mimeType,
|
|
680
678
|
originalFile: file.file,
|
|
681
679
|
thumb_url: file.thumb_url,
|
|
682
680
|
title: file.file.name,
|
|
@@ -686,7 +684,7 @@ export const MessageInputProvider = <
|
|
|
686
684
|
return {
|
|
687
685
|
asset_url: file.url || file.file.uri,
|
|
688
686
|
file_size: file.file.size,
|
|
689
|
-
mime_type: file.file.
|
|
687
|
+
mime_type: file.file.mimeType,
|
|
690
688
|
originalFile: file.file,
|
|
691
689
|
title: file.file.name,
|
|
692
690
|
type: 'file',
|
|
@@ -915,14 +913,15 @@ export const MessageInputProvider = <
|
|
|
915
913
|
}
|
|
916
914
|
};
|
|
917
915
|
|
|
918
|
-
const
|
|
916
|
+
const regexCondition = /File (extension \.\w{2,4}|type \S+) is not supported/;
|
|
919
917
|
|
|
920
|
-
const getUploadSetStateAction =
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
918
|
+
const getUploadSetStateAction =
|
|
919
|
+
<UploadType extends ImageUpload | FileUpload>(
|
|
920
|
+
id: string,
|
|
921
|
+
fileState: FileStateValue,
|
|
922
|
+
extraData: Partial<UploadType> = {},
|
|
923
|
+
): React.SetStateAction<UploadType[]> =>
|
|
924
|
+
(prevUploads: UploadType[]) =>
|
|
926
925
|
prevUploads.map((prevUpload) => {
|
|
927
926
|
if (prevUpload.id === id) {
|
|
928
927
|
return {
|
|
@@ -934,14 +933,11 @@ export const MessageInputProvider = <
|
|
|
934
933
|
return prevUpload;
|
|
935
934
|
});
|
|
936
935
|
|
|
937
|
-
return uploads;
|
|
938
|
-
};
|
|
939
|
-
|
|
940
936
|
const handleFileOrImageUploadError = (error: unknown, isImageError: boolean, id: string) => {
|
|
941
937
|
if (isImageError) {
|
|
942
938
|
setNumberOfUploads((prevNumberOfUploads) => prevNumberOfUploads - 1);
|
|
943
939
|
if (error instanceof Error) {
|
|
944
|
-
if (
|
|
940
|
+
if (regexCondition.test(error.message)) {
|
|
945
941
|
return setImageUploads(getUploadSetStateAction(id, FileState.NOT_SUPPORTED));
|
|
946
942
|
}
|
|
947
943
|
|
|
@@ -951,7 +947,7 @@ export const MessageInputProvider = <
|
|
|
951
947
|
setNumberOfUploads((prevNumberOfUploads) => prevNumberOfUploads - 1);
|
|
952
948
|
|
|
953
949
|
if (error instanceof Error) {
|
|
954
|
-
if (
|
|
950
|
+
if (regexCondition.test(error.message)) {
|
|
955
951
|
return setFileUploads(getUploadSetStateAction(id, FileState.NOT_SUPPORTED));
|
|
956
952
|
}
|
|
957
953
|
return setFileUploads(getUploadSetStateAction(id, FileState.UPLOAD_FAILED));
|
|
@@ -969,9 +965,7 @@ export const MessageInputProvider = <
|
|
|
969
965
|
if (value.doDocUploadRequest) {
|
|
970
966
|
response = await value.doDocUploadRequest(file, channel);
|
|
971
967
|
} else if (channel && file.uri) {
|
|
972
|
-
|
|
973
|
-
const localAssetURI = Platform.OS === 'ios' && file.id && (await getLocalAssetUri(file.id));
|
|
974
|
-
response = await channel.sendFile(localAssetURI || file.uri, file.name, file.type);
|
|
968
|
+
response = await channel.sendFile(file.uri, file.name, file.mimeType);
|
|
975
969
|
}
|
|
976
970
|
const extraData: Partial<FileUpload> = { thumb_url: response.thumb_url, url: response.file };
|
|
977
971
|
setFileUploads(getUploadSetStateAction(id, FileState.UPLOADED, extraData));
|
|
@@ -996,7 +990,7 @@ export const MessageInputProvider = <
|
|
|
996
990
|
/**
|
|
997
991
|
* We skip compression if:
|
|
998
992
|
* - the file is from the camera as that should already be compressed
|
|
999
|
-
* - the file has
|
|
993
|
+
* - the file has no height/width value to maintain for compression
|
|
1000
994
|
* - the compressImageQuality number is not present or is 1 (meaning no compression)
|
|
1001
995
|
*/
|
|
1002
996
|
const compressedUri = await (file.source === 'camera' ||
|
|
@@ -1055,7 +1049,6 @@ export const MessageInputProvider = <
|
|
|
1055
1049
|
|
|
1056
1050
|
const uploadNewFile = async (file: File) => {
|
|
1057
1051
|
const id: string = generateRandomId();
|
|
1058
|
-
const mimeType: string | boolean = lookup(file.name);
|
|
1059
1052
|
|
|
1060
1053
|
const isBlockedFileExtension: boolean | undefined = blockedFileExtensionTypes?.some(
|
|
1061
1054
|
(fileExtensionType: string) => file.name?.includes(fileExtensionType),
|
|
@@ -1071,7 +1064,7 @@ export const MessageInputProvider = <
|
|
|
1071
1064
|
|
|
1072
1065
|
const newFile: FileUpload = {
|
|
1073
1066
|
duration: 0,
|
|
1074
|
-
file
|
|
1067
|
+
file,
|
|
1075
1068
|
id: file.id || id,
|
|
1076
1069
|
paused: true,
|
|
1077
1070
|
progress: 0,
|
|
@@ -42,7 +42,7 @@ Object {
|
|
|
42
42
|
Object {
|
|
43
43
|
"asset_url": undefined,
|
|
44
44
|
"file_size": undefined,
|
|
45
|
-
"mime_type":
|
|
45
|
+
"mime_type": undefined,
|
|
46
46
|
"originalFile": Object {
|
|
47
47
|
"name": "dummy.pdf",
|
|
48
48
|
"state": "uploaded",
|
|
@@ -53,41 +53,39 @@ Object {
|
|
|
53
53
|
},
|
|
54
54
|
Object {
|
|
55
55
|
"asset_url": undefined,
|
|
56
|
-
"duration": undefined,
|
|
57
56
|
"file_size": undefined,
|
|
58
|
-
"mime_type":
|
|
57
|
+
"mime_type": undefined,
|
|
59
58
|
"originalFile": Object {
|
|
60
59
|
"name": "dummy.pdf",
|
|
61
60
|
"state": "finished",
|
|
62
61
|
"type": "video/mp4",
|
|
63
62
|
},
|
|
64
|
-
"thumb_url": undefined,
|
|
65
63
|
"title": "dummy.pdf",
|
|
66
|
-
"type": "
|
|
64
|
+
"type": "file",
|
|
67
65
|
},
|
|
68
66
|
Object {
|
|
69
67
|
"asset_url": undefined,
|
|
70
|
-
"duration": undefined,
|
|
71
68
|
"file_size": undefined,
|
|
72
|
-
"mime_type":
|
|
69
|
+
"mime_type": undefined,
|
|
73
70
|
"originalFile": Object {
|
|
74
71
|
"name": "dummy.pdf",
|
|
75
72
|
"state": "uploaded",
|
|
76
73
|
"type": "audio/mp3",
|
|
77
74
|
},
|
|
78
75
|
"title": "dummy.pdf",
|
|
79
|
-
"type": "
|
|
76
|
+
"type": "file",
|
|
80
77
|
},
|
|
81
78
|
Object {
|
|
82
|
-
"
|
|
83
|
-
"
|
|
84
|
-
"mime_type":
|
|
79
|
+
"asset_url": undefined,
|
|
80
|
+
"file_size": undefined,
|
|
81
|
+
"mime_type": undefined,
|
|
85
82
|
"originalFile": Object {
|
|
86
83
|
"name": "dummy.pdf",
|
|
87
84
|
"state": "finished",
|
|
88
85
|
"type": "image/jpeg",
|
|
89
86
|
},
|
|
90
|
-
"
|
|
87
|
+
"title": "dummy.pdf",
|
|
88
|
+
"type": "file",
|
|
91
89
|
},
|
|
92
90
|
],
|
|
93
91
|
"mentioned_users": Array [
|
|
@@ -40,11 +40,11 @@ describe("MessageInputContext's pickFile", () => {
|
|
|
40
40
|
jest.spyOn(Alert, 'alert');
|
|
41
41
|
jest.spyOn(NativeUtils, 'pickDocument').mockImplementation(
|
|
42
42
|
jest.fn().mockResolvedValue({
|
|
43
|
-
|
|
44
|
-
docs: [
|
|
43
|
+
assets: [
|
|
45
44
|
generateFileAttachment({ size: 500000000 }),
|
|
46
45
|
generateFileAttachment({ size: 600000000 }),
|
|
47
46
|
],
|
|
47
|
+
cancelled: false,
|
|
48
48
|
}),
|
|
49
49
|
);
|
|
50
50
|
|
|
@@ -54,9 +54,9 @@ export const useMessageDetailsForState = <
|
|
|
54
54
|
const id = generateRandomId();
|
|
55
55
|
newFileUploads.push({
|
|
56
56
|
file: {
|
|
57
|
+
mimeType: attachment.mime_type,
|
|
57
58
|
name: attachment.title || '',
|
|
58
59
|
size: attachment.file_size,
|
|
59
|
-
type: attachment.mime_type,
|
|
60
60
|
},
|
|
61
61
|
id,
|
|
62
62
|
state: 'finished',
|
|
@@ -78,9 +78,9 @@ export const useMessageDetailsForState = <
|
|
|
78
78
|
const id = generateRandomId();
|
|
79
79
|
newFileUploads.push({
|
|
80
80
|
file: {
|
|
81
|
+
mimeType: attachment.mime_type,
|
|
81
82
|
name: attachment.title || '',
|
|
82
83
|
size: attachment.file_size,
|
|
83
|
-
type: attachment.mime_type,
|
|
84
84
|
},
|
|
85
85
|
id,
|
|
86
86
|
state: 'finished',
|
package/src/native.ts
CHANGED
package/src/types/types.ts
CHANGED
|
@@ -13,15 +13,19 @@ export type Asset = {
|
|
|
13
13
|
size?: number | string;
|
|
14
14
|
};
|
|
15
15
|
|
|
16
|
-
export type
|
|
16
|
+
export type FileAssetType = {
|
|
17
17
|
name: string;
|
|
18
|
-
|
|
19
|
-
id?: string;
|
|
18
|
+
mimeType?: string;
|
|
20
19
|
size?: number | string;
|
|
21
|
-
type
|
|
20
|
+
// The uri should be of type `string`. But is `string|undefined` because the same type is used for the response from Stream's Attachment. This shall be fixed.
|
|
22
21
|
uri?: string;
|
|
23
22
|
};
|
|
24
23
|
|
|
24
|
+
export type File = FileAssetType & {
|
|
25
|
+
duration?: string | null;
|
|
26
|
+
id?: string;
|
|
27
|
+
};
|
|
28
|
+
|
|
25
29
|
export type DefaultAttachmentType = UnknownType & {
|
|
26
30
|
file_size?: number | string;
|
|
27
31
|
mime_type?: string;
|
|
@@ -34,6 +38,7 @@ interface DefaultUserType extends UnknownType {
|
|
|
34
38
|
|
|
35
39
|
interface DefaultChannelType extends UnknownType {
|
|
36
40
|
[key: string]: unknown;
|
|
41
|
+
|
|
37
42
|
image?: string;
|
|
38
43
|
}
|
|
39
44
|
|
package/src/version.json
CHANGED