stream-chat-react-native-core 5.8.1-beta.2 → 5.8.1-beta.4
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/AttachmentPicker/components/AttachmentPickerItem.js +38 -65
- package/lib/commonjs/components/AttachmentPicker/components/AttachmentPickerItem.js.map +1 -1
- package/lib/commonjs/components/ChannelList/ChannelList.js +2 -4
- package/lib/commonjs/components/ChannelList/ChannelList.js.map +1 -1
- package/lib/commonjs/components/ChannelList/hooks/listeners/useNewMessage.js +2 -5
- package/lib/commonjs/components/ChannelList/hooks/listeners/useNewMessage.js.map +1 -1
- package/lib/commonjs/components/ChannelList/hooks/listeners/useNewMessageNotification.js +8 -11
- package/lib/commonjs/components/ChannelList/hooks/listeners/useNewMessageNotification.js.map +1 -1
- package/lib/commonjs/components/MessageInput/FileUploadPreview.js +22 -21
- package/lib/commonjs/components/MessageInput/FileUploadPreview.js.map +1 -1
- package/lib/commonjs/contexts/messageInputContext/MessageInputContext.js +82 -112
- package/lib/commonjs/contexts/messageInputContext/MessageInputContext.js.map +1 -1
- package/lib/commonjs/types/types.js.map +1 -1
- package/lib/commonjs/version.json +1 -1
- package/lib/module/components/AttachmentPicker/components/AttachmentPickerItem.js +38 -65
- package/lib/module/components/AttachmentPicker/components/AttachmentPickerItem.js.map +1 -1
- package/lib/module/components/ChannelList/ChannelList.js +2 -4
- package/lib/module/components/ChannelList/ChannelList.js.map +1 -1
- package/lib/module/components/ChannelList/hooks/listeners/useNewMessage.js +2 -5
- package/lib/module/components/ChannelList/hooks/listeners/useNewMessage.js.map +1 -1
- package/lib/module/components/ChannelList/hooks/listeners/useNewMessageNotification.js +8 -11
- package/lib/module/components/ChannelList/hooks/listeners/useNewMessageNotification.js.map +1 -1
- package/lib/module/components/MessageInput/FileUploadPreview.js +22 -21
- package/lib/module/components/MessageInput/FileUploadPreview.js.map +1 -1
- package/lib/module/contexts/messageInputContext/MessageInputContext.js +82 -112
- package/lib/module/contexts/messageInputContext/MessageInputContext.js.map +1 -1
- package/lib/module/types/types.js.map +1 -1
- package/lib/module/version.json +1 -1
- package/lib/typescript/components/ChannelList/hooks/listeners/useNewMessage.d.ts +2 -3
- package/lib/typescript/components/ChannelList/hooks/listeners/useNewMessageNotification.d.ts +2 -3
- package/lib/typescript/contexts/messageInputContext/MessageInputContext.d.ts +1 -6
- package/lib/typescript/types/types.d.ts +1 -0
- package/package.json +1 -1
- package/src/components/AttachmentPicker/components/AttachmentPickerItem.tsx +3 -5
- package/src/components/ChannelList/ChannelList.tsx +0 -2
- package/src/components/ChannelList/hooks/listeners/useNewMessage.ts +2 -14
- package/src/components/ChannelList/hooks/listeners/useNewMessageNotification.ts +2 -8
- package/src/components/MessageInput/FileUploadPreview.tsx +1 -0
- package/src/contexts/messageInputContext/MessageInputContext.tsx +10 -32
- package/src/types/types.ts +1 -0
- package/src/version.json +1 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React, { PropsWithChildren, useContext, useEffect, useRef, useState } from 'react';
|
|
2
2
|
|
|
3
|
-
import { Alert, Keyboard } from 'react-native';
|
|
3
|
+
import { Alert, Keyboard, Platform } from 'react-native';
|
|
4
4
|
|
|
5
5
|
import type { TextInput, TextInputProps } from 'react-native';
|
|
6
6
|
|
|
@@ -327,12 +327,7 @@ export type InputMessageInputContextValue<
|
|
|
327
327
|
* @overrideType Function
|
|
328
328
|
*/
|
|
329
329
|
doDocUploadRequest?: (
|
|
330
|
-
file:
|
|
331
|
-
name: string;
|
|
332
|
-
size?: string | number;
|
|
333
|
-
type?: string;
|
|
334
|
-
uri?: string;
|
|
335
|
-
},
|
|
330
|
+
file: File,
|
|
336
331
|
channel: ChannelContextValue<StreamChatGenerics>['channel'],
|
|
337
332
|
) => Promise<SendFileAPIResponse>;
|
|
338
333
|
/**
|
|
@@ -972,7 +967,9 @@ export const MessageInputProvider = <
|
|
|
972
967
|
if (value.doDocUploadRequest) {
|
|
973
968
|
response = await value.doDocUploadRequest(file, channel);
|
|
974
969
|
} else if (channel && file.uri) {
|
|
975
|
-
|
|
970
|
+
// For the case of expo messaging app where you need to fetch the file uri from file id. Here it is only done for iOS since for android the file.uri is fine.
|
|
971
|
+
const localAssetURI = Platform.OS === 'ios' && file.id && (await getLocalAssetUri(file.id));
|
|
972
|
+
response = await channel.sendFile(localAssetURI || file.uri, file.name, file.type);
|
|
976
973
|
}
|
|
977
974
|
const extraData: Partial<FileUpload> = { thumb_url: response.thumb_url, url: response.file };
|
|
978
975
|
setFileUploads(getUploadSetStateAction(id, FileState.UPLOADED, extraData));
|
|
@@ -991,23 +988,9 @@ export const MessageInputProvider = <
|
|
|
991
988
|
let response = {} as SendFileAPIResponse;
|
|
992
989
|
|
|
993
990
|
try {
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
* only, if that file id exits we call getLocalAssetUri to download
|
|
998
|
-
* the asset for expo before uploading it. We do the same for native
|
|
999
|
-
* if the uri includes assets-library, this uses the CameraRoll.save
|
|
1000
|
-
* function to also create a local uri.
|
|
1001
|
-
*/
|
|
1002
|
-
const getLocalUri = async () => {
|
|
1003
|
-
if (file.id) {
|
|
1004
|
-
return await getLocalAssetUri(file.id);
|
|
1005
|
-
} else if (file.uri?.match(/assets-library/)) {
|
|
1006
|
-
return await getLocalAssetUri(file.uri);
|
|
1007
|
-
}
|
|
1008
|
-
return file.uri;
|
|
1009
|
-
};
|
|
1010
|
-
const uri = file.name || (await getLocalUri()) || '';
|
|
991
|
+
// For the case of expo messaging app where you need to fetch the file uri from file id. Here it is only done for iOS since for android the file.uri is fine.
|
|
992
|
+
const localAssetURI = Platform.OS === 'ios' && file.id && (await getLocalAssetUri(file.id));
|
|
993
|
+
const uri = localAssetURI || file.uri || '';
|
|
1011
994
|
/**
|
|
1012
995
|
* We skip compression if:
|
|
1013
996
|
* - the file is from the camera as that should already be compressed
|
|
@@ -1068,12 +1051,7 @@ export const MessageInputProvider = <
|
|
|
1068
1051
|
}
|
|
1069
1052
|
};
|
|
1070
1053
|
|
|
1071
|
-
const uploadNewFile = async (file: {
|
|
1072
|
-
name: string;
|
|
1073
|
-
size?: number | string;
|
|
1074
|
-
type?: string;
|
|
1075
|
-
uri?: string;
|
|
1076
|
-
}) => {
|
|
1054
|
+
const uploadNewFile = async (file: File) => {
|
|
1077
1055
|
const id: string = generateRandomId();
|
|
1078
1056
|
const mimeType: string | boolean = lookup(file.name);
|
|
1079
1057
|
|
|
@@ -1092,7 +1070,7 @@ export const MessageInputProvider = <
|
|
|
1092
1070
|
const newFile: FileUpload = {
|
|
1093
1071
|
duration: 0,
|
|
1094
1072
|
file: { ...file, type: mimeType || file?.type },
|
|
1095
|
-
id,
|
|
1073
|
+
id: file.id || id,
|
|
1096
1074
|
paused: true,
|
|
1097
1075
|
progress: 0,
|
|
1098
1076
|
state: fileState,
|
package/src/types/types.ts
CHANGED
package/src/version.json
CHANGED