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.
Files changed (41) hide show
  1. package/lib/commonjs/components/AttachmentPicker/components/AttachmentPickerItem.js +38 -65
  2. package/lib/commonjs/components/AttachmentPicker/components/AttachmentPickerItem.js.map +1 -1
  3. package/lib/commonjs/components/ChannelList/ChannelList.js +2 -4
  4. package/lib/commonjs/components/ChannelList/ChannelList.js.map +1 -1
  5. package/lib/commonjs/components/ChannelList/hooks/listeners/useNewMessage.js +2 -5
  6. package/lib/commonjs/components/ChannelList/hooks/listeners/useNewMessage.js.map +1 -1
  7. package/lib/commonjs/components/ChannelList/hooks/listeners/useNewMessageNotification.js +8 -11
  8. package/lib/commonjs/components/ChannelList/hooks/listeners/useNewMessageNotification.js.map +1 -1
  9. package/lib/commonjs/components/MessageInput/FileUploadPreview.js +22 -21
  10. package/lib/commonjs/components/MessageInput/FileUploadPreview.js.map +1 -1
  11. package/lib/commonjs/contexts/messageInputContext/MessageInputContext.js +82 -112
  12. package/lib/commonjs/contexts/messageInputContext/MessageInputContext.js.map +1 -1
  13. package/lib/commonjs/types/types.js.map +1 -1
  14. package/lib/commonjs/version.json +1 -1
  15. package/lib/module/components/AttachmentPicker/components/AttachmentPickerItem.js +38 -65
  16. package/lib/module/components/AttachmentPicker/components/AttachmentPickerItem.js.map +1 -1
  17. package/lib/module/components/ChannelList/ChannelList.js +2 -4
  18. package/lib/module/components/ChannelList/ChannelList.js.map +1 -1
  19. package/lib/module/components/ChannelList/hooks/listeners/useNewMessage.js +2 -5
  20. package/lib/module/components/ChannelList/hooks/listeners/useNewMessage.js.map +1 -1
  21. package/lib/module/components/ChannelList/hooks/listeners/useNewMessageNotification.js +8 -11
  22. package/lib/module/components/ChannelList/hooks/listeners/useNewMessageNotification.js.map +1 -1
  23. package/lib/module/components/MessageInput/FileUploadPreview.js +22 -21
  24. package/lib/module/components/MessageInput/FileUploadPreview.js.map +1 -1
  25. package/lib/module/contexts/messageInputContext/MessageInputContext.js +82 -112
  26. package/lib/module/contexts/messageInputContext/MessageInputContext.js.map +1 -1
  27. package/lib/module/types/types.js.map +1 -1
  28. package/lib/module/version.json +1 -1
  29. package/lib/typescript/components/ChannelList/hooks/listeners/useNewMessage.d.ts +2 -3
  30. package/lib/typescript/components/ChannelList/hooks/listeners/useNewMessageNotification.d.ts +2 -3
  31. package/lib/typescript/contexts/messageInputContext/MessageInputContext.d.ts +1 -6
  32. package/lib/typescript/types/types.d.ts +1 -0
  33. package/package.json +1 -1
  34. package/src/components/AttachmentPicker/components/AttachmentPickerItem.tsx +3 -5
  35. package/src/components/ChannelList/ChannelList.tsx +0 -2
  36. package/src/components/ChannelList/hooks/listeners/useNewMessage.ts +2 -14
  37. package/src/components/ChannelList/hooks/listeners/useNewMessageNotification.ts +2 -8
  38. package/src/components/MessageInput/FileUploadPreview.tsx +1 -0
  39. package/src/contexts/messageInputContext/MessageInputContext.tsx +10 -32
  40. package/src/types/types.ts +1 -0
  41. 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
- response = await channel.sendFile(file.uri, file.name, file.type);
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
- * Expo now uses the assets-library which is also how remote
996
- * native files are presented. We now return a file id from Expo
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,
@@ -17,6 +17,7 @@ export type Asset = {
17
17
  export type File = {
18
18
  name: string;
19
19
  duration?: string | null;
20
+ id?: string;
20
21
  size?: number | string;
21
22
  type?: string;
22
23
  uri?: string;
package/src/version.json CHANGED
@@ -1,3 +1,3 @@
1
1
  {
2
- "version": "5.8.1-beta.2"
2
+ "version": "5.8.1-beta.4"
3
3
  }