@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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cometchat/chat-uikit-react-native",
3
- "version": "4.3.20",
3
+ "version": "4.3.21",
4
4
  "description": "Ready-to-use Chat UI Components for React Native",
5
5
  "main": "src/index",
6
6
  "module": "src/index",
@@ -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 = time;
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 * 1000)
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 && { color: 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>
File without changes
@@ -1,2 +0,0 @@
1
- #Mon Sep 23 16:45:44 IST 2024
2
- gradle.version=7.4
File without changes