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 +2 -2
- package/src/handlers/pickDocument.ts +47 -24
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.
|
|
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.
|
|
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
|
-
|
|
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
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
});
|
|
13
|
+
let DocumentPicker: {
|
|
14
|
+
types: { allFiles: string };
|
|
15
|
+
pickMultiple: (opts?: { type: string[] }) => Promise<ResponseValue[]>;
|
|
16
|
+
};
|
|
8
17
|
|
|
9
|
-
|
|
10
|
-
|
|
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
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
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;
|