@cometchat/chat-uikit-react-native 4.3.20 → 4.3.21
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 +1 -1
- package/src/shared/views/CometChatMediaRecorder/CometChatMediaRecorder.tsx +18 -4
- package/android/.gradle/7.4/checksums/checksums.lock +0 -0
- package/android/.gradle/7.4/dependencies-accessors/dependencies-accessors.lock +0 -0
- package/android/.gradle/7.4/dependencies-accessors/gc.properties +0 -0
- package/android/.gradle/7.4/executionHistory/executionHistory.lock +0 -0
- package/android/.gradle/7.4/fileChanges/last-build.bin +0 -0
- package/android/.gradle/7.4/fileHashes/fileHashes.lock +0 -0
- package/android/.gradle/7.4/gc.properties +0 -0
- package/android/.gradle/buildOutputCleanup/buildOutputCleanup.lock +0 -0
- package/android/.gradle/buildOutputCleanup/cache.properties +0 -2
- package/android/.gradle/vcs-1/gc.properties +0 -0
package/package.json
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import React, { useContext, useEffect } from 'react';
|
|
2
2
|
import { CometChatContext, CometChatContextType, ImageType, localize } from "../..";
|
|
3
|
-
import { View, TouchableOpacity, Text, Image, NativeModules, FlatList, PermissionsAndroid, Alert, Platform, Linking, TextStyle, ViewProps } from "react-native";
|
|
3
|
+
import { View, TouchableOpacity, Text, Image, NativeModules, FlatList, PermissionsAndroid, Alert, Platform, Linking, TextStyle, ViewProps, AppState } from "react-native";
|
|
4
4
|
import { Style } from "./style";
|
|
5
5
|
import { ICONS } from '../../framework/resources';
|
|
6
6
|
import { MediaRecorderStyle, MediaRecorderStyleInterface } from './MediaRecorderStyle';
|
|
7
7
|
|
|
8
8
|
let recordedTime = 0, stopRecordingIntervalId: any = null;
|
|
9
|
+
let recordingStatedAt = 0;
|
|
9
10
|
export interface CometChatMediaRecorderInterface {
|
|
10
11
|
onClose?: Function;
|
|
11
12
|
onPlay?: Function;
|
|
@@ -70,6 +71,18 @@ export const CometChatMediaRecorder = (props: CometChatMediaRecorderInterface) =
|
|
|
70
71
|
}
|
|
71
72
|
}, [])
|
|
72
73
|
|
|
74
|
+
useEffect(() => {
|
|
75
|
+
const subscription = AppState.addEventListener('change', (nextAppState) => {
|
|
76
|
+
if (nextAppState === 'background') {
|
|
77
|
+
_onStop();
|
|
78
|
+
}
|
|
79
|
+
});
|
|
80
|
+
|
|
81
|
+
return () => {
|
|
82
|
+
subscription.remove();
|
|
83
|
+
};
|
|
84
|
+
}, []);
|
|
85
|
+
|
|
73
86
|
function permissionAlert() {
|
|
74
87
|
Alert.alert('', localize("MICROPHONE_PERMISSION"), [
|
|
75
88
|
{
|
|
@@ -114,6 +127,7 @@ export const CometChatMediaRecorder = (props: CometChatMediaRecorderInterface) =
|
|
|
114
127
|
}
|
|
115
128
|
|
|
116
129
|
const startInterval = () => {
|
|
130
|
+
recordingStatedAt = Date.now();
|
|
117
131
|
timerIntervalId = setInterval(timer, 1000);
|
|
118
132
|
}
|
|
119
133
|
|
|
@@ -131,7 +145,7 @@ export const CometChatMediaRecorder = (props: CometChatMediaRecorderInterface) =
|
|
|
131
145
|
const _onStop = () => {
|
|
132
146
|
NativeModules.FileManager.releaseMediaResources((result: string) => {
|
|
133
147
|
console.log(time, "Filepath _stopRecorderAudio", result);
|
|
134
|
-
recordedTime =
|
|
148
|
+
recordedTime = Date.now() - recordingStatedAt;
|
|
135
149
|
setRecordedFile(JSON.parse(result)?.file);
|
|
136
150
|
onStop && onStop(JSON.parse(result)?.file);
|
|
137
151
|
})
|
|
@@ -164,7 +178,7 @@ export const CometChatMediaRecorder = (props: CometChatMediaRecorderInterface) =
|
|
|
164
178
|
onPause && onPause();
|
|
165
179
|
setRecordedPlaying(false);
|
|
166
180
|
clearTimeout(stopRecordingIntervalId);
|
|
167
|
-
}, recordedTime
|
|
181
|
+
}, recordedTime)
|
|
168
182
|
})
|
|
169
183
|
}
|
|
170
184
|
|
|
@@ -246,7 +260,7 @@ export const CometChatMediaRecorder = (props: CometChatMediaRecorderInterface) =
|
|
|
246
260
|
<View style={[Style.timerContainer, { flexDirection: Boolean(recordedFile) ? "row-reverse" : "row" }]}>
|
|
247
261
|
<Text style={[
|
|
248
262
|
timerTextFont && { fontFamily: timerTextFont },
|
|
249
|
-
timerTextColor
|
|
263
|
+
timerTextColor ? { color: timerTextColor } : { color: "#000" },
|
|
250
264
|
timerTextstyle && { fontStyle: timerTextstyle },
|
|
251
265
|
!Boolean(recordedFile) && { marginRight: 10 }
|
|
252
266
|
] as TextStyle}>{formatTime(time)}</Text>
|
|
Binary file
|
|
Binary file
|
|
File without changes
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
File without changes
|
|
Binary file
|
|
File without changes
|