stream-chat-react-native 5.22.0-beta.5 → 5.22.0-beta.6

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.22.0-beta.5",
4
+ "version": "5.22.0-beta.6",
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.22.0-beta.5"
14
+ "stream-chat-react-native-core": "5.22.0-beta.6"
15
15
  },
16
16
  "peerDependencies": {
17
17
  "@react-native-camera-roll/camera-roll": ">=5.0.0",
@@ -1,8 +1,6 @@
1
- import { AppState, Image, Linking, PermissionsAndroid, 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
- let hadDeniedAndroidPermission = false;
5
-
6
4
  export const takePhoto = async ({ compressImageQuality = Platform.OS === 'ios' ? 0.8 : 1 }) => {
7
5
  if (Platform.OS === 'android') {
8
6
  const cameraPermissions = await PermissionsAndroid.check(PermissionsAndroid.PERMISSIONS.CAMERA);
@@ -11,13 +9,9 @@ export const takePhoto = async ({ compressImageQuality = Platform.OS === 'ios' ?
11
9
  PermissionsAndroid.PERMISSIONS.CAMERA,
12
10
  );
13
11
  if (androidPermissionStatus === PermissionsAndroid.RESULTS.DENIED) {
14
- hadDeniedAndroidPermission = true;
15
12
  return { cancelled: true };
16
13
  } else if (androidPermissionStatus === PermissionsAndroid.RESULTS.NEVER_ASK_AGAIN) {
17
- if (!hadDeniedAndroidPermission) {
18
- Linking.openSettings();
19
- }
20
- return { cancelled: true };
14
+ return { askToOpenSettings: true, cancelled: true };
21
15
  }
22
16
  }
23
17
  }
@@ -62,9 +56,15 @@ export const takePhoto = async ({ compressImageQuality = Platform.OS === 'ios' ?
62
56
  };
63
57
  }
64
58
  } catch (e: unknown) {
65
- // on iOS: if it was in inactive state, then the user had just denied the permissions
66
- if (Platform.OS === 'ios' && AppState.currentState === 'active') {
67
- await Linking.openSettings();
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
68
  }
69
69
  }
70
70