stream-chat-react-native 5.6.0-beta.1 → 5.6.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/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.6.0-beta.1",
4
+ "version": "5.6.0-beta.3",
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.6.0-beta.1"
14
+ "stream-chat-react-native-core": "5.6.0-beta.3"
15
15
  },
16
16
  "peerDependencies": {
17
17
  "@react-native-camera-roll/camera-roll": "^5.0.0",
@@ -1,27 +1,50 @@
1
- import DocumentPicker from 'react-native-document-picker';
1
+ /**
2
+ * Types are approximated from what we need from the DocumentPicker API.
3
+ *
4
+ * For its full API, see https://github.com/rnmods/react-native-document-picker/blob/master/src/index.tsx
5
+ * */
6
+ type ResponseValue = {
7
+ name: string;
8
+ uri: string;
9
+ size: number;
10
+ type: string;
11
+ };
2
12
 
3
- export const pickDocument = async ({ maxNumberOfFiles }: { maxNumberOfFiles: number }) => {
4
- try {
5
- let res = await DocumentPicker.pickMultiple({
6
- type: [DocumentPicker.types.allFiles],
7
- });
13
+ let DocumentPicker: {
14
+ types: { allFiles: string };
15
+ pickMultiple: (opts?: { type: string[] }) => Promise<ResponseValue[]>;
16
+ };
8
17
 
9
- if (maxNumberOfFiles && res.length > maxNumberOfFiles) {
10
- res = res.slice(0, maxNumberOfFiles);
11
- }
18
+ try {
19
+ DocumentPicker = require('react-native-document-picker').default;
20
+ } catch (err) {
21
+ console.log('react-native-document-picker is not installed');
22
+ }
12
23
 
13
- return {
14
- cancelled: false,
15
- docs: res.map(({ name, size, type, uri }) => ({
16
- name,
17
- size,
18
- type,
19
- uri,
20
- })),
21
- };
22
- } catch (err) {
23
- return {
24
- cancelled: true,
25
- };
26
- }
27
- };
24
+ export const pickDocument = DocumentPicker
25
+ ? async ({ maxNumberOfFiles }: { maxNumberOfFiles: number }) => {
26
+ try {
27
+ let res = await DocumentPicker.pickMultiple({
28
+ type: [DocumentPicker.types.allFiles],
29
+ });
30
+
31
+ if (maxNumberOfFiles && res.length > maxNumberOfFiles) {
32
+ res = res.slice(0, maxNumberOfFiles);
33
+ }
34
+
35
+ return {
36
+ cancelled: false,
37
+ docs: res.map(({ name, size, type, uri }) => ({
38
+ name,
39
+ size,
40
+ type,
41
+ uri,
42
+ })),
43
+ };
44
+ } catch (err) {
45
+ return {
46
+ cancelled: true,
47
+ };
48
+ }
49
+ }
50
+ : null;