stream-chat-react-native 5.34.1-beta.5 → 5.35.0-beta.1
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 +9 -3
- package/src/handlers/index.ts +0 -4
- package/src/index.js +5 -10
- package/src/optionalDependencies/getLocalAssetUri.ts +21 -0
- package/src/{handlers → optionalDependencies}/getPhotos.ts +40 -31
- package/src/optionalDependencies/iOS14RefreshGallerySelection.ts +25 -0
- package/src/optionalDependencies/index.ts +5 -0
- package/src/optionalDependencies/oniOS14GalleryLibrarySelectionChange.ts +37 -0
- package/src/optionalDependencies/pickImage.ts +38 -0
- package/src/handlers/getLocalAssetUri.ts +0 -10
- package/src/handlers/iOS14RefreshGallerySelection.ts +0 -14
- package/src/handlers/oniOS14GalleryLibrarySelectionChange.ts +0 -22
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.
|
|
4
|
+
"version": "5.35.0-beta.1",
|
|
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.
|
|
14
|
+
"stream-chat-react-native-core": "5.35.0-beta.1"
|
|
15
15
|
},
|
|
16
16
|
"peerDependencies": {
|
|
17
17
|
"@react-native-camera-roll/camera-roll": ">=5.0.0",
|
|
@@ -23,12 +23,16 @@
|
|
|
23
23
|
"react-native-document-picker": ">=9.0.1",
|
|
24
24
|
"react-native-fs": ">=2.16.6",
|
|
25
25
|
"react-native-haptic-feedback": ">=1.11.0",
|
|
26
|
+
"react-native-image-picker": ">=7.1.2",
|
|
26
27
|
"react-native-image-crop-picker": ">=0.33.2",
|
|
27
28
|
"react-native-image-resizer": ">=1.4.2",
|
|
28
29
|
"react-native-share": ">=4.1.0",
|
|
29
30
|
"react-native-video": ">=6.4.2"
|
|
30
31
|
},
|
|
31
32
|
"peerDependenciesMeta": {
|
|
33
|
+
"@react-native-camera-roll/camera-roll": {
|
|
34
|
+
"optional": true
|
|
35
|
+
},
|
|
32
36
|
"@react-native-clipboard/clipboard": {
|
|
33
37
|
"optional": true
|
|
34
38
|
},
|
|
@@ -41,6 +45,9 @@
|
|
|
41
45
|
"react-native-haptic-feedback": {
|
|
42
46
|
"optional": true
|
|
43
47
|
},
|
|
48
|
+
"react-native-image-picker": {
|
|
49
|
+
"optional": true
|
|
50
|
+
},
|
|
44
51
|
"react-native-image-crop-picker": {
|
|
45
52
|
"optional": true
|
|
46
53
|
},
|
|
@@ -56,7 +63,6 @@
|
|
|
56
63
|
"postpack": "rm README.md"
|
|
57
64
|
},
|
|
58
65
|
"devDependencies": {
|
|
59
|
-
"@react-native-camera-roll/camera-roll": "^5.0.2",
|
|
60
66
|
"@react-native-community/netinfo": ">=2.0.7",
|
|
61
67
|
"@stream-io/flat-list-mvcp": "0.10.3",
|
|
62
68
|
"react-native": ">=0.60.0",
|
package/src/handlers/index.ts
CHANGED
|
@@ -1,10 +1,6 @@
|
|
|
1
1
|
export * from './deleteFile';
|
|
2
2
|
export * from './compressImage';
|
|
3
|
-
export * from './getLocalAssetUri';
|
|
4
|
-
export * from './getPhotos';
|
|
5
3
|
export * from './NetInfo';
|
|
6
4
|
export * from './saveFile';
|
|
7
5
|
export * from './Sound';
|
|
8
6
|
export * from './Video';
|
|
9
|
-
export * from './oniOS14GalleryLibrarySelectionChange';
|
|
10
|
-
export * from './iOS14RefreshGallerySelection';
|
package/src/index.js
CHANGED
|
@@ -3,22 +3,16 @@ import { Platform } from 'react-native';
|
|
|
3
3
|
import { FlatList } from '@stream-io/flat-list-mvcp';
|
|
4
4
|
import { registerNativeHandlers } from 'stream-chat-react-native-core';
|
|
5
5
|
|
|
6
|
+
import { compressImage, deleteFile, NetInfo, saveFile, Sound, Video } from './handlers';
|
|
7
|
+
|
|
6
8
|
import {
|
|
7
|
-
|
|
8
|
-
deleteFile,
|
|
9
|
+
Audio,
|
|
9
10
|
getLocalAssetUri,
|
|
10
11
|
getPhotos,
|
|
11
12
|
iOS14RefreshGallerySelection,
|
|
12
|
-
NetInfo,
|
|
13
13
|
oniOS14GalleryLibrarySelectionChange,
|
|
14
|
-
saveFile,
|
|
15
|
-
Sound,
|
|
16
|
-
Video,
|
|
17
|
-
} from './handlers';
|
|
18
|
-
|
|
19
|
-
import {
|
|
20
|
-
Audio,
|
|
21
14
|
pickDocument,
|
|
15
|
+
pickImage,
|
|
22
16
|
setClipboardString,
|
|
23
17
|
shareImage,
|
|
24
18
|
takePhoto,
|
|
@@ -36,6 +30,7 @@ registerNativeHandlers({
|
|
|
36
30
|
NetInfo,
|
|
37
31
|
oniOS14GalleryLibrarySelectionChange,
|
|
38
32
|
pickDocument,
|
|
33
|
+
pickImage,
|
|
39
34
|
saveFile,
|
|
40
35
|
SDK: 'stream-chat-react-native',
|
|
41
36
|
setClipboardString,
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
let CameraRollDependency;
|
|
2
|
+
|
|
3
|
+
try {
|
|
4
|
+
CameraRollDependency = require('@react-native-camera-roll/camera-roll');
|
|
5
|
+
} catch (e) {
|
|
6
|
+
// do nothing
|
|
7
|
+
console.log(
|
|
8
|
+
'@react-native-camera-roll/camera-roll is not installed. Please install it or you can choose to install react-native-image-crop-picker for native image picker.',
|
|
9
|
+
);
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export const getLocalAssetUri = CameraRollDependency
|
|
13
|
+
? async (remoteUri: string) => {
|
|
14
|
+
try {
|
|
15
|
+
const localUri = await CameraRollDependency.CameraRoll.save(remoteUri);
|
|
16
|
+
return localUri;
|
|
17
|
+
} catch {
|
|
18
|
+
throw new Error('getLocalAssetUri Error');
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
: null;
|
|
@@ -1,6 +1,16 @@
|
|
|
1
1
|
import { PermissionsAndroid, Platform } from 'react-native';
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
let CameraRollDependency;
|
|
4
|
+
|
|
5
|
+
try {
|
|
6
|
+
CameraRollDependency = require('@react-native-camera-roll/camera-roll');
|
|
7
|
+
} catch (e) {
|
|
8
|
+
// do nothing
|
|
9
|
+
console.log(
|
|
10
|
+
'@react-native-camera-roll/camera-roll is not installed. Please install it or you can choose to install react-native-image-crop-picker for native image picker.',
|
|
11
|
+
);
|
|
12
|
+
}
|
|
13
|
+
|
|
4
14
|
import type { Asset } from 'stream-chat-react-native-core';
|
|
5
15
|
|
|
6
16
|
type ReturnType = {
|
|
@@ -57,36 +67,35 @@ const verifyAndroidPermissions = async () => {
|
|
|
57
67
|
return true;
|
|
58
68
|
};
|
|
59
69
|
|
|
60
|
-
export const getPhotos =
|
|
61
|
-
after,
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
70
|
+
export const getPhotos = CameraRollDependency
|
|
71
|
+
? async ({ after, first }): Promise<ReturnType> => {
|
|
72
|
+
try {
|
|
73
|
+
if (Platform.OS === 'android') {
|
|
74
|
+
const granted = await verifyAndroidPermissions();
|
|
75
|
+
if (!granted) {
|
|
76
|
+
throw new Error('getPhotos Error');
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
const results = await CameraRollDependency.CameraRoll.getPhotos({
|
|
80
|
+
after,
|
|
81
|
+
assetType: 'All',
|
|
82
|
+
first,
|
|
83
|
+
include: ['fileSize', 'filename', 'imageSize', 'playableDuration'],
|
|
84
|
+
});
|
|
85
|
+
const assets = results.edges.map((edge) => ({
|
|
86
|
+
...edge.node.image,
|
|
87
|
+
duration: edge.node.image.playableDuration * 1000,
|
|
88
|
+
// since we include filename, fileSize in the query, we can safely assume it will be defined
|
|
89
|
+
name: edge.node.image.filename as string,
|
|
90
|
+
size: edge.node.image.fileSize as number,
|
|
91
|
+
source: 'picker' as const,
|
|
92
|
+
type: edge.node.type,
|
|
93
|
+
}));
|
|
94
|
+
const hasNextPage = results.page_info.has_next_page;
|
|
95
|
+
const endCursor = results.page_info.end_cursor;
|
|
96
|
+
return { assets, endCursor, hasNextPage, iOSLimited: !!results.limited };
|
|
97
|
+
} catch (_error) {
|
|
68
98
|
throw new Error('getPhotos Error');
|
|
69
99
|
}
|
|
70
100
|
}
|
|
71
|
-
|
|
72
|
-
after,
|
|
73
|
-
assetType: 'All',
|
|
74
|
-
first,
|
|
75
|
-
include: ['fileSize', 'filename', 'imageSize', 'playableDuration'],
|
|
76
|
-
});
|
|
77
|
-
const assets = results.edges.map((edge) => ({
|
|
78
|
-
...edge.node.image,
|
|
79
|
-
duration: edge.node.image.playableDuration,
|
|
80
|
-
// since we include filename, fileSize in the query, we can safely assume it will be defined
|
|
81
|
-
name: edge.node.image.filename as string,
|
|
82
|
-
size: edge.node.image.fileSize as number,
|
|
83
|
-
source: 'picker' as const,
|
|
84
|
-
type: edge.node.type,
|
|
85
|
-
}));
|
|
86
|
-
const hasNextPage = results.page_info.has_next_page;
|
|
87
|
-
const endCursor = results.page_info.end_cursor;
|
|
88
|
-
return { assets, endCursor, hasNextPage, iOSLimited: !!results.limited };
|
|
89
|
-
} catch (_error) {
|
|
90
|
-
throw new Error('getPhotos Error');
|
|
91
|
-
}
|
|
92
|
-
};
|
|
101
|
+
: null;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { Platform } from 'react-native';
|
|
2
|
+
|
|
3
|
+
let CameraRollDependency;
|
|
4
|
+
|
|
5
|
+
try {
|
|
6
|
+
CameraRollDependency = require('@react-native-camera-roll/camera-roll');
|
|
7
|
+
} catch (e) {
|
|
8
|
+
// do nothing
|
|
9
|
+
console.log(
|
|
10
|
+
'@react-native-camera-roll/camera-roll is not installed. Please install it or you can choose to install react-native-image-crop-picker for native image picker.',
|
|
11
|
+
);
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
const isAboveIOS14 = Platform.OS === 'ios' && parseInt(Platform.Version as string, 10) >= 14;
|
|
15
|
+
|
|
16
|
+
export const iOS14RefreshGallerySelection = CameraRollDependency
|
|
17
|
+
? (): Promise<void> => {
|
|
18
|
+
if (isAboveIOS14) {
|
|
19
|
+
return CameraRollDependency.iosRefreshGallerySelection().then(() => {
|
|
20
|
+
//do nothing
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
return Promise.resolve();
|
|
24
|
+
}
|
|
25
|
+
: null;
|
|
@@ -4,4 +4,9 @@ export * from './Video';
|
|
|
4
4
|
export * from './triggerHaptic';
|
|
5
5
|
export * from './setClipboardString';
|
|
6
6
|
export * from './pickDocument';
|
|
7
|
+
export * from './getLocalAssetUri';
|
|
8
|
+
export * from './iOS14RefreshGallerySelection';
|
|
9
|
+
export * from './oniOS14GalleryLibrarySelectionChange';
|
|
10
|
+
export * from './getPhotos';
|
|
11
|
+
export * from './pickImage';
|
|
7
12
|
export * from './takePhoto';
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { Platform } from 'react-native';
|
|
2
|
+
|
|
3
|
+
let CameraRollDependency;
|
|
4
|
+
|
|
5
|
+
try {
|
|
6
|
+
CameraRollDependency = require('@react-native-camera-roll/camera-roll');
|
|
7
|
+
} catch (e) {
|
|
8
|
+
// do nothing
|
|
9
|
+
console.log(
|
|
10
|
+
'@react-native-camera-roll/camera-roll is not installed. Please install it or you can choose to install react-native-image-crop-picker for native image picker.',
|
|
11
|
+
);
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
const isAboveIOS14 = Platform.OS === 'ios' && parseInt(Platform.Version as string, 10) >= 14;
|
|
15
|
+
|
|
16
|
+
export const oniOS14GalleryLibrarySelectionChange = CameraRollDependency
|
|
17
|
+
? (
|
|
18
|
+
callback: () => void,
|
|
19
|
+
): {
|
|
20
|
+
unsubscribe: () => void;
|
|
21
|
+
} => {
|
|
22
|
+
if (isAboveIOS14) {
|
|
23
|
+
const subscription = CameraRollDependency.cameraRollEventEmitter.addListener(
|
|
24
|
+
'onLibrarySelectionChange',
|
|
25
|
+
callback,
|
|
26
|
+
);
|
|
27
|
+
return {
|
|
28
|
+
unsubscribe: () => {
|
|
29
|
+
subscription.remove();
|
|
30
|
+
},
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
return {
|
|
34
|
+
unsubscribe: () => {},
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
: null;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { Platform } from 'react-native';
|
|
2
|
+
let ImagePicker;
|
|
3
|
+
|
|
4
|
+
try {
|
|
5
|
+
ImagePicker = require('react-native-image-picker');
|
|
6
|
+
} catch (e) {
|
|
7
|
+
console.log('react-native-image-picker is not installed');
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export const pickImage = ImagePicker
|
|
11
|
+
? async () => {
|
|
12
|
+
try {
|
|
13
|
+
const result = await ImagePicker.launchImageLibrary({ mediaType: 'mixed' });
|
|
14
|
+
const canceled = result.didCancel;
|
|
15
|
+
const errorCode = result.errorCode;
|
|
16
|
+
|
|
17
|
+
if (Platform.OS === 'ios' && errorCode === 'permission') {
|
|
18
|
+
return { askToOpenSettings: true, cancelled: true };
|
|
19
|
+
}
|
|
20
|
+
if (!canceled) {
|
|
21
|
+
const assets = result.assets.map((asset) => ({
|
|
22
|
+
...asset,
|
|
23
|
+
duration: asset.duration * 1000, // in milliseconds
|
|
24
|
+
name: asset.fileName,
|
|
25
|
+
size: asset.fileSize,
|
|
26
|
+
source: 'picker',
|
|
27
|
+
type: asset.type,
|
|
28
|
+
uri: asset.uri,
|
|
29
|
+
}));
|
|
30
|
+
return { assets, cancelled: false, source: 'picker' };
|
|
31
|
+
} else {
|
|
32
|
+
return { cancelled: true };
|
|
33
|
+
}
|
|
34
|
+
} catch (error) {
|
|
35
|
+
console.log('Error picking image: ', error);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
: null;
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { CameraRoll } from '@react-native-camera-roll/camera-roll';
|
|
2
|
-
|
|
3
|
-
export const getLocalAssetUri = async (remoteUri: string) => {
|
|
4
|
-
try {
|
|
5
|
-
const localUri = await CameraRoll.save(remoteUri);
|
|
6
|
-
return localUri;
|
|
7
|
-
} catch {
|
|
8
|
-
throw new Error('getLocalAssetUri Error');
|
|
9
|
-
}
|
|
10
|
-
};
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { Platform } from 'react-native';
|
|
2
|
-
|
|
3
|
-
import { iosRefreshGallerySelection } from '@react-native-camera-roll/camera-roll';
|
|
4
|
-
|
|
5
|
-
const isAboveIOS14 = Platform.OS === 'ios' && parseInt(Platform.Version as string, 10) >= 14;
|
|
6
|
-
|
|
7
|
-
export const iOS14RefreshGallerySelection = (): Promise<void> => {
|
|
8
|
-
if (isAboveIOS14) {
|
|
9
|
-
return iosRefreshGallerySelection().then(() => {
|
|
10
|
-
//do nothing
|
|
11
|
-
});
|
|
12
|
-
}
|
|
13
|
-
return Promise.resolve();
|
|
14
|
-
};
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import { Platform } from 'react-native';
|
|
2
|
-
|
|
3
|
-
import { cameraRollEventEmitter } from '@react-native-camera-roll/camera-roll';
|
|
4
|
-
|
|
5
|
-
const isAboveIOS14 = Platform.OS === 'ios' && parseInt(Platform.Version as string, 10) >= 14;
|
|
6
|
-
|
|
7
|
-
export function oniOS14GalleryLibrarySelectionChange(callback: () => void): {
|
|
8
|
-
unsubscribe: () => void;
|
|
9
|
-
} {
|
|
10
|
-
if (isAboveIOS14) {
|
|
11
|
-
const subscription = cameraRollEventEmitter.addListener('onLibrarySelectionChange', callback);
|
|
12
|
-
return {
|
|
13
|
-
unsubscribe: () => {
|
|
14
|
-
subscription.remove();
|
|
15
|
-
},
|
|
16
|
-
};
|
|
17
|
-
}
|
|
18
|
-
return {
|
|
19
|
-
// eslint-disable-next-line @typescript-eslint/no-empty-function
|
|
20
|
-
unsubscribe: () => {},
|
|
21
|
-
};
|
|
22
|
-
}
|