stream-chat-react-native 5.15.1-beta.1 → 5.15.1-beta.2

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/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "stream-chat-react-native",
3
3
  "description": "The official React Native SDK for Stream Chat, a service for building chat applications",
4
- "version": "5.15.1-beta.1",
4
+ "version": "5.15.1-beta.2",
5
5
  "author": {
6
6
  "company": "Stream.io Inc",
7
7
  "name": "Stream.io Inc"
@@ -11,7 +11,7 @@
11
11
  "types": "types/index.d.ts",
12
12
  "dependencies": {
13
13
  "es6-symbol": "^3.1.3",
14
- "stream-chat-react-native-core": "5.15.1-beta.1"
14
+ "stream-chat-react-native-core": "5.15.1-beta.2"
15
15
  },
16
16
  "peerDependencies": {
17
17
  "@react-native-camera-roll/camera-roll": ">=5.0.0",
@@ -19,7 +19,7 @@
19
19
  "@react-native-clipboard/clipboard": "^1.11.1",
20
20
  "@stream-io/flat-list-mvcp": "^0.10.3",
21
21
  "react-native": ">=0.60.0",
22
- "react-native-document-picker": ">=3.2.0",
22
+ "react-native-document-picker": ">=9.0.1",
23
23
  "react-native-fs": ">=2.16.6",
24
24
  "react-native-haptic-feedback": ">=1.11.0",
25
25
  "react-native-image-crop-picker": ">=0.33.2",
@@ -1,6 +1,13 @@
1
1
  import { PermissionsAndroid, Platform } from 'react-native';
2
2
 
3
3
  import { CameraRoll, GetPhotosParams } from '@react-native-camera-roll/camera-roll';
4
+ import type { Asset } from 'stream-chat-react-native-core';
5
+
6
+ type ReturnType = {
7
+ assets: Array<Omit<Asset, 'source'> & { source: 'picker' }>;
8
+ endCursor: string | undefined;
9
+ hasNextPage: boolean;
10
+ };
4
11
 
5
12
  const verifyAndroidPermissions = async () => {
6
13
  const isRN71orAbove = Platform.constants.reactNativeVersion?.minor >= 71;
@@ -49,7 +56,10 @@ const verifyAndroidPermissions = async () => {
49
56
  return true;
50
57
  };
51
58
 
52
- export const getPhotos = async ({ after, first }: Pick<GetPhotosParams, 'after' | 'first'>) => {
59
+ export const getPhotos = async ({
60
+ after,
61
+ first,
62
+ }: Pick<GetPhotosParams, 'after' | 'first'>): Promise<ReturnType> => {
53
63
  try {
54
64
  if (Platform.OS === 'android') {
55
65
  const granted = await verifyAndroidPermissions();
@@ -65,7 +75,12 @@ export const getPhotos = async ({ after, first }: Pick<GetPhotosParams, 'after'
65
75
  });
66
76
  const assets = results.edges.map((edge) => ({
67
77
  ...edge.node.image,
68
- source: 'picker',
78
+ duration: edge.node.image.playableDuration,
79
+ // since we include filename, fileSize in the query, we can safely assume it will be defined
80
+ filename: edge.node.image.filename as string,
81
+ fileSize: edge.node.image.fileSize as number,
82
+ source: 'picker' as const,
83
+ type: edge.node.type,
69
84
  }));
70
85
  const hasNextPage = results.page_info.has_next_page;
71
86
  const endCursor = results.page_info.end_cursor;
@@ -10,10 +10,12 @@ type ResponseValue = {
10
10
  uri: string;
11
11
  };
12
12
 
13
- let DocumentPicker: {
14
- pickMultiple: (opts?: { type: string[] }) => Promise<ResponseValue[]>;
15
- types: { allFiles: string };
16
- };
13
+ let DocumentPicker:
14
+ | {
15
+ pick: (opts?: { allowMultiSelection: boolean; type: string[] }) => Promise<ResponseValue[]>;
16
+ types: { allFiles: string };
17
+ }
18
+ | undefined;
17
19
 
18
20
  try {
19
21
  DocumentPicker = require('react-native-document-picker').default;
@@ -24,7 +26,9 @@ try {
24
26
  export const pickDocument = DocumentPicker
25
27
  ? async ({ maxNumberOfFiles }: { maxNumberOfFiles: number }) => {
26
28
  try {
27
- let res = await DocumentPicker.pickMultiple({
29
+ if (!DocumentPicker) return { cancelled: true };
30
+ let res: ResponseValue[] = await DocumentPicker.pick({
31
+ allowMultiSelection: true,
28
32
  type: [DocumentPicker.types.allFiles],
29
33
  });
30
34