stream-chat-react-native 5.21.0 → 5.22.0-beta.10

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 CHANGED
@@ -9,7 +9,7 @@
9
9
 
10
10
 
11
11
  [![NPM](https://img.shields.io/npm/v/stream-chat-react-native.svg)](https://www.npmjs.com/package/stream-chat-react-native)
12
- [![Build Status](https://github.com/GetStream/stream-chat-react-native/workflows/build/badge.svg)](https://github.com/GetStream/stream-chat-react-native/actions)
12
+ [![Build Status](https://github.com/GetStream/stream-chat-react-native/actions/workflows/release.yml/badge.svg)](https://github.com/GetStream/stream-chat-react-native/actions)
13
13
  [![Component Reference](https://img.shields.io/badge/docs-component%20reference-blue.svg)](https://getstream.io/chat/docs/sdk/reactnative)
14
14
 
15
15
  <img align="right" src="https://getstream.imgix.net/images/ios-chat-tutorial/iphone_chat_art@3x.png?auto=format,enhance" width="50%" />
@@ -25,10 +25,15 @@
25
25
 
26
26
  ## Contents
27
27
 
28
- - [React Native Chat Tutorial](#-react-native-chat-tutorial)
29
- - [Example Apps](#-example-apps)
30
- - [Keep in mind](#-keep-in-mind)
31
- - [Contributing](#-contributing)
28
+ - [Official React Native SDK for Stream Chat](#official-react-native-sdk-for-stream-chat)
29
+ - [Contents](#contents)
30
+ - [📖 React Native Chat Tutorial](#-react-native-chat-tutorial)
31
+ - [Free for Makers](#free-for-makers)
32
+ - [🔮 Example Apps](#-example-apps)
33
+ - [💬 Keep in mind](#-keep-in-mind)
34
+ - [👏 Contributing](#-contributing)
35
+ - [Git flow \& Release process](#git-flow--release-process)
36
+ - [We are hiring](#we-are-hiring)
32
37
 
33
38
  ## 📖 React Native Chat Tutorial
34
39
 
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.21.0",
4
+ "version": "5.22.0-beta.10",
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.21.0"
14
+ "stream-chat-react-native-core": "5.22.0-beta.10"
15
15
  },
16
16
  "peerDependencies": {
17
17
  "@react-native-camera-roll/camera-roll": ">=5.0.0",
@@ -78,8 +78,8 @@ export const getPhotos = async ({
78
78
  ...edge.node.image,
79
79
  duration: edge.node.image.playableDuration,
80
80
  // since we include filename, fileSize in the query, we can safely assume it will be defined
81
- filename: edge.node.image.filename as string,
82
- fileSize: edge.node.image.fileSize as number,
81
+ name: edge.node.image.filename as string,
82
+ size: edge.node.image.fileSize as number,
83
83
  source: 'picker' as const,
84
84
  type: edge.node.type,
85
85
  }));
@@ -1,47 +1,72 @@
1
- import { Image, Platform } from 'react-native';
1
+ import { AppState, Image, PermissionsAndroid, Platform } from 'react-native';
2
2
  import ImagePicker from 'react-native-image-crop-picker';
3
3
 
4
4
  export const takePhoto = async ({ compressImageQuality = Platform.OS === 'ios' ? 0.8 : 1 }) => {
5
- const photo = await ImagePicker.openCamera({
6
- compressImageQuality: Math.min(Math.max(0, compressImageQuality), 1),
7
- });
8
-
9
- if (photo.height && photo.width && photo.path) {
10
- let size: { height?: number; width?: number } = {};
11
- if (Platform.OS === 'android') {
12
- // Height and width returned by ImagePicker are incorrect on Android.
13
- // The issue is described in following github issue:
14
- // https://github.com/ivpusic/react-native-image-crop-picker/issues/901
15
- // This we can't rely on them as it is, and we need to use Image.getSize
16
- // to get accurate size.
17
- const getSize = (): Promise<{ height: number; width: number }> =>
18
- new Promise((resolve) => {
19
- Image.getSize(photo.path, (width, height) => {
20
- resolve({ height, width });
5
+ if (Platform.OS === 'android') {
6
+ const cameraPermissions = await PermissionsAndroid.check(PermissionsAndroid.PERMISSIONS.CAMERA);
7
+ if (!cameraPermissions) {
8
+ const androidPermissionStatus = await PermissionsAndroid.request(
9
+ PermissionsAndroid.PERMISSIONS.CAMERA,
10
+ );
11
+ if (androidPermissionStatus === PermissionsAndroid.RESULTS.DENIED) {
12
+ return { cancelled: true };
13
+ } else if (androidPermissionStatus === PermissionsAndroid.RESULTS.NEVER_ASK_AGAIN) {
14
+ return { askToOpenSettings: true, cancelled: true };
15
+ }
16
+ }
17
+ }
18
+ try {
19
+ const photo = await ImagePicker.openCamera({
20
+ compressImageQuality: Math.min(Math.max(0, compressImageQuality), 1),
21
+ });
22
+ if (photo.height && photo.width && photo.path) {
23
+ let size: { height?: number; width?: number } = {};
24
+ if (Platform.OS === 'android') {
25
+ // Height and width returned by ImagePicker are incorrect on Android.
26
+ // The issue is described in following github issue:
27
+ // https://github.com/ivpusic/react-native-image-crop-picker/issues/901
28
+ // This we can't rely on them as it is, and we need to use Image.getSize
29
+ // to get accurate size.
30
+ const getSize = (): Promise<{ height: number; width: number }> =>
31
+ new Promise((resolve) => {
32
+ Image.getSize(photo.path, (width, height) => {
33
+ resolve({ height, width });
34
+ });
21
35
  });
22
- });
23
36
 
24
- try {
25
- const { height, width } = await getSize();
26
- size.height = height;
27
- size.width = width;
28
- } catch (e) {
29
- // do nothing
30
- console.warn('Error get image size of picture caputred from camera ', e);
37
+ try {
38
+ const { height, width } = await getSize();
39
+ size.height = height;
40
+ size.width = width;
41
+ } catch (e) {
42
+ // do nothing
43
+ console.warn('Error get image size of picture caputred from camera ', e);
44
+ }
45
+ } else {
46
+ size = {
47
+ height: photo.height,
48
+ width: photo.width,
49
+ };
31
50
  }
32
- } else {
33
- size = {
34
- height: photo.height,
35
- width: photo.width,
51
+ return {
52
+ cancelled: false,
53
+ source: 'camera',
54
+ uri: photo.path,
55
+ ...size,
36
56
  };
37
57
  }
38
-
39
- return {
40
- cancelled: false,
41
- source: 'camera',
42
- uri: photo.path,
43
- ...size,
44
- };
58
+ } catch (e: unknown) {
59
+ if (e instanceof Error) {
60
+ // on iOS: if it was in inactive state, then the user had just denied the permissions
61
+ if (Platform.OS === 'ios' && AppState.currentState === 'active') {
62
+ const cameraPermissionDeniedMsg = 'User did not grant camera permission.';
63
+ // Open settings when the user did not allow camera permissions
64
+ if (e.message === cameraPermissionDeniedMsg) {
65
+ return { askToOpenSettings: true, cancelled: true };
66
+ }
67
+ }
68
+ }
45
69
  }
70
+
46
71
  return { cancelled: true };
47
72
  };