@cometchat/chat-uikit-react-native 4.3.24 → 4.3.25
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/android/src/main/java/com/reactnativecometchatuikit/FileManager.java +1 -1
- package/ios/CometchatUiKit.mm +0 -13
- package/ios/FileManager.m +7 -0
- package/package.json +1 -1
- package/react-native-cometchat-ui-kit.podspec +0 -16
- package/src/CometChatConversations/CometChatConversations.tsx +44 -18
- package/src/CometChatConversationsWithMessages/CometChatConversationsWithMessages.tsx +2 -5
- package/src/CometChatDetails/CometChatDetails.tsx +128 -85
- package/src/CometChatGroupsWithMessages/CometChatGroupsWithMessages.tsx +2 -5
- package/src/CometChatMessageComposer/CometChatMessageComposer.tsx +18 -14
- package/src/CometChatMessageHeader/CometChatMessageHeader.tsx +78 -19
- package/src/CometChatMessageInformation/CometChatMessageInformation.tsx +57 -17
- package/src/CometChatMessages/CometChatMessages.tsx +2 -5
- package/src/CometChatTabs/CometChatTabs.tsx +1 -1
- package/src/CometChatThreadedMessages/CometChatThreadedMessages.tsx +6 -2
- package/src/calls/CometChatIncomingCall/CometChatIncomingCall.tsx +6 -0
- package/src/index.ts +20 -1
- package/src/shared/index.ts +4 -0
- package/src/shared/libs/VideoPlayer/Video.js +4 -4
- package/src/shared/resources/CometChatLocalize/CometChatLocalize.ts +3 -4
- package/src/shared/resources/CometChatLocalize/resources/ar/translation.json +1 -0
- package/src/shared/resources/CometChatLocalize/resources/de/translation.json +1 -0
- package/src/shared/resources/CometChatLocalize/resources/en/translation.json +1 -0
- package/src/shared/resources/CometChatLocalize/resources/es/translation.json +1 -0
- package/src/shared/resources/CometChatLocalize/resources/fr/translation.json +1 -0
- package/src/shared/resources/CometChatLocalize/resources/hi/translation.json +1 -0
- package/src/shared/resources/CometChatLocalize/resources/hu/translation.json +1 -0
- package/src/shared/resources/CometChatLocalize/resources/lt/translation.json +1 -0
- package/src/shared/resources/CometChatLocalize/resources/ms/translation.json +1 -0
- package/src/shared/resources/CometChatLocalize/resources/pt/translation.json +1 -0
- package/src/shared/resources/CometChatLocalize/resources/ru/translation.json +1 -0
- package/src/shared/resources/CometChatLocalize/resources/sv/translation.json +1 -0
- package/src/shared/resources/CometChatLocalize/resources/zh/translation.json +1 -0
- package/src/shared/resources/CometChatLocalize/resources/zh-tw/translation.json +1 -0
- package/src/shared/utils/CommonUtils.ts +1 -1
- package/src/shared/views/CometChatBottomSheet/CometChatBottomSheet.tsx +2 -2
- package/src/shared/views/CometChatDate/CometChatDate.tsx +1 -1
- package/src/shared/views/CometChatList/CometChatList.tsx +24 -3
- package/src/shared/views/CometChatReceipt/CometChatReceipt.tsx +14 -14
- package/src/shared/views/CometChatReceipt/ReceiptStyle.ts +39 -1
- package/src/shared/views/CometChatReceipt/index.ts +4 -2
- package/src/shared/views/CometChatStatusIndicator/CometChatStatusIndicator.tsx +1 -1
- package/src/shared/views/index.ts +4 -0
|
@@ -12,6 +12,7 @@ import {
|
|
|
12
12
|
Text,
|
|
13
13
|
ViewProps,
|
|
14
14
|
TextStyle,
|
|
15
|
+
TextInput,
|
|
15
16
|
} from 'react-native';
|
|
16
17
|
import { Style } from './styles';
|
|
17
18
|
import {
|
|
@@ -612,8 +613,7 @@ export const CometChatMessageComposer = React.forwardRef(
|
|
|
612
613
|
messageComposerStyle = {},
|
|
613
614
|
} = props;
|
|
614
615
|
|
|
615
|
-
const
|
|
616
|
-
ChatConfigurator.dataSource.getAttachmentOptions(user, group, id);
|
|
616
|
+
const messageComposerId = id ?? `${user ? user.getUid() : ''}${group ? group.getGuid() : ''}${parentMessageId ?? ''}`;
|
|
617
617
|
|
|
618
618
|
const composerIdMap = new Map().set('parentMessageId', parentMessageId);
|
|
619
619
|
const defaultAuxiliaryButtonOptions =
|
|
@@ -627,7 +627,7 @@ export const CometChatMessageComposer = React.forwardRef(
|
|
|
627
627
|
const loggedInUser = React.useRef<any>({});
|
|
628
628
|
const chatWith = React.useRef<any>(null);
|
|
629
629
|
const chatWithId = React.useRef<any>(null);
|
|
630
|
-
const messageInputRef = React.useRef<
|
|
630
|
+
const messageInputRef = React.useRef<TextInput>(null);
|
|
631
631
|
const chatRef = React.useRef<any>(chatWith);
|
|
632
632
|
const inputValueRef = React.useRef<any>(null);
|
|
633
633
|
const plainTextInput = React.useRef<string>(text ?? '');
|
|
@@ -889,6 +889,10 @@ export const CometChatMessageComposer = React.forwardRef(
|
|
|
889
889
|
const clearInputBox = () => {
|
|
890
890
|
inputValueRef.current = '';
|
|
891
891
|
setInputMessage('');
|
|
892
|
+
setTimeout(() => {
|
|
893
|
+
messageInputRef.current.clear();
|
|
894
|
+
setInputMessage('');
|
|
895
|
+
}, 100);
|
|
892
896
|
};
|
|
893
897
|
|
|
894
898
|
const sendTextMessage = () => {
|
|
@@ -980,7 +984,7 @@ export const CometChatMessageComposer = React.forwardRef(
|
|
|
980
984
|
|
|
981
985
|
inputValueRef.current = '';
|
|
982
986
|
setInputMessage('');
|
|
983
|
-
messageInputRef.current.
|
|
987
|
+
messageInputRef.current.clear();
|
|
984
988
|
|
|
985
989
|
setMessagePreview(null);
|
|
986
990
|
|
|
@@ -1167,9 +1171,9 @@ export const CometChatMessageComposer = React.forwardRef(
|
|
|
1167
1171
|
};
|
|
1168
1172
|
|
|
1169
1173
|
const AuxiliaryButtonViewElem = () => {
|
|
1170
|
-
if (AuxiliaryButtonView &&
|
|
1174
|
+
if (AuxiliaryButtonView && messageComposerId)
|
|
1171
1175
|
return (
|
|
1172
|
-
<AuxiliaryButtonView user={user} group={group} composerId={
|
|
1176
|
+
<AuxiliaryButtonView user={user} group={group} composerId={messageComposerId} />
|
|
1173
1177
|
);
|
|
1174
1178
|
else if (defaultAuxiliaryButtonOptions)
|
|
1175
1179
|
return (
|
|
@@ -1184,8 +1188,8 @@ export const CometChatMessageComposer = React.forwardRef(
|
|
|
1184
1188
|
};
|
|
1185
1189
|
|
|
1186
1190
|
const SendButtonViewElem = () => {
|
|
1187
|
-
if (SendButtonView &&
|
|
1188
|
-
return <SendButtonView user={user} group={group} composerId={
|
|
1191
|
+
if (SendButtonView && messageComposerId)
|
|
1192
|
+
return <SendButtonView user={user} group={group} composerId={messageComposerId} />;
|
|
1189
1193
|
return (
|
|
1190
1194
|
<ImageButton
|
|
1191
1195
|
image={ICONS.SEND}
|
|
@@ -1206,9 +1210,9 @@ export const CometChatMessageComposer = React.forwardRef(
|
|
|
1206
1210
|
};
|
|
1207
1211
|
|
|
1208
1212
|
const SecondaryButtonViewElem = () => {
|
|
1209
|
-
if (SecondaryButtonView &&
|
|
1213
|
+
if (SecondaryButtonView && messageComposerId)
|
|
1210
1214
|
return (
|
|
1211
|
-
<SecondaryButtonView user={user} group={group} composerId={
|
|
1215
|
+
<SecondaryButtonView user={user} group={group} composerId={messageComposerId} />
|
|
1212
1216
|
);
|
|
1213
1217
|
return (
|
|
1214
1218
|
<AttachIconButton
|
|
@@ -1303,7 +1307,7 @@ export const CometChatMessageComposer = React.forwardRef(
|
|
|
1303
1307
|
}
|
|
1304
1308
|
|
|
1305
1309
|
_formatter.forEach((formatter) => {
|
|
1306
|
-
|
|
1310
|
+
messageComposerId && formatter.setComposerId(messageComposerId);
|
|
1307
1311
|
user && formatter.setUser(user);
|
|
1308
1312
|
group && formatter.setGroup(group);
|
|
1309
1313
|
let trackingCharacter = formatter.getTrackingCharacter();
|
|
@@ -1412,7 +1416,7 @@ export const CometChatMessageComposer = React.forwardRef(
|
|
|
1412
1416
|
let newAiOptions: any = _getAIOptions(aiOptions);
|
|
1413
1417
|
setAIOptionItems(newAiOptions);
|
|
1414
1418
|
setRootAIOptionItems(newAiOptions);
|
|
1415
|
-
}, [user, group,
|
|
1419
|
+
}, [user, group, messageComposerId, parentMessageId]);
|
|
1416
1420
|
|
|
1417
1421
|
const _getAIOptions = (
|
|
1418
1422
|
options: (
|
|
@@ -1468,7 +1472,7 @@ export const CometChatMessageComposer = React.forwardRef(
|
|
|
1468
1472
|
id: string | number;
|
|
1469
1473
|
data: Array<SuggestionItem>;
|
|
1470
1474
|
}) {
|
|
1471
|
-
if (activeCharacter.current &&
|
|
1475
|
+
if (activeCharacter.current && messageComposerId === item?.id) {
|
|
1472
1476
|
setMentionsSearchData(item?.data);
|
|
1473
1477
|
setSuggestionListLoader(false);
|
|
1474
1478
|
}
|
|
@@ -1966,7 +1970,7 @@ export const CometChatMessageComposer = React.forwardRef(
|
|
|
1966
1970
|
{CustomView && CustomView}
|
|
1967
1971
|
</Modal>
|
|
1968
1972
|
<KeyboardAvoidingView
|
|
1969
|
-
key={
|
|
1973
|
+
key={messageComposerId}
|
|
1970
1974
|
behavior={Platform.OS === 'ios' ? 'padding' : 'height'}
|
|
1971
1975
|
keyboardVerticalOffset={Platform.select({ ios: kbOffset })}
|
|
1972
1976
|
{...keyboardAvoidingViewProps}
|
|
@@ -34,6 +34,7 @@ import {
|
|
|
34
34
|
} from '../shared/constants/UIKitConstants';
|
|
35
35
|
import { CometChatContextType } from '../shared/base/Types';
|
|
36
36
|
import { CometChatUIEventHandler } from '../shared/events/CometChatUIEventHandler/CometChatUIEventHandler';
|
|
37
|
+
import { CommonUtils } from '../shared/utils/CommonUtils';
|
|
37
38
|
export interface MessageHeaderStyleInterface {
|
|
38
39
|
width?: string | number;
|
|
39
40
|
height?: string | number;
|
|
@@ -189,6 +190,7 @@ export const CometChatMessageHeader = (
|
|
|
189
190
|
const userStatusListenerId = 'user_status_' + new Date().getTime();
|
|
190
191
|
const msgTypingListenerId = 'message_typing_' + new Date().getTime();
|
|
191
192
|
const groupListenerId = 'head_group_' + new Date().getTime();
|
|
193
|
+
const userListenerId = 'head_user_' + new Date().getTime();
|
|
192
194
|
|
|
193
195
|
const {
|
|
194
196
|
SubtitleView,
|
|
@@ -221,9 +223,7 @@ export const CometChatMessageHeader = (
|
|
|
221
223
|
});
|
|
222
224
|
|
|
223
225
|
const [groupObj, setGroupObj] = useState(group);
|
|
224
|
-
const [userStatus, setUserStatus] = useState(
|
|
225
|
-
user && user.getStatus ? user.getStatus() : ''
|
|
226
|
-
);
|
|
226
|
+
const [userStatus, setUserStatus] = useState('');
|
|
227
227
|
const [typingText, setTypingText] = useState('');
|
|
228
228
|
|
|
229
229
|
const receiverTypeRef = useRef(
|
|
@@ -239,7 +239,13 @@ export const CometChatMessageHeader = (
|
|
|
239
239
|
}, [group]);
|
|
240
240
|
|
|
241
241
|
useEffect(() => {
|
|
242
|
-
|
|
242
|
+
if (user) {
|
|
243
|
+
if (!(user.getHasBlockedMe() || user.getBlockedByMe())) {
|
|
244
|
+
setUserStatus(user.getStatus());
|
|
245
|
+
return;
|
|
246
|
+
}
|
|
247
|
+
setUserStatus('');
|
|
248
|
+
}
|
|
243
249
|
}, [user]);
|
|
244
250
|
|
|
245
251
|
const BackButton = () => {
|
|
@@ -282,6 +288,23 @@ export const CometChatMessageHeader = (
|
|
|
282
288
|
</Text>
|
|
283
289
|
);
|
|
284
290
|
if (disableUsersPresence) return null;
|
|
291
|
+
|
|
292
|
+
const subtitleText =
|
|
293
|
+
receiverTypeRef.current === CometChat.RECEIVER_TYPE.GROUP &&
|
|
294
|
+
groupObj?.["membersCount"]
|
|
295
|
+
? groupObj["membersCount"] === 1
|
|
296
|
+
? `1 ${localize("MEMBER")}`
|
|
297
|
+
: `${groupObj["membersCount"]} ${localize("MEMBERS")}`
|
|
298
|
+
: receiverTypeRef.current === CometChat.RECEIVER_TYPE.USER
|
|
299
|
+
? userStatus === UserStatusConstants.online
|
|
300
|
+
? localize('ONLINE')
|
|
301
|
+
: userStatus === UserStatusConstants.offline
|
|
302
|
+
? localize('OFFLINE')
|
|
303
|
+
: ''
|
|
304
|
+
: '';
|
|
305
|
+
|
|
306
|
+
if (!subtitleText) return null;
|
|
307
|
+
|
|
285
308
|
return (
|
|
286
309
|
<Text
|
|
287
310
|
style={
|
|
@@ -291,21 +314,23 @@ export const CometChatMessageHeader = (
|
|
|
291
314
|
] as TextStyle[]
|
|
292
315
|
}
|
|
293
316
|
>
|
|
294
|
-
{
|
|
295
|
-
(groupObj?.['membersCount'] || groupObj?.['membersCount'] === 0)
|
|
296
|
-
? `${groupObj['membersCount']} ${localize('MEMBERS')}`
|
|
297
|
-
: receiverTypeRef.current === CometChat.RECEIVER_TYPE.USER
|
|
298
|
-
? userStatus === UserStatusConstants.online
|
|
299
|
-
? localize('ONLINE')
|
|
300
|
-
: localize('OFFLINE')
|
|
301
|
-
: ''}
|
|
317
|
+
{subtitleText}
|
|
302
318
|
</Text>
|
|
303
319
|
);
|
|
304
320
|
};
|
|
305
321
|
|
|
306
|
-
const handleUserStatus = (
|
|
307
|
-
|
|
308
|
-
|
|
322
|
+
const handleUserStatus = useCallback(
|
|
323
|
+
(userDetails: any) => {
|
|
324
|
+
if (userDetails.uid === user?.getUid()) {
|
|
325
|
+
if (user.getHasBlockedMe() || user.getBlockedByMe()) {
|
|
326
|
+
setUserStatus('');
|
|
327
|
+
return;
|
|
328
|
+
}
|
|
329
|
+
setUserStatus(userDetails.status);
|
|
330
|
+
}
|
|
331
|
+
},
|
|
332
|
+
[user]
|
|
333
|
+
);
|
|
309
334
|
|
|
310
335
|
const msgTypingIndicator = (typist: any, status: string) => {
|
|
311
336
|
if (
|
|
@@ -321,7 +346,8 @@ export const CometChatMessageHeader = (
|
|
|
321
346
|
} else if (
|
|
322
347
|
receiverTypeRef.current === CometChat.RECEIVER_TYPE.USER &&
|
|
323
348
|
receiverTypeRef.current === typist.receiverType &&
|
|
324
|
-
user?.getUid() === typist.sender.uid
|
|
349
|
+
user?.getUid() === typist.sender.uid &&
|
|
350
|
+
!(user?.getBlockedByMe() || user?.getHasBlockedMe())
|
|
325
351
|
) {
|
|
326
352
|
setTypingText(status === 'typing' ? localize('TYPING') : '');
|
|
327
353
|
}
|
|
@@ -364,7 +390,7 @@ export const CometChatMessageHeader = (
|
|
|
364
390
|
}
|
|
365
391
|
listners.removeListner.removeMessageListener({ msgTypingListenerId });
|
|
366
392
|
};
|
|
367
|
-
}, []);
|
|
393
|
+
}, [user]);
|
|
368
394
|
|
|
369
395
|
const handleGroupMemberKicked = ({
|
|
370
396
|
message,
|
|
@@ -406,16 +432,49 @@ export const CometChatMessageHeader = (
|
|
|
406
432
|
};
|
|
407
433
|
}, []);
|
|
408
434
|
|
|
435
|
+
useEffect(() => {
|
|
436
|
+
CometChatUIEventHandler.addUserListener(userListenerId, {
|
|
437
|
+
ccUserBlocked: ({ user: blockedUser }: { user: CometChat.User }) => {
|
|
438
|
+
if (user.getUid() === blockedUser.getUid()) {
|
|
439
|
+
setUserStatus('');
|
|
440
|
+
}
|
|
441
|
+
},
|
|
442
|
+
ccUserUnBlocked: ({ user: unblockedUser }: { user: CometChat.User }) => {
|
|
443
|
+
if (user.getUid() !== unblockedUser.getUid()) {
|
|
444
|
+
return;
|
|
445
|
+
}
|
|
446
|
+
setUserStatus(unblockedUser.getStatus());
|
|
447
|
+
},
|
|
448
|
+
});
|
|
449
|
+
return () => {
|
|
450
|
+
CometChatUIEventHandler.removeUserListener(userListenerId);
|
|
451
|
+
};
|
|
452
|
+
}, [user]);
|
|
453
|
+
|
|
409
454
|
const AppBarOptionsView = useCallback(() => {
|
|
455
|
+
/*************Start Of: This is required for the below scenario***********/
|
|
456
|
+
// user(prop) is online
|
|
457
|
+
// on blocking the user, userStatus is updated to offline and this has to be passed to Details
|
|
458
|
+
// user status in original user prop (for example, the reference in conversation -> conversationWith) is updated to offline on blocking but will only be propagated to MessageHeader on reopening Messages
|
|
459
|
+
let clonedUser: CometChat.User;
|
|
460
|
+
if (user) {
|
|
461
|
+
clonedUser = CommonUtils.clone(user);
|
|
462
|
+
clonedUser.setStatus(userStatus);
|
|
463
|
+
}
|
|
464
|
+
/*************End Of: This is required for the below scenario***********/
|
|
410
465
|
if (AppBarOptions) {
|
|
411
466
|
return (
|
|
412
467
|
<AppBarOptions
|
|
413
|
-
{...(user
|
|
468
|
+
{...(user
|
|
469
|
+
? { user: clonedUser }
|
|
470
|
+
: groupObj
|
|
471
|
+
? { group: groupObj }
|
|
472
|
+
: {})}
|
|
414
473
|
/>
|
|
415
474
|
);
|
|
416
475
|
}
|
|
417
476
|
return null;
|
|
418
|
-
}, [user
|
|
477
|
+
}, [userStatus, user, groupObj]);
|
|
419
478
|
|
|
420
479
|
return (
|
|
421
480
|
<View
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import React, { useContext, useEffect, useState } from 'react'
|
|
1
|
+
import React, { useCallback, useContext, useEffect, useState } from 'react'
|
|
2
2
|
import { Dimensions, FlatList, Image, Text, TouchableOpacity, View, ScrollView, TextStyle, ViewProps, ActivityIndicator } from 'react-native'
|
|
3
3
|
//@ts-ignore
|
|
4
4
|
import { CometChat } from '@cometchat/chat-sdk-react-native'
|
|
5
|
-
import { AvatarStyleInterface, ChatConfigurator, CometChatContext, CometChatDate, CometChatListItem, CometChatMessageTemplate, CometChatUIEventHandler, ImageType, ListItemStyleInterface, StatusIndicatorStyleInterface, localize } from '../shared'
|
|
5
|
+
import { AvatarStyleInterface, ChatConfigurator, CometChatContext, CometChatDate, CometChatListItem, CometChatMessageTemplate, CometChatUIEventHandler, CometChatUiKitConstants, ImageType, ListItemStyleInterface, StatusIndicatorStyleInterface, localize } from '../shared'
|
|
6
6
|
import { MessageInformationStyleInterface } from './MessageInformationStyle'
|
|
7
7
|
import { MessageUtils } from '../shared/utils/MessageUtils'
|
|
8
8
|
import { CommonUtils } from '../shared/utils/CommonUtils'
|
|
@@ -95,10 +95,6 @@ export const CometChatMessageInformation = (props: CometChatMessageInformationIn
|
|
|
95
95
|
} = messageInformationStyle || {};
|
|
96
96
|
|
|
97
97
|
const receipt = (receipt: any, status: any, time: any) => {
|
|
98
|
-
|
|
99
|
-
if (ListItemView) {
|
|
100
|
-
return ListItemView(message, receipt);
|
|
101
|
-
}
|
|
102
98
|
return <View style={{ flexDirection: 'row', alignItems: 'center' }}>
|
|
103
99
|
<Image
|
|
104
100
|
source={receipt == 'SENT' ? sentIcon :
|
|
@@ -119,7 +115,7 @@ export const CometChatMessageInformation = (props: CometChatMessageInformationIn
|
|
|
119
115
|
<Text style={[
|
|
120
116
|
{ color: subtitleTextColor || theme.palette.getAccent600() },
|
|
121
117
|
subtitleTextFont
|
|
122
|
-
] as TextStyle}>{status}</Text>
|
|
118
|
+
] as TextStyle[]}>{status}</Text>
|
|
123
119
|
</View>
|
|
124
120
|
{
|
|
125
121
|
receiptDatePattern ?
|
|
@@ -145,6 +141,9 @@ export const CometChatMessageInformation = (props: CometChatMessageInformationIn
|
|
|
145
141
|
}
|
|
146
142
|
|
|
147
143
|
const renderReceipients = ({ item, index }: any) => {
|
|
144
|
+
if (ListItemView) {
|
|
145
|
+
return ListItemView(message, item);
|
|
146
|
+
}
|
|
148
147
|
const { sender } = item;
|
|
149
148
|
if(!(item['deliveredAt'] || item['readAt'] )) {
|
|
150
149
|
return null;
|
|
@@ -188,19 +187,56 @@ export const CometChatMessageInformation = (props: CometChatMessageInformationIn
|
|
|
188
187
|
}
|
|
189
188
|
}
|
|
190
189
|
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
190
|
+
const updateMessageReceipt = useCallback(
|
|
191
|
+
(newReceipt: any) => {
|
|
192
|
+
let checkId;
|
|
193
|
+
if(newReceipt.messageId) {
|
|
194
|
+
checkId = newReceipt.messageId ? newReceipt.messageId : newReceipt.id;
|
|
195
|
+
} else {
|
|
196
|
+
checkId = newReceipt.getId();
|
|
197
|
+
}
|
|
198
|
+
if (message.getId() === checkId) {
|
|
199
|
+
if (message.getReceiverType() === CometChatUiKitConstants.ReceiverTypeConstants.user) {
|
|
200
|
+
const readAt = message.getReadAt() || recipients[0]?.readAt || newReceipt.getReadAt();
|
|
201
|
+
const deliveredAt = message.getDeliveredAt() || recipients[0]?.deliveredAt || newReceipt.getDeliveredAt() || readAt;
|
|
202
|
+
const udpatedReceipt = {
|
|
203
|
+
sender: message.getReceiver(),
|
|
204
|
+
sentAt: message.getSentAt(),
|
|
205
|
+
readAt: readAt,
|
|
206
|
+
deliveredAt: deliveredAt
|
|
207
|
+
};
|
|
208
|
+
setRecipients([udpatedReceipt]);
|
|
209
|
+
return;
|
|
199
210
|
}
|
|
200
|
-
|
|
211
|
+
|
|
212
|
+
const receiptIndex = recipients.findIndex((rec) => {
|
|
213
|
+
return (
|
|
214
|
+
(rec as any).sender.getUid() ===
|
|
215
|
+
newReceipt.sender.getUid()
|
|
216
|
+
);
|
|
217
|
+
});
|
|
218
|
+
|
|
219
|
+
if (receiptIndex > -1) {
|
|
220
|
+
let oldReceipt = recipients[receiptIndex] as any;
|
|
221
|
+
oldReceipt.setDeliveredAt(oldReceipt.getDeliveredAt() || newReceipt.getDeliveredAt() || newReceipt.getReadAt());
|
|
222
|
+
oldReceipt.setReadAt(oldReceipt.getReadAt() || newReceipt.getReadAt());
|
|
223
|
+
let receiptsList = [...recipients];
|
|
224
|
+
receiptsList.splice(receiptIndex, 1, oldReceipt);
|
|
225
|
+
setRecipients(receiptsList);
|
|
226
|
+
} else {
|
|
227
|
+
newReceipt.setDeliveredAt(newReceipt.getDeliveredAt() || newReceipt.getReadAt());
|
|
228
|
+
setRecipients([newReceipt, ...recipients]);
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
},
|
|
232
|
+
[recipients, message]
|
|
233
|
+
);
|
|
234
|
+
|
|
235
|
+
useEffect(() => {
|
|
236
|
+
loadTemplates();
|
|
237
|
+
}, []);
|
|
201
238
|
|
|
202
239
|
useEffect(() => {
|
|
203
|
-
loadTemplates()
|
|
204
240
|
//add listener for message delivery
|
|
205
241
|
CometChatUIEventHandler.addMessageListener(
|
|
206
242
|
listenerId,
|
|
@@ -213,6 +249,10 @@ export const CometChatMessageInformation = (props: CometChatMessageInformationIn
|
|
|
213
249
|
},
|
|
214
250
|
}
|
|
215
251
|
)
|
|
252
|
+
return () => {
|
|
253
|
+
// clean up code like removing listeners
|
|
254
|
+
CometChatUIEventHandler.removeMessageListener(listenerId);
|
|
255
|
+
}
|
|
216
256
|
}, []);
|
|
217
257
|
|
|
218
258
|
useEffect(() => {
|
|
@@ -109,12 +109,9 @@ export const CometChatMessages = (props: CometChatMessagesInterface) => {
|
|
|
109
109
|
}
|
|
110
110
|
|
|
111
111
|
useEffect(() => {
|
|
112
|
-
BackHandler.addEventListener('hardwareBackPress', handleBack);
|
|
112
|
+
const backHandlerListener = BackHandler.addEventListener('hardwareBackPress', handleBack);
|
|
113
113
|
return () => {
|
|
114
|
-
|
|
115
|
-
'hardwareBackPress',
|
|
116
|
-
handleBack
|
|
117
|
-
);
|
|
114
|
+
backHandlerListener.remove();
|
|
118
115
|
};
|
|
119
116
|
}, [showComponent]);
|
|
120
117
|
|
|
@@ -147,7 +147,7 @@ export const CometChatTabs = (props: CometChatTabsInterface) => {
|
|
|
147
147
|
const TabsList = () => {
|
|
148
148
|
return (
|
|
149
149
|
<View style={{flexDirection: 'row', backgroundColor: style?.backgroundColor, borderRadius: style?.borderRadius, margin: 15, marginTop: 0}}>
|
|
150
|
-
{ tabs.map(item=> <TabItemView item={item}/>) }
|
|
150
|
+
{ tabs.map((item, index)=> <TabItemView key={index} item={item}/>) }
|
|
151
151
|
</View>
|
|
152
152
|
)
|
|
153
153
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { View, Text, Image, ViewStyle, Platform, ScrollView, TextStyle } from 'react-native';
|
|
1
|
+
import { View, Text, Image, ViewStyle, Platform, ScrollView, TextStyle, DimensionValue, Dimensions } from 'react-native';
|
|
2
2
|
import React, { useContext, useEffect, useRef, useState } from 'react';
|
|
3
3
|
import Header from './Header';
|
|
4
4
|
import { ICONS } from './resources';
|
|
@@ -23,6 +23,7 @@ import { CometChatContextType } from '../shared/base/Types';
|
|
|
23
23
|
import { useKeyboard } from '../shared/helper/useKeyboard';
|
|
24
24
|
import { CometChatUIEventHandler } from '../shared/events/CometChatUIEventHandler/CometChatUIEventHandler';
|
|
25
25
|
import { commonVars } from '../shared/base/vars';
|
|
26
|
+
const screenHeight = Dimensions.get('window').height;
|
|
26
27
|
|
|
27
28
|
const uiEventId = 'ccUiEvent' + new Date().getTime();
|
|
28
29
|
export interface CometChatThreadedMessagesInterface {
|
|
@@ -148,6 +149,9 @@ export const CometChatThreadedMessages = (
|
|
|
148
149
|
);
|
|
149
150
|
|
|
150
151
|
const keyboardHeight = useKeyboard();
|
|
152
|
+
const bubbleViewMaxHeight = (Math.floor(
|
|
153
|
+
((screenHeight - keyboardHeight - 280) / screenHeight) * 100
|
|
154
|
+
) + '%') as DimensionValue;
|
|
151
155
|
|
|
152
156
|
let limit: number = 30;
|
|
153
157
|
|
|
@@ -264,7 +268,7 @@ export const CometChatThreadedMessages = (
|
|
|
264
268
|
threadedMessagesStyle?.closeIconTint ?? theme.palette.getPrimary()
|
|
265
269
|
}
|
|
266
270
|
/>
|
|
267
|
-
<View style={styles.msgBubbleContainer}>
|
|
271
|
+
<View style={[styles.msgBubbleContainer, { maxHeight: bubbleViewMaxHeight }]}>
|
|
268
272
|
<ScrollView>
|
|
269
273
|
{BubbleView && BubbleView(message)}
|
|
270
274
|
</ScrollView>
|
|
@@ -163,6 +163,12 @@ export const CometChatIncomingCall = (props: CometChatIncomingCallInterface) =>
|
|
|
163
163
|
new CometChat.CallListener({
|
|
164
164
|
onIncomingCallCancelled: (call: any) => {
|
|
165
165
|
CometChatSoundManager.pause();
|
|
166
|
+
},
|
|
167
|
+
onOutgoingCallAccepted: (call: any) => {
|
|
168
|
+
CometChatSoundManager.pause();
|
|
169
|
+
},
|
|
170
|
+
onOutgoingCallRejected: (call: any) => {
|
|
171
|
+
CometChatSoundManager.pause();
|
|
166
172
|
}
|
|
167
173
|
})
|
|
168
174
|
);
|
package/src/index.ts
CHANGED
|
@@ -45,6 +45,7 @@ import {
|
|
|
45
45
|
CometChatBadge,
|
|
46
46
|
CometChatStatusIndicator,
|
|
47
47
|
CometChatReceipt,
|
|
48
|
+
ReceiptStyle,
|
|
48
49
|
CometChatDate,
|
|
49
50
|
AudioBubbleStyleInterface,
|
|
50
51
|
CometChatAudioBubble,
|
|
@@ -108,6 +109,7 @@ import {
|
|
|
108
109
|
CometChatMessageInputInterface,
|
|
109
110
|
CometChatMessageInputStyleInterface,
|
|
110
111
|
CometChatReceiptInterface,
|
|
112
|
+
ReceiptStyleInterface,
|
|
111
113
|
CometChatStatusIndicatorInterface,
|
|
112
114
|
DateConfigurationInterface,
|
|
113
115
|
DateStyleInterface,
|
|
@@ -186,6 +188,7 @@ import {
|
|
|
186
188
|
UsersStyle,
|
|
187
189
|
UsersStyleInterface,
|
|
188
190
|
UsersConfigurationInterface,
|
|
191
|
+
UsersConfiguration,
|
|
189
192
|
} from "./CometChatUsers";
|
|
190
193
|
|
|
191
194
|
import {
|
|
@@ -193,11 +196,13 @@ import {
|
|
|
193
196
|
GroupsConfigurationInterface,
|
|
194
197
|
GroupsStyleInterface,
|
|
195
198
|
CometChatGroupsInterface,
|
|
199
|
+
GroupsConfiguration,
|
|
196
200
|
} from "./CometChatGroups";
|
|
197
201
|
|
|
198
202
|
import {
|
|
199
203
|
CometChatConversations,
|
|
200
204
|
ConversationInterface,
|
|
205
|
+
ConversationsConfiguration,
|
|
201
206
|
ConversationsConfigurationInterface,
|
|
202
207
|
ConversationsStyleInterface,
|
|
203
208
|
} from "./CometChatConversations";
|
|
@@ -261,6 +266,7 @@ import {
|
|
|
261
266
|
import {
|
|
262
267
|
CometChatMessageHeader,
|
|
263
268
|
CometChatMessageHeaderInterface,
|
|
269
|
+
MessageHeaderConfiguration,
|
|
264
270
|
MessageHeaderConfigurationInterface,
|
|
265
271
|
MessageHeaderStyleInterface,
|
|
266
272
|
} from "./CometChatMessageHeader";
|
|
@@ -279,11 +285,13 @@ import {
|
|
|
279
285
|
CometChatMessageListProps,
|
|
280
286
|
MessageListStyleInterface,
|
|
281
287
|
MessageListConfigurationInterface,
|
|
288
|
+
MessageListConfiguration,
|
|
282
289
|
} from "./CometChatMessageList";
|
|
283
290
|
|
|
284
291
|
import {
|
|
285
292
|
CometChatMessageComposer,
|
|
286
293
|
CometChatMessageComposerInterface,
|
|
294
|
+
MessageComposerConfiguration,
|
|
287
295
|
MessageComposerConfigurationInterface,
|
|
288
296
|
MessageComposerStyleInterface,
|
|
289
297
|
} from "./CometChatMessageComposer";
|
|
@@ -299,6 +307,7 @@ import {
|
|
|
299
307
|
import {
|
|
300
308
|
CometChatThreadedMessages,
|
|
301
309
|
CometChatThreadedMessagesInterface,
|
|
310
|
+
ThreadedMessagesConfiguration,
|
|
302
311
|
ThreadedMessagesConfigurationInterface,
|
|
303
312
|
ThreadedMessagesStyleInterface,
|
|
304
313
|
} from "./CometChatThreadedMessages";
|
|
@@ -488,6 +497,7 @@ export {
|
|
|
488
497
|
CometChatBadge,
|
|
489
498
|
CometChatStatusIndicator,
|
|
490
499
|
CometChatReceipt,
|
|
500
|
+
ReceiptStyle,
|
|
491
501
|
CometChatDate,
|
|
492
502
|
CometChatAudioBubble,
|
|
493
503
|
CometChatFileBubble,
|
|
@@ -581,8 +591,16 @@ export {
|
|
|
581
591
|
/* Text Formatters */
|
|
582
592
|
DateTimeElement,
|
|
583
593
|
CometChatDateTimePicker,
|
|
584
|
-
CometChatMessageInformationConfiguration
|
|
594
|
+
CometChatMessageInformationConfiguration,
|
|
595
|
+
ConversationsConfiguration,
|
|
596
|
+
MessageListConfiguration,
|
|
597
|
+
MessageHeaderConfiguration,
|
|
598
|
+
MessageComposerConfiguration,
|
|
599
|
+
UsersConfiguration,
|
|
600
|
+
GroupsConfiguration,
|
|
601
|
+
ThreadedMessagesConfiguration,
|
|
585
602
|
};
|
|
603
|
+
|
|
586
604
|
export type {
|
|
587
605
|
ThumbnailGenerationConfigurationInterface,
|
|
588
606
|
PollsStyleInterface,
|
|
@@ -707,6 +725,7 @@ export type {
|
|
|
707
725
|
CometChatMessageInputInterface,
|
|
708
726
|
CometChatMessageInputStyleInterface,
|
|
709
727
|
CometChatReceiptInterface,
|
|
728
|
+
ReceiptStyleInterface,
|
|
710
729
|
CometChatStatusIndicatorInterface,
|
|
711
730
|
DateConfigurationInterface,
|
|
712
731
|
DateStyleInterface,
|
package/src/shared/index.ts
CHANGED
|
@@ -95,6 +95,7 @@ import {
|
|
|
95
95
|
BadgeStyle,
|
|
96
96
|
DateConfiguration,
|
|
97
97
|
ReceiptConfiguration,
|
|
98
|
+
ReceiptStyle,
|
|
98
99
|
StatusIndicatorConfiguration,
|
|
99
100
|
StatusIndicatorStyle,
|
|
100
101
|
DateStyle,
|
|
@@ -149,6 +150,7 @@ import {
|
|
|
149
150
|
CometChatMessageInputInterface,
|
|
150
151
|
CometChatMessageInputStyleInterface,
|
|
151
152
|
CometChatReceiptInterface,
|
|
153
|
+
ReceiptStyleInterface,
|
|
152
154
|
CometChatStatusIndicatorInterface,
|
|
153
155
|
DateConfigurationInterface,
|
|
154
156
|
DateStyleInterface,
|
|
@@ -258,6 +260,7 @@ export {
|
|
|
258
260
|
BadgeStyle,
|
|
259
261
|
DateConfiguration,
|
|
260
262
|
ReceiptConfiguration,
|
|
263
|
+
ReceiptStyle,
|
|
261
264
|
StatusIndicatorConfiguration,
|
|
262
265
|
StatusIndicatorStyle,
|
|
263
266
|
DateStyle,
|
|
@@ -342,6 +345,7 @@ export type {
|
|
|
342
345
|
CometChatMessageInputInterface,
|
|
343
346
|
CometChatMessageInputStyleInterface,
|
|
344
347
|
CometChatReceiptInterface,
|
|
348
|
+
ReceiptStyleInterface,
|
|
345
349
|
CometChatStatusIndicatorInterface,
|
|
346
350
|
DateConfigurationInterface,
|
|
347
351
|
DateStyleInterface,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React, { Component } from 'react';
|
|
2
2
|
import PropTypes from 'prop-types';
|
|
3
|
-
import { StyleSheet, requireNativeComponent, NativeModules, View, Image, Platform, ViewProps, ImageResizeMode } from 'react-native';
|
|
3
|
+
import { StyleSheet, requireNativeComponent, NativeModules, View, Image, Platform, ViewProps, ImageResizeMode, UIManager } from 'react-native';
|
|
4
4
|
import resolveAssetSource from 'react-native/Libraries/Image/resolveAssetSource';
|
|
5
5
|
import TextTrackType from './TextTrackType';
|
|
6
6
|
import FilterType from './FilterType';
|
|
@@ -231,10 +231,10 @@ export default class Video extends Component {
|
|
|
231
231
|
};
|
|
232
232
|
|
|
233
233
|
getViewManagerConfig = viewManagerName => {
|
|
234
|
-
if (!
|
|
235
|
-
return
|
|
234
|
+
if (!UIManager.getViewManagerConfig) {
|
|
235
|
+
return UIManager[viewManagerName];
|
|
236
236
|
}
|
|
237
|
-
return
|
|
237
|
+
return UIManager.getViewManagerConfig(viewManagerName);
|
|
238
238
|
};
|
|
239
239
|
|
|
240
240
|
render() {
|
|
@@ -12,7 +12,7 @@ import translationZHTW from "./resources/zh-tw/translation.json";
|
|
|
12
12
|
import translationSV from "./resources/sv/translation.json";
|
|
13
13
|
import translationLT from "./resources/lt/translation.json";
|
|
14
14
|
import translationHU from "./resources/hu/translation.json";
|
|
15
|
-
import { Platform,
|
|
15
|
+
import { Platform, Settings, I18nManager } from 'react-native';
|
|
16
16
|
|
|
17
17
|
/**
|
|
18
18
|
* CometChatLocalize component allows you to show text in the locale set by you.
|
|
@@ -81,9 +81,8 @@ class CometChatLocalize {
|
|
|
81
81
|
*/
|
|
82
82
|
static getNativeLanguage = () => {
|
|
83
83
|
return Platform.OS === 'ios'
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
: NativeModules.I18nManager.localeIdentifier.replace("_", "-")
|
|
84
|
+
? Settings.get('AppleLocale') || Settings.get('AppleLanguages')[0] //iOS 13
|
|
85
|
+
: I18nManager.getConstants().localeIdentifier?.replace("_", "-")
|
|
87
86
|
};
|
|
88
87
|
|
|
89
88
|
/**
|