stream-chat-react-native 4.0.0 → 4.1.0
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/README.md +1 -13
- package/package.json +3 -4
- package/src/index.js +42 -14
package/README.md
CHANGED
|
@@ -31,18 +31,6 @@
|
|
|
31
31
|
- [Keep in mind](#-keep-in-mind)
|
|
32
32
|
- [Contributing](#-contributing)
|
|
33
33
|
|
|
34
|
-
## 🔐 React Native Compatibility
|
|
35
|
-
|
|
36
|
-
To use this library you need to ensure you match up with the correct version of React Native you are using.
|
|
37
|
-
|
|
38
|
-
| `stream-chat-react-native` version | React Native Version | `stream-chat` Version |
|
|
39
|
-
| ---------------------------------- | --------------------- | --------------------- |
|
|
40
|
-
| `3.2.0` | `>= 0.60` | `>= 3.5.1` |
|
|
41
|
-
| `3.0.0` | `>= 0.60` | `>= 3.0.0` |
|
|
42
|
-
| `2.x.x` | `>= 0.60` | `< 3.0.0` |
|
|
43
|
-
| `1.x.x` | `>= 0.59` | `< 3.0.0` |
|
|
44
|
-
| `0.x.x` | `*` | `< 3.0.0` |
|
|
45
|
-
|
|
46
34
|
## 📖 React Native Chat Tutorial
|
|
47
35
|
|
|
48
36
|
The best place to start is the [React Native Chat Tutorial](https://github.com/GetStream/stream-chat-react-native/wiki/Tutorial-v3.0). It teaches you how to use this SDK and also shows how to make frequently required changes.
|
|
@@ -58,7 +46,7 @@ This repo includes 4 example apps. One made with Expo, one Native JavaScript cod
|
|
|
58
46
|
|
|
59
47
|
- [Expo example](./examples/ExpoMessaging)
|
|
60
48
|
- [Native example](./examples/NativeMessaging)
|
|
61
|
-
- [Typescript example](./examples/
|
|
49
|
+
- [Typescript example](./examples/TypeScriptMessaging)
|
|
62
50
|
- [Fully featured messaging application](./examples/SampleApp)
|
|
63
51
|
|
|
64
52
|
Besides, our team maintains a dedicated repository for fully-fledged sample applications and demos at [GetStream/react-native-samples](https://github.com/GetStream/react-native-samples). Please consider checking following sample applications:
|
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": "4.
|
|
4
|
+
"version": "4.1.0",
|
|
5
5
|
"author": {
|
|
6
6
|
"company": "Stream.io Inc",
|
|
7
7
|
"name": "Stream.io Inc"
|
|
@@ -11,19 +11,18 @@
|
|
|
11
11
|
"types": "types/index.d.ts",
|
|
12
12
|
"dependencies": {
|
|
13
13
|
"es6-symbol": "^3.1.3",
|
|
14
|
-
"stream-chat-react-native-core": "4.
|
|
14
|
+
"stream-chat-react-native-core": "4.1.0"
|
|
15
15
|
},
|
|
16
16
|
"peerDependencies": {
|
|
17
|
-
"@react-native-community/blur": ">=3.6.0",
|
|
18
17
|
"@react-native-community/cameraroll": ">=4.0.1",
|
|
19
18
|
"@react-native-community/netinfo": ">=2.0.7",
|
|
19
|
+
"@stream-io/flat-list-mvcp": "0.10.1",
|
|
20
20
|
"react-native": ">=0.60.0",
|
|
21
21
|
"react-native-document-picker": ">=3.2.0",
|
|
22
22
|
"react-native-fs": ">=2.16.6",
|
|
23
23
|
"react-native-haptic-feedback": ">=1.11.0",
|
|
24
24
|
"react-native-image-crop-picker": ">=0.33.2",
|
|
25
25
|
"react-native-image-resizer": ">=1.4.2",
|
|
26
|
-
"@stream-io/flat-list-mvcp": "0.10.1",
|
|
27
26
|
"react-native-share": ">=4.1.0"
|
|
28
27
|
},
|
|
29
28
|
"scripts": {
|
package/src/index.js
CHANGED
|
@@ -1,22 +1,19 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import { PermissionsAndroid, Platform } from 'react-native';
|
|
3
|
-
|
|
4
|
-
import CameraRoll from '@react-native-community/cameraroll';
|
|
5
|
-
import NetInfo from '@react-native-community/netinfo';
|
|
6
|
-
import { FlatList } from '@stream-io/flat-list-mvcp';
|
|
2
|
+
import { Image, PermissionsAndroid, Platform } from 'react-native';
|
|
3
|
+
|
|
7
4
|
import DocumentPicker from 'react-native-document-picker';
|
|
8
5
|
import RNFS from 'react-native-fs';
|
|
9
6
|
import ReactNativeHapticFeedback from 'react-native-haptic-feedback';
|
|
10
7
|
import ImagePicker from 'react-native-image-crop-picker';
|
|
11
8
|
import ImageResizer from 'react-native-image-resizer';
|
|
12
9
|
import RNShare from 'react-native-share';
|
|
10
|
+
|
|
11
|
+
import CameraRoll from '@react-native-community/cameraroll';
|
|
12
|
+
import NetInfo from '@react-native-community/netinfo';
|
|
13
|
+
import { FlatList } from '@stream-io/flat-list-mvcp';
|
|
13
14
|
import { registerNativeHandlers } from 'stream-chat-react-native-core';
|
|
14
15
|
|
|
15
16
|
registerNativeHandlers({
|
|
16
|
-
// eslint-disable-next-line react/display-name
|
|
17
|
-
BlurView: ({ blurAmount = 10, blurType = 'dark', style }) => (
|
|
18
|
-
<RNBlurView blurAmount={blurAmount} blurType={blurType} style={style} />
|
|
19
|
-
),
|
|
20
17
|
compressImage: async ({ compressImageQuality = 1, height, uri, width }) => {
|
|
21
18
|
try {
|
|
22
19
|
const { uri: compressedUri } = await ImageResizer.createResizedImage(
|
|
@@ -95,8 +92,11 @@ registerNativeHandlers({
|
|
|
95
92
|
let unsubscribe;
|
|
96
93
|
// For NetInfo >= 3.x.x
|
|
97
94
|
if (NetInfo.fetch && typeof NetInfo.fetch === 'function') {
|
|
98
|
-
unsubscribe = NetInfo.addEventListener(({ isConnected }) => {
|
|
99
|
-
|
|
95
|
+
unsubscribe = NetInfo.addEventListener(({ isConnected, isInternetReachable }) => {
|
|
96
|
+
// Initialize with truthy value when internetReachable is still loading
|
|
97
|
+
// if it resolves to false, listener is triggered with false value and network
|
|
98
|
+
// status is updated
|
|
99
|
+
listener(isInternetReachable === null ? isConnected : isConnected && isInternetReachable);
|
|
100
100
|
});
|
|
101
101
|
return unsubscribe;
|
|
102
102
|
} else {
|
|
@@ -154,7 +154,7 @@ registerNativeHandlers({
|
|
|
154
154
|
},
|
|
155
155
|
saveFile: async ({ fileName, fromUrl }) => {
|
|
156
156
|
try {
|
|
157
|
-
const path = RNFS.
|
|
157
|
+
const path = RNFS.CachesDirectoryPath + '/' + encodeURIComponent(fileName);
|
|
158
158
|
await RNFS.downloadFile({ fromUrl, toFile: path }).promise;
|
|
159
159
|
return 'file://' + path;
|
|
160
160
|
} catch (error) {
|
|
@@ -201,13 +201,41 @@ registerNativeHandlers({
|
|
|
201
201
|
const photo = await ImagePicker.openCamera({
|
|
202
202
|
compressImageQuality: Math.min(Math.max(0, compressImageQuality), 1),
|
|
203
203
|
});
|
|
204
|
+
|
|
204
205
|
if (photo.height && photo.width && photo.path) {
|
|
206
|
+
let size = {};
|
|
207
|
+
if (Platform.OS === 'android') {
|
|
208
|
+
// Height and width returned by ImagePicker are incorrect on Android.
|
|
209
|
+
// The issue is described in following github issue:
|
|
210
|
+
// https://github.com/ivpusic/react-native-image-crop-picker/issues/901
|
|
211
|
+
// This we can't rely on them as it is, and we need to use Image.getSize
|
|
212
|
+
// to get accurate size.
|
|
213
|
+
const getSize = () => new Promise((resolve) => {
|
|
214
|
+
Image.getSize(photo.path, (width, height) => {
|
|
215
|
+
resolve({height, width});
|
|
216
|
+
});
|
|
217
|
+
});
|
|
218
|
+
|
|
219
|
+
try {
|
|
220
|
+
const { height, width } = await getSize();
|
|
221
|
+
size.height = height;
|
|
222
|
+
size.width = width;
|
|
223
|
+
} catch (e) {
|
|
224
|
+
// do nothing
|
|
225
|
+
console.warning('Error get image size of picture caputred from camera ', e);
|
|
226
|
+
}
|
|
227
|
+
} else {
|
|
228
|
+
size = {
|
|
229
|
+
height: photo.height,
|
|
230
|
+
width: photo.width,
|
|
231
|
+
};
|
|
232
|
+
}
|
|
233
|
+
|
|
205
234
|
return {
|
|
206
235
|
cancelled: false,
|
|
207
|
-
height: photo.height,
|
|
208
236
|
source: 'camera',
|
|
209
237
|
uri: photo.path,
|
|
210
|
-
|
|
238
|
+
...size,
|
|
211
239
|
};
|
|
212
240
|
}
|
|
213
241
|
return { cancelled: true };
|