stream-chat-react-native-core 5.36.1-beta.3 → 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.
Files changed (23) hide show
  1. package/lib/commonjs/components/MessageInput/MessageInput.js +40 -37
  2. package/lib/commonjs/components/MessageInput/MessageInput.js.map +1 -1
  3. package/lib/commonjs/components/MessageInput/components/AudioRecorder/AudioRecorder.js +1 -0
  4. package/lib/commonjs/components/MessageInput/components/AudioRecorder/AudioRecorder.js.map +1 -1
  5. package/lib/commonjs/components/MessageInput/hooks/useAudioController.js +51 -50
  6. package/lib/commonjs/components/MessageInput/hooks/useAudioController.js.map +1 -1
  7. package/lib/commonjs/version.json +1 -1
  8. package/lib/module/components/MessageInput/MessageInput.js +40 -37
  9. package/lib/module/components/MessageInput/MessageInput.js.map +1 -1
  10. package/lib/module/components/MessageInput/components/AudioRecorder/AudioRecorder.js +1 -0
  11. package/lib/module/components/MessageInput/components/AudioRecorder/AudioRecorder.js.map +1 -1
  12. package/lib/module/components/MessageInput/hooks/useAudioController.js +51 -50
  13. package/lib/module/components/MessageInput/hooks/useAudioController.js.map +1 -1
  14. package/lib/module/version.json +1 -1
  15. package/lib/typescript/components/MessageInput/MessageInput.d.ts +1 -1
  16. package/lib/typescript/components/MessageInput/MessageInput.d.ts.map +1 -1
  17. package/lib/typescript/components/MessageInput/hooks/useAudioController.d.ts.map +1 -1
  18. package/package.json +1 -1
  19. package/src/components/MessageInput/MessageInput.tsx +47 -40
  20. package/src/components/MessageInput/__tests__/MessageInput.test.js +60 -1
  21. package/src/components/MessageInput/components/AudioRecorder/AudioRecorder.tsx +1 -1
  22. package/src/components/MessageInput/hooks/useAudioController.tsx +15 -14
  23. package/src/version.json +1 -1
@@ -38,10 +38,12 @@ export const useAudioController = () => {
38
38
  // For playback support in Expo CLI apps
39
39
  const soundRef = useRef<SoundReturnType | null>(null);
40
40
 
41
- // Effect to stop the player when the component unmounts
41
+ // This effect stop the player from playing and stops audio recording on
42
+ // the audio SDK side on unmount.
42
43
  useEffect(
43
44
  () => () => {
44
45
  stopVoicePlayer();
46
+ stopSDKVoiceRecording();
45
47
  },
46
48
  [],
47
49
  );
@@ -163,7 +165,6 @@ export const useAudioController = () => {
163
165
  */
164
166
  const startVoiceRecording = async () => {
165
167
  if (!Audio) return;
166
- setRecordingStatus('recording');
167
168
  const recordingInfo = await Audio.startRecording(
168
169
  {
169
170
  isMeteringEnabled: true,
@@ -178,6 +179,7 @@ export const useAudioController = () => {
178
179
  recording.setProgressUpdateInterval(Platform.OS === 'android' ? 100 : 60);
179
180
  }
180
181
  setRecording(recording);
182
+ setRecordingStatus('recording');
181
183
  await stopVoicePlayer();
182
184
  } else {
183
185
  setPermissionsGranted(false);
@@ -186,22 +188,21 @@ export const useAudioController = () => {
186
188
  }
187
189
  };
188
190
 
191
+ /**
192
+ * A function that takes care of stopping the voice recording from the library's
193
+ * side only. Meant to be used as a pure function (during unmounting for instance)
194
+ * hence this approach.
195
+ */
196
+ const stopSDKVoiceRecording = async () => {
197
+ if (!Audio) return;
198
+ await Audio.stopRecording();
199
+ };
200
+
189
201
  /**
190
202
  * Function to stop voice recording.
191
203
  */
192
204
  const stopVoiceRecording = async () => {
193
- if (!Audio) return;
194
- if (recording) {
195
- // For Expo CLI
196
- if (typeof recording !== 'string') {
197
- await recording.stopAndUnloadAsync();
198
- await Audio.stopRecording();
199
- }
200
- // For RN CLI
201
- else {
202
- await Audio.stopRecording();
203
- }
204
- }
205
+ await stopSDKVoiceRecording();
205
206
  setRecordingStatus('stopped');
206
207
  };
207
208
 
package/src/version.json CHANGED
@@ -1,3 +1,3 @@
1
1
  {
2
- "version": "5.36.1-beta.3"
2
+ "version": "5.36.1-beta.4"
3
3
  }