stream-chat-expo 4.0.0-beta.2 → 4.0.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.
Files changed (2) hide show
  1. package/package.json +2 -2
  2. package/src/index.js +31 -3
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "stream-chat-expo",
3
3
  "description": "The official Expo SDK for Stream Chat, a service for building chat applications",
4
- "version": "4.0.0-beta.2",
4
+ "version": "4.0.0-beta.6",
5
5
  "author": {
6
6
  "company": "Stream.io Inc",
7
7
  "name": "Stream.io Inc"
@@ -10,7 +10,7 @@
10
10
  "main": "src/index.js",
11
11
  "types": "types/index.d.ts",
12
12
  "dependencies": {
13
- "stream-chat-react-native-core": "4.0.0-beta.2"
13
+ "stream-chat-react-native-core": "4.0.0-beta.6"
14
14
  },
15
15
  "peerDependencies": {
16
16
  "@react-native-community/netinfo": "^6.0.0",
package/src/index.js CHANGED
@@ -1,5 +1,6 @@
1
1
  import React from 'react';
2
- import { FlatList } from 'react-native';
2
+ import { FlatList, Image, Platform } from 'react-native';
3
+
3
4
  import NetInfo from '@react-native-community/netinfo';
4
5
  import * as DocumentPicker from 'expo-document-picker';
5
6
  import * as FileSystem from 'expo-file-system';
@@ -147,12 +148,39 @@ registerNativeHandlers({
147
148
  quality: Math.min(Math.max(0, compressImageQuality), 1),
148
149
  });
149
150
  if (photo.height && photo.width && photo.uri) {
151
+ let size = {};
152
+ if (Platform.OS === 'android') {
153
+ // Height and width returned by ImagePicker are incorrect on Android.
154
+ // The issue is described in following github issue:
155
+ // https://github.com/ivpusic/react-native-image-crop-picker/issues/901
156
+ // This we can't rely on them as it is, and we need to use Image.getSize
157
+ // to get accurate size.
158
+ const getSize = () => new Promise((resolve) => {
159
+ Image.getSize(photo.uri, (width, height) => {
160
+ resolve({height, width});
161
+ });
162
+ });
163
+
164
+ try {
165
+ const { height, width } = await getSize();
166
+ size.height = height;
167
+ size.width = width;
168
+ } catch (e) {
169
+ // do nothing
170
+ console.warning('Error get image size of picture caputred from camera ', e);
171
+ }
172
+ } else {
173
+ size = {
174
+ height: photo.height,
175
+ width: photo.width,
176
+ };
177
+ }
178
+
150
179
  return {
151
180
  cancelled: false,
152
- height: photo.height,
153
181
  source: 'camera',
154
182
  uri: photo.uri,
155
- width: photo.width,
183
+ ...size
156
184
  };
157
185
  }
158
186
  }