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.
- package/lib/commonjs/components/MessageInput/MessageInput.js +40 -37
- package/lib/commonjs/components/MessageInput/MessageInput.js.map +1 -1
- package/lib/commonjs/components/MessageInput/components/AudioRecorder/AudioRecorder.js +1 -0
- package/lib/commonjs/components/MessageInput/components/AudioRecorder/AudioRecorder.js.map +1 -1
- package/lib/commonjs/components/MessageInput/hooks/useAudioController.js +51 -50
- package/lib/commonjs/components/MessageInput/hooks/useAudioController.js.map +1 -1
- package/lib/commonjs/version.json +1 -1
- package/lib/module/components/MessageInput/MessageInput.js +40 -37
- package/lib/module/components/MessageInput/MessageInput.js.map +1 -1
- package/lib/module/components/MessageInput/components/AudioRecorder/AudioRecorder.js +1 -0
- package/lib/module/components/MessageInput/components/AudioRecorder/AudioRecorder.js.map +1 -1
- package/lib/module/components/MessageInput/hooks/useAudioController.js +51 -50
- package/lib/module/components/MessageInput/hooks/useAudioController.js.map +1 -1
- package/lib/module/version.json +1 -1
- package/lib/typescript/components/MessageInput/MessageInput.d.ts +1 -1
- package/lib/typescript/components/MessageInput/MessageInput.d.ts.map +1 -1
- package/lib/typescript/components/MessageInput/hooks/useAudioController.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/components/MessageInput/MessageInput.tsx +47 -40
- package/src/components/MessageInput/__tests__/MessageInput.test.js +60 -1
- package/src/components/MessageInput/components/AudioRecorder/AudioRecorder.tsx +1 -1
- package/src/components/MessageInput/hooks/useAudioController.tsx +15 -14
- 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
|
-
//
|
|
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
|
-
|
|
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