stream-chat-react-native 5.36.1-beta.2 → 5.36.1-beta.4

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.36.1-beta.2",
4
+ "version": "5.36.1-beta.4",
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.36.1-beta.2"
14
+ "stream-chat-react-native-core": "5.36.1-beta.4"
15
15
  },
16
16
  "peerDependencies": {
17
17
  "@react-native-camera-roll/camera-roll": ">=5.0.0",
@@ -168,74 +168,85 @@ const verifyAndroidPermissions = async () => {
168
168
  return true;
169
169
  };
170
170
 
171
- export const Audio = AudioRecorderPackage
172
- ? {
173
- pausePlayer: async () => {
174
- await audioRecorderPlayer.pausePlayer();
175
- },
176
- resumePlayer: async () => {
177
- await audioRecorderPlayer.resumePlayer();
178
- },
179
- startPlayer: async (uri, _, onPlaybackStatusUpdate) => {
180
- try {
181
- const playback = await audioRecorderPlayer.startPlayer(uri);
182
- console.log({ playback });
183
- audioRecorderPlayer.addPlayBackListener((status) => {
184
- onPlaybackStatusUpdate(status);
185
- });
186
- } catch (error) {
187
- console.log('Error starting player', error);
188
- }
189
- },
190
- startRecording: async (options: RecordingOptions, onRecordingStatusUpdate) => {
191
- if (Platform.OS === 'android') {
192
- try {
193
- await verifyAndroidPermissions();
194
- } catch (err) {
195
- console.warn('Audio Recording Permissions error', err);
196
- return;
197
- }
198
- }
199
- try {
200
- const path = Platform.select({
201
- android: `${RNFS.CachesDirectoryPath}/sound.aac`,
202
- ios: 'sound.aac',
203
- });
204
- const audioSet = {
205
- AudioEncoderAndroid: AudioEncoderAndroidType.AAC,
206
- AudioSourceAndroid: AudioSourceAndroidType.MIC,
207
- AVEncoderAudioQualityKeyIOS: AVEncoderAudioQualityIOSType.high,
208
- AVFormatIDKeyIOS: AVEncodingOption.aac,
209
- AVModeIOS: AVModeIOSOption.measurement,
210
- AVNumberOfChannelsKeyIOS: 2,
211
- OutputFormatAndroid: OutputFormatAndroidType.AAC_ADTS,
212
- };
213
- const recording = await audioRecorderPlayer.startRecorder(
214
- path,
215
- audioSet,
216
- options?.isMeteringEnabled,
217
- );
171
+ class _Audio {
172
+ pausePlayer = async () => {
173
+ await audioRecorderPlayer.pausePlayer();
174
+ };
175
+ resumePlayer = async () => {
176
+ await audioRecorderPlayer.resumePlayer();
177
+ };
178
+ startPlayer = async (uri, _, onPlaybackStatusUpdate) => {
179
+ try {
180
+ const playback = await audioRecorderPlayer.startPlayer(uri);
181
+ console.log({ playback });
182
+ audioRecorderPlayer.addPlayBackListener((status) => {
183
+ onPlaybackStatusUpdate(status);
184
+ });
185
+ } catch (error) {
186
+ console.log('Error starting player', error);
187
+ }
188
+ };
189
+ startRecording = async (options: RecordingOptions, onRecordingStatusUpdate) => {
190
+ if (Platform.OS === 'android') {
191
+ try {
192
+ await verifyAndroidPermissions();
193
+ } catch (err) {
194
+ console.warn('Audio Recording Permissions error', err);
195
+ return;
196
+ }
197
+ }
198
+ try {
199
+ const path = Platform.select({
200
+ android: `${RNFS.CachesDirectoryPath}/sound.aac`,
201
+ ios: 'sound.aac',
202
+ });
203
+ const audioSet = {
204
+ AudioEncoderAndroid: AudioEncoderAndroidType.AAC,
205
+ AudioSourceAndroid: AudioSourceAndroidType.MIC,
206
+ AVEncoderAudioQualityKeyIOS: AVEncoderAudioQualityIOSType.high,
207
+ AVFormatIDKeyIOS: AVEncodingOption.aac,
208
+ AVModeIOS: AVModeIOSOption.measurement,
209
+ AVNumberOfChannelsKeyIOS: 2,
210
+ OutputFormatAndroid: OutputFormatAndroidType.AAC_ADTS,
211
+ };
212
+ const recording = await audioRecorderPlayer.startRecorder(
213
+ path,
214
+ audioSet,
215
+ options?.isMeteringEnabled,
216
+ );
218
217
 
219
- audioRecorderPlayer.addRecordBackListener((status) => {
220
- onRecordingStatusUpdate(status);
221
- });
222
- return { accessGranted: true, recording };
223
- } catch (error) {
224
- console.error('Failed to start recording', error);
225
- return { accessGranted: false, recording: null };
226
- }
227
- },
228
- stopPlayer: async () => {
229
- try {
230
- await audioRecorderPlayer.stopPlayer();
231
- audioRecorderPlayer.removePlayBackListener();
232
- } catch (error) {
233
- console.log(error);
234
- }
235
- },
236
- stopRecording: async () => {
237
- await audioRecorderPlayer.stopRecorder();
238
- audioRecorderPlayer.removeRecordBackListener();
239
- },
218
+ audioRecorderPlayer.addRecordBackListener((status) => {
219
+ onRecordingStatusUpdate(status);
220
+ });
221
+ return { accessGranted: true, recording };
222
+ } catch (error) {
223
+ console.error('Failed to start recording', error);
224
+ // There is currently a bug in react-native-audio-recorder-player and we
225
+ // need to do this until it gets fixed. More information can be found here:
226
+ // https://github.com/hyochan/react-native-audio-recorder-player/pull/625
227
+ // eslint-disable-next-line no-underscore-dangle
228
+ audioRecorderPlayer._isRecording = false;
229
+ // eslint-disable-next-line no-underscore-dangle
230
+ audioRecorderPlayer._hasPausedRecord = false;
231
+ return { accessGranted: false, recording: null };
240
232
  }
241
- : null;
233
+ };
234
+ stopPlayer = async () => {
235
+ try {
236
+ await audioRecorderPlayer.stopPlayer();
237
+ audioRecorderPlayer.removePlayBackListener();
238
+ } catch (error) {
239
+ console.log(error);
240
+ }
241
+ };
242
+ stopRecording = async () => {
243
+ try {
244
+ await audioRecorderPlayer.stopRecorder();
245
+ audioRecorderPlayer.removeRecordBackListener();
246
+ } catch (error) {
247
+ console.log(error);
248
+ }
249
+ };
250
+ }
251
+
252
+ export const Audio = AudioRecorderPackage ? new _Audio() : null;
@@ -10,7 +10,9 @@ try {
10
10
  export const pickImage = ImagePicker
11
11
  ? async () => {
12
12
  try {
13
- const result = await ImagePicker.launchImageLibrary({ mediaType: 'mixed' });
13
+ const result = await ImagePicker.launchImageLibrary({
14
+ mediaType: 'mixed',
15
+ });
14
16
  const canceled = result.didCancel;
15
17
  const errorCode = result.errorCode;
16
18
 
@@ -20,7 +22,7 @@ export const pickImage = ImagePicker
20
22
  if (!canceled) {
21
23
  const assets = result.assets.map((asset) => ({
22
24
  ...asset,
23
- duration: asset.duration * 1000, // in milliseconds
25
+ duration: asset.duration ? asset.duration * 1000 : undefined, // in milliseconds
24
26
  name: asset.fileName,
25
27
  size: asset.fileSize,
26
28
  source: 'picker',
@@ -60,6 +60,7 @@ export const takePhoto = ImagePicker
60
60
  }
61
61
  return {
62
62
  cancelled: false,
63
+ size: photo.size,
63
64
  source: 'camera',
64
65
  uri: photo.path,
65
66
  ...size,