@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
|
@@ -43,7 +43,7 @@ import com.facebook.react.bridge.ActivityEventListener;
|
|
|
43
43
|
import com.facebook.react.bridge.Arguments;
|
|
44
44
|
import com.facebook.react.bridge.BaseActivityEventListener;
|
|
45
45
|
import com.facebook.react.bridge.Callback;
|
|
46
|
-
import com.facebook.react.bridge.
|
|
46
|
+
import com.facebook.react.bridge.GuardedAsyncTask;
|
|
47
47
|
import com.facebook.react.bridge.ReactApplicationContext;
|
|
48
48
|
import com.facebook.react.bridge.ReactContext;
|
|
49
49
|
import com.facebook.react.bridge.ReactContextBaseJavaModule;
|
package/ios/CometchatUiKit.mm
CHANGED
|
@@ -1,9 +1,5 @@
|
|
|
1
1
|
#import "CometchatUiKit.h"
|
|
2
2
|
|
|
3
|
-
#ifdef RCT_NEW_ARCH_ENABLED
|
|
4
|
-
#import "RNCometchatUiKitSpec.h"
|
|
5
|
-
#endif
|
|
6
|
-
|
|
7
3
|
@implementation CometchatUiKit
|
|
8
4
|
RCT_EXPORT_MODULE()
|
|
9
5
|
|
|
@@ -19,13 +15,4 @@ RCT_REMAP_METHOD(multiply,
|
|
|
19
15
|
resolve(result);
|
|
20
16
|
}
|
|
21
17
|
|
|
22
|
-
// Don't compile this code when we build for the old architecture.
|
|
23
|
-
#ifdef RCT_NEW_ARCH_ENABLED
|
|
24
|
-
- (std::shared_ptr<facebook::react::TurboModule>)getTurboModule:
|
|
25
|
-
(const facebook::react::ObjCTurboModule::InitParams &)params
|
|
26
|
-
{
|
|
27
|
-
return std::make_shared<facebook::react::NativeCometchatUiKitSpecJSI>(params);
|
|
28
|
-
}
|
|
29
|
-
#endif
|
|
30
|
-
|
|
31
18
|
@end
|
package/ios/FileManager.m
CHANGED
|
@@ -226,6 +226,13 @@ RCT_EXPORT_METHOD(openFileChooser:(NSString *) type callback:(RCTResponseSenderB
|
|
|
226
226
|
imageController.sourceType = UIImagePickerControllerSourceTypeSavedPhotosAlbum;
|
|
227
227
|
[presentedViewController presentViewController:imageController animated:YES completion:nil];
|
|
228
228
|
});
|
|
229
|
+
} else if ([@"audio" isEqualToString:type]) {
|
|
230
|
+
dispatch_async(dispatch_get_main_queue(), ^{
|
|
231
|
+
UIDocumentPickerViewController *documentController = [[UIDocumentPickerViewController alloc] initWithDocumentTypes: @[@"public.audio"] inMode: UIDocumentPickerModeImport];
|
|
232
|
+
documentController.delegate = self;
|
|
233
|
+
documentController.title = @"Select an audio file";
|
|
234
|
+
[presentedViewController presentViewController:documentController animated:YES completion:nil];
|
|
235
|
+
});
|
|
229
236
|
} else {
|
|
230
237
|
dispatch_async(dispatch_get_main_queue(), ^{
|
|
231
238
|
UIDocumentPickerViewController *documentController = [[UIDocumentPickerViewController alloc] initWithDocumentTypes: @[@"public.data",@"public.content",@"public.audiovisual-content",@"public.movie",@"public.audiovisual-content",@"public.video",@"public.audio",@"public.data",@"public.zip-archive",@"com.pkware.zip-archive",@"public.composite-content",@"public.text"] inMode: UIDocumentPickerModeImport];
|
package/package.json
CHANGED
|
@@ -31,20 +31,4 @@ Pod::Spec.new do |s|
|
|
|
31
31
|
|
|
32
32
|
ss.source_files = "ios/VideoCaching/**/*.{h,m}"
|
|
33
33
|
end
|
|
34
|
-
|
|
35
|
-
# Conditional compiler flags and dependencies for the new architecture
|
|
36
|
-
if ENV['RCT_NEW_ARCH_ENABLED'] == '1'
|
|
37
|
-
s.compiler_flags = "#{folly_compiler_flags} -DRCT_NEW_ARCH_ENABLED=1"
|
|
38
|
-
s.pod_target_xcconfig = {
|
|
39
|
-
"HEADER_SEARCH_PATHS" => "\"$(PODS_ROOT)/Header/Public/**\"",
|
|
40
|
-
"CLANG_CXX_LANGUAGE_STANDARD" => "c++17"
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
s.dependency "React-Codegen"
|
|
44
|
-
s.dependency "RCT-Folly"
|
|
45
|
-
s.dependency "RCTRequired"
|
|
46
|
-
s.dependency "RCTTypeSafety"
|
|
47
|
-
s.dependency "ReactCommon/turbomodule/core"
|
|
48
|
-
s.dependency "RCTSlider"
|
|
49
|
-
end
|
|
50
34
|
end
|
|
@@ -40,6 +40,7 @@ import { DateStyleInterface } from "../shared/views/CometChatDate/DateStyle";
|
|
|
40
40
|
import { BadgeStyleInterface } from "../shared/views/CometChatBadge";
|
|
41
41
|
import { InteractiveMessageUtils } from "../shared/utils/InteractiveMessageUtils";
|
|
42
42
|
import { CommonUtils } from "../shared/utils/CommonUtils";
|
|
43
|
+
import { ReceiptStyle, ReceiptStyleInterface } from "../shared/views/CometChatReceipt";
|
|
43
44
|
|
|
44
45
|
const conversationListenerId = "chatlist_" + new Date().getTime();
|
|
45
46
|
const userListenerId = "chatlist_user_" + new Date().getTime();
|
|
@@ -215,7 +216,7 @@ export interface ConversationInterface {
|
|
|
215
216
|
/**
|
|
216
217
|
* style object for receipt
|
|
217
218
|
*/
|
|
218
|
-
receiptStyle?:
|
|
219
|
+
receiptStyle?: ReceiptStyleInterface,
|
|
219
220
|
/**
|
|
220
221
|
* style object for badge
|
|
221
222
|
*/
|
|
@@ -332,7 +333,7 @@ export const CometChatConversations = (props: ConversationInterface) => {
|
|
|
332
333
|
textFont: theme?.typography?.caption2,
|
|
333
334
|
...props?.badgeStyle
|
|
334
335
|
});
|
|
335
|
-
|
|
336
|
+
const _receiptStyle = new ReceiptStyle(props?.receiptStyle || {});
|
|
336
337
|
const _dateStyle = new DateStyle({
|
|
337
338
|
textColor: theme?.palette?.getAccent600(),
|
|
338
339
|
textFont: theme?.typography?.caption1,
|
|
@@ -365,15 +366,15 @@ export const CometChatConversations = (props: ConversationInterface) => {
|
|
|
365
366
|
}
|
|
366
367
|
|
|
367
368
|
const userEventHandler = (...args: any[]) => {
|
|
368
|
-
const { uid
|
|
369
|
-
if (!blockedByMe) {
|
|
369
|
+
const { uid } = args[0];
|
|
370
370
|
let item: CometChat.Conversation | any = conversationListRef.current?.getListItem(`${uid}_user_${loggedInUser.current?.uid}`) as unknown as CometChat.Conversation || conversationListRef.current?.getListItem(`${loggedInUser.current?.uid}_user_${uid}`) as unknown as CometChat.Conversation;
|
|
371
|
+
const user: CometChat.User = item.getConversationWith();
|
|
372
|
+
if((user.getBlockedByMe() || user.getHasBlockedMe())) return;
|
|
371
373
|
if (item) {
|
|
372
374
|
let updatedConversation = CommonUtils.clone(item);
|
|
373
375
|
updatedConversation.setConversationWith(args[0]);
|
|
374
376
|
conversationListRef.current?.updateList(updatedConversation);
|
|
375
377
|
}
|
|
376
|
-
}
|
|
377
378
|
}
|
|
378
379
|
|
|
379
380
|
|
|
@@ -383,7 +384,7 @@ export const CometChatConversations = (props: ConversationInterface) => {
|
|
|
383
384
|
return (
|
|
384
385
|
(typingIndicator.getReceiverType() == ReceiverTypeConstants.user &&
|
|
385
386
|
item.getConversationType() == ReceiverTypeConstants.user
|
|
386
|
-
&& (item.getConversationWith() as CometChat.User).getUid() == typingIndicator.getSender().getUid())
|
|
387
|
+
&& (item.getConversationWith() as CometChat.User).getUid() == typingIndicator.getSender().getUid() && !((item.getConversationWith() as CometChat.User)?.getBlockedByMe() || (item.getConversationWith() as CometChat.User)?.getHasBlockedMe()))
|
|
387
388
|
|| (typingIndicator.getReceiverType() == ReceiverTypeConstants.group && item.getConversationType() == ReceiverTypeConstants.group
|
|
388
389
|
&& (item.getConversationWith() as CometChat.Group).getGuid() == typingIndicator.getReceiverId())
|
|
389
390
|
)
|
|
@@ -741,7 +742,7 @@ export const CometChatConversations = (props: ConversationInterface) => {
|
|
|
741
742
|
<Text numberOfLines={1} ellipsizeMode={"tail"} style={[Style.subtitleTextStyle, {
|
|
742
743
|
color: theme.palette.getAccent600(), fontSize: theme.typography.subtitle1.fontSize,
|
|
743
744
|
fontWeight: theme.typography.subtitle1.fontWeight
|
|
744
|
-
}] as TextStyle}>
|
|
745
|
+
}] as TextStyle[]}>
|
|
745
746
|
{groupText}{messageText}
|
|
746
747
|
</Text>
|
|
747
748
|
)
|
|
@@ -796,7 +797,7 @@ export const CometChatConversations = (props: ConversationInterface) => {
|
|
|
796
797
|
<Text numberOfLines={1} ellipsizeMode={"tail"} style={[Style.subtitleTextStyle, {
|
|
797
798
|
color: theme.palette.getPrimary(),
|
|
798
799
|
fontSize: theme.typography.subtitle1.fontSize, fontWeight: theme.typography.subtitle1.fontWeight
|
|
799
|
-
}] as TextStyle} >{params.typingText}</Text>
|
|
800
|
+
}] as TextStyle[]} >{params.typingText}</Text>
|
|
800
801
|
</View>
|
|
801
802
|
}
|
|
802
803
|
|
|
@@ -815,6 +816,7 @@ export const CometChatConversations = (props: ConversationInterface) => {
|
|
|
815
816
|
readIcon={props.readIcon}
|
|
816
817
|
sentIcon={props.sentIcon}
|
|
817
818
|
waitIcon={props.waitingIcon}
|
|
819
|
+
style={_receiptStyle}
|
|
818
820
|
/>;
|
|
819
821
|
}
|
|
820
822
|
|
|
@@ -1214,12 +1216,29 @@ export const CometChatConversations = (props: ConversationInterface) => {
|
|
|
1214
1216
|
CometChatUIEventHandler.addUserListener(
|
|
1215
1217
|
userListenerId,
|
|
1216
1218
|
{
|
|
1217
|
-
ccUserBlocked: ({ user }:
|
|
1219
|
+
ccUserBlocked: ({ user }: {user: CometChat.User}) => {
|
|
1220
|
+
const uid = user.getUid();
|
|
1221
|
+
let item: CometChat.Conversation | any = conversationListRef.current?.getListItem(`${uid}_user_${loggedInUser.current?.uid}`) as unknown as CometChat.Conversation || conversationListRef.current?.getListItem(`${loggedInUser.current?.uid}_user_${uid}`) as unknown as CometChat.Conversation;
|
|
1218
1222
|
if(conversationsRequestBuilder && conversationsRequestBuilder.build().isIncludeBlockedUsers()) {
|
|
1223
|
+
if(item) {
|
|
1224
|
+
let updatedConversation = CommonUtils.clone(item);
|
|
1225
|
+
updatedConversation.setConversationWith(user);
|
|
1226
|
+
conversationListRef.current?.updateList(updatedConversation);
|
|
1227
|
+
}
|
|
1219
1228
|
return;
|
|
1220
1229
|
}
|
|
1221
1230
|
conversationListRef?.current?.removeItemFromList(user['conversationId']);
|
|
1222
1231
|
removeItemFromSelectionList(user['conversationId']);
|
|
1232
|
+
},
|
|
1233
|
+
ccUserUnBlocked: ({ user }: {user: CometChat.User}) => {
|
|
1234
|
+
/**unblocked handling is required to enable user presence listener for the user**/
|
|
1235
|
+
const uid = user.getUid();
|
|
1236
|
+
let item: CometChat.Conversation | any = conversationListRef.current?.getListItem(`${uid}_user_${loggedInUser.current?.uid}`) as unknown as CometChat.Conversation || conversationListRef.current?.getListItem(`${loggedInUser.current?.uid}_user_${uid}`) as unknown as CometChat.Conversation;
|
|
1237
|
+
if(item) {
|
|
1238
|
+
let updatedConversation = CommonUtils.clone(item);
|
|
1239
|
+
updatedConversation.setConversationWith(user);
|
|
1240
|
+
conversationListRef.current?.updateList(updatedConversation);
|
|
1241
|
+
}
|
|
1223
1242
|
}
|
|
1224
1243
|
}
|
|
1225
1244
|
)
|
|
@@ -1293,14 +1312,21 @@ export const CometChatConversations = (props: ConversationInterface) => {
|
|
|
1293
1312
|
}
|
|
1294
1313
|
}, []);
|
|
1295
1314
|
|
|
1296
|
-
const ConversationItemView = ({ item: conversation }:
|
|
1315
|
+
const ConversationItemView = ({ item: conversation }: {item: CometChat.Conversation}) => {
|
|
1297
1316
|
if (!conversation) return null;
|
|
1298
1317
|
//custom view check
|
|
1299
1318
|
if (ListItemView)
|
|
1300
1319
|
return ListItemView(conversation);
|
|
1301
|
-
const
|
|
1320
|
+
const conversationWith = conversation.getConversationWith();
|
|
1321
|
+
const conversationType = conversation.getConversationType();
|
|
1302
1322
|
const lastMessage = CometChatConversationUtils.getLastMessage(conversation);
|
|
1303
|
-
const
|
|
1323
|
+
const name = conversationWith.getName();
|
|
1324
|
+
const conversationId = conversation.getConversationId();
|
|
1325
|
+
let type: string;
|
|
1326
|
+
if(conversationWith instanceof CometChat.Group) {
|
|
1327
|
+
type = conversationWith.getType();
|
|
1328
|
+
}
|
|
1329
|
+
|
|
1304
1330
|
let image!: ImageType, backgroundColor!: string, avatarIcon = conversationWith[conversationType == "group" ? 'icon' : "avatar"];
|
|
1305
1331
|
if (type == GroupTypeConstants.password) {
|
|
1306
1332
|
image = props?.protectedGroupIcon || passwordGroupIcon;
|
|
@@ -1310,7 +1336,7 @@ export const CometChatConversations = (props: ConversationInterface) => {
|
|
|
1310
1336
|
image = props?.privateGroupIcon || privateGroupIcon;
|
|
1311
1337
|
backgroundColor = PRIVATE_GROUP_COLOR;
|
|
1312
1338
|
}
|
|
1313
|
-
if (conversationWith.
|
|
1339
|
+
if (conversationWith instanceof CometChat.User && conversationWith.getStatus() == CometChatUiKitConstants.UserStatusConstants.online && !(conversationWith?.getBlockedByMe() || conversationWith?.getHasBlockedMe())) {
|
|
1314
1340
|
backgroundColor = theme.palette.getSuccess();
|
|
1315
1341
|
}
|
|
1316
1342
|
if (selecting) {
|
|
@@ -1322,7 +1348,7 @@ export const CometChatConversations = (props: ConversationInterface) => {
|
|
|
1322
1348
|
}
|
|
1323
1349
|
|
|
1324
1350
|
return <CometChatListItem
|
|
1325
|
-
id={conversation.
|
|
1351
|
+
id={conversation.getConversationId()}
|
|
1326
1352
|
avatarName={name}
|
|
1327
1353
|
avatarURL={avatarIcon}
|
|
1328
1354
|
hideSeparator={hideSeparator}
|
|
@@ -1335,7 +1361,7 @@ export const CometChatConversations = (props: ConversationInterface) => {
|
|
|
1335
1361
|
TailView={() => <TailView
|
|
1336
1362
|
customPattern={() => datePattern && datePattern(conversation)}
|
|
1337
1363
|
timestamp={lastMessage && lastMessage['sentAt'] || conversationWith['createdAt']}
|
|
1338
|
-
unreadCount={conversation.
|
|
1364
|
+
unreadCount={conversation.getUnreadMessageCount()}
|
|
1339
1365
|
/>}
|
|
1340
1366
|
avatarStyle={_avatarStyle}
|
|
1341
1367
|
statusIndicatorStyle={_statusIndicatorStyle as ViewProps}
|
|
@@ -1376,9 +1402,9 @@ export const CometChatConversations = (props: ConversationInterface) => {
|
|
|
1376
1402
|
onBack={onBack}
|
|
1377
1403
|
backButtonIcon={backButtonIcon}
|
|
1378
1404
|
showBackButton={showBackButton}
|
|
1379
|
-
onSelection={(
|
|
1380
|
-
if(!
|
|
1381
|
-
onSelection && onSelection(
|
|
1405
|
+
onSelection={() => {
|
|
1406
|
+
if(!selectedConversation.length) return
|
|
1407
|
+
onSelection && onSelection(selectedConversation);
|
|
1382
1408
|
setSelecting(false);
|
|
1383
1409
|
setSelectedConversations([]);
|
|
1384
1410
|
}}
|
|
@@ -94,12 +94,9 @@ export const CometChatConversationsWithMessages = (props: CometChatConversations
|
|
|
94
94
|
}
|
|
95
95
|
|
|
96
96
|
useEffect(() => {
|
|
97
|
-
BackHandler.addEventListener('hardwareBackPress', handleBack);
|
|
97
|
+
const backHandlerListener = BackHandler.addEventListener('hardwareBackPress', handleBack);
|
|
98
98
|
return () => {
|
|
99
|
-
|
|
100
|
-
'hardwareBackPress',
|
|
101
|
-
handleBack
|
|
102
|
-
);
|
|
99
|
+
backHandlerListener.remove();
|
|
103
100
|
};
|
|
104
101
|
}, [showComponent]);
|
|
105
102
|
|
|
@@ -9,7 +9,7 @@ import {
|
|
|
9
9
|
ViewStyle,
|
|
10
10
|
ViewProps,
|
|
11
11
|
} from 'react-native';
|
|
12
|
-
import React, { useContext, useEffect, useState } from 'react';
|
|
12
|
+
import React, { useContext, useEffect, useState, useCallback } from 'react';
|
|
13
13
|
import Header from './Header';
|
|
14
14
|
import { CometChatContext, CometChatListItem } from '../shared';
|
|
15
15
|
import { ICONS } from './resources';
|
|
@@ -370,8 +370,8 @@ export const CometChatDetails = (props: CometChatDetailsInterface) => {
|
|
|
370
370
|
const ccGroupMemberAddedId = 'ccGroupMemberAdded_' + new Date().getTime();
|
|
371
371
|
const ccOwnershipChangedId = 'ccOwnershipChanged_' + new Date().getTime();
|
|
372
372
|
|
|
373
|
-
const [userDetails, setUserDetails] = useState<
|
|
374
|
-
const [groupDetails, setGroupDetails] = useState<
|
|
373
|
+
const [userDetails, setUserDetails] = useState<CometChat.User>(user);
|
|
374
|
+
const [groupDetails, setGroupDetails] = useState<CometChat.Group>(group);
|
|
375
375
|
|
|
376
376
|
const [modalVisible, setModalVisible] = useState(false);
|
|
377
377
|
const [detailsList, setDetailsList] = useState<any[]>(
|
|
@@ -488,25 +488,35 @@ export const CometChatDetails = (props: CometChatDetailsInterface) => {
|
|
|
488
488
|
});
|
|
489
489
|
};
|
|
490
490
|
|
|
491
|
-
const updateUserBlockStatus = (
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
491
|
+
const updateUserBlockStatus = useCallback(
|
|
492
|
+
(list: any, blocked: boolean) => {
|
|
493
|
+
let updatedUser = userDetails;
|
|
494
|
+
if (list[userDetails.getUid()]['success'] == true) {
|
|
495
|
+
updatedUser.setBlockedByMe(blocked);
|
|
496
|
+
if (blocked) {
|
|
497
|
+
updatedUser.setStatus('');
|
|
498
|
+
}
|
|
499
|
+
}
|
|
500
|
+
getDefaultTemplate(loggedInUser, updatedUser);
|
|
501
|
+
},
|
|
502
|
+
[userDetails]
|
|
503
|
+
);
|
|
499
504
|
|
|
500
505
|
const handleUserBlockUnblock = (blocked = false) => {
|
|
501
506
|
var usersList: String[] = [userDetails.getUid()];
|
|
502
507
|
if (blocked) {
|
|
503
508
|
CometChat.unblockUsers(usersList).then(
|
|
504
509
|
(list: Object) => {
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
+
CometChat.getUser(userDetails.getUid()).then(
|
|
511
|
+
(fetchedUser: CometChat.User) => {
|
|
512
|
+
setUserDetails(fetchedUser);
|
|
513
|
+
updateUserBlockStatus(list, false);
|
|
514
|
+
CometChatUIEventHandler.emitUserEvent(
|
|
515
|
+
CometChatUIEvents.ccUserUnBlocked,
|
|
516
|
+
{
|
|
517
|
+
user: fetchedUser,
|
|
518
|
+
}
|
|
519
|
+
);
|
|
510
520
|
}
|
|
511
521
|
);
|
|
512
522
|
},
|
|
@@ -519,9 +529,12 @@ export const CometChatDetails = (props: CometChatDetailsInterface) => {
|
|
|
519
529
|
CometChat.blockUsers(usersList).then(
|
|
520
530
|
(list: Object) => {
|
|
521
531
|
updateUserBlockStatus(list, true);
|
|
522
|
-
CometChatUIEventHandler.emitUserEvent(
|
|
523
|
-
|
|
524
|
-
|
|
532
|
+
CometChatUIEventHandler.emitUserEvent(
|
|
533
|
+
CometChatUIEvents.ccUserBlocked,
|
|
534
|
+
{
|
|
535
|
+
user: userDetails,
|
|
536
|
+
}
|
|
537
|
+
);
|
|
525
538
|
},
|
|
526
539
|
(error: CometChat.CometChatException) => {
|
|
527
540
|
onError && onError(error);
|
|
@@ -547,7 +560,7 @@ export const CometChatDetails = (props: CometChatDetailsInterface) => {
|
|
|
547
560
|
case UserStatusConstants.unblocked:
|
|
548
561
|
return () => handleUserBlockUnblock();
|
|
549
562
|
default:
|
|
550
|
-
return () => {
|
|
563
|
+
return () => {};
|
|
551
564
|
}
|
|
552
565
|
};
|
|
553
566
|
|
|
@@ -677,15 +690,29 @@ export const CometChatDetails = (props: CometChatDetailsInterface) => {
|
|
|
677
690
|
);
|
|
678
691
|
};
|
|
679
692
|
|
|
680
|
-
const SubtitleViewElem = () => {
|
|
693
|
+
const SubtitleViewElem = useCallback(() => {
|
|
694
|
+
const blocked =
|
|
695
|
+
userDetails ? (userDetails.getBlockedByMe() || userDetails.getHasBlockedMe()) : false;
|
|
696
|
+
|
|
697
|
+
const subtitleText =
|
|
698
|
+
groupDetails && groupDetails.getMembersCount() !== undefined
|
|
699
|
+
? groupDetails.getMembersCount() === 1
|
|
700
|
+
? `1 ${localize('MEMBER')}`
|
|
701
|
+
: `${groupDetails.getMembersCount()} ${localize('MEMBERS')}`
|
|
702
|
+
: blocked
|
|
703
|
+
? ''
|
|
704
|
+
: userDetails.getStatus() === UserStatusConstants.online
|
|
705
|
+
? localize('ONLINE')
|
|
706
|
+
: userDetails.getStatus() === UserStatusConstants.offline
|
|
707
|
+
? localize('OFFLINE')
|
|
708
|
+
: '';
|
|
709
|
+
if (!subtitleText) return null;
|
|
681
710
|
return (
|
|
682
711
|
<Text style={{ color: theme.palette.getAccent600() }}>
|
|
683
|
-
{
|
|
684
|
-
? localize('ONLINE')
|
|
685
|
-
: localize('OFFLINE')}
|
|
712
|
+
{subtitleText}
|
|
686
713
|
</Text>
|
|
687
714
|
);
|
|
688
|
-
};
|
|
715
|
+
}, [userDetails]);
|
|
689
716
|
|
|
690
717
|
const handleBackButtonClick = () => {
|
|
691
718
|
setCurrentScreen(null);
|
|
@@ -695,20 +722,22 @@ export const CometChatDetails = (props: CometChatDetailsInterface) => {
|
|
|
695
722
|
|
|
696
723
|
useEffect(() => {
|
|
697
724
|
if (currentScreen) {
|
|
698
|
-
BackHandler.addEventListener('hardwareBackPress', handleBackButtonClick);
|
|
725
|
+
const backHandlerListener = BackHandler.addEventListener('hardwareBackPress', handleBackButtonClick);
|
|
699
726
|
return () => {
|
|
700
|
-
|
|
701
|
-
'hardwareBackPress',
|
|
702
|
-
handleBackButtonClick
|
|
703
|
-
);
|
|
727
|
+
backHandlerListener.remove();
|
|
704
728
|
};
|
|
705
729
|
}
|
|
706
|
-
return () => {
|
|
730
|
+
return () => {};
|
|
707
731
|
}, [currentScreen]);
|
|
708
732
|
|
|
709
733
|
const getDefaultTemplate = (loggedUser: any, user?: any) => {
|
|
710
734
|
if (userDetails || groupDetails) {
|
|
711
|
-
const template = getDefaultDetailsTemplate(
|
|
735
|
+
const template = getDefaultDetailsTemplate(
|
|
736
|
+
loggedUser,
|
|
737
|
+
user ?? userDetails,
|
|
738
|
+
groupDetails,
|
|
739
|
+
theme
|
|
740
|
+
);
|
|
712
741
|
setDetailsList(template.filter((item) => item));
|
|
713
742
|
}
|
|
714
743
|
};
|
|
@@ -725,7 +754,7 @@ export const CometChatDetails = (props: CometChatDetailsInterface) => {
|
|
|
725
754
|
onError && onError(error);
|
|
726
755
|
}
|
|
727
756
|
);
|
|
728
|
-
}
|
|
757
|
+
};
|
|
729
758
|
|
|
730
759
|
useEffect(() => {
|
|
731
760
|
getTemplates();
|
|
@@ -733,6 +762,12 @@ export const CometChatDetails = (props: CometChatDetailsInterface) => {
|
|
|
733
762
|
|
|
734
763
|
const handleUserStatus = (user: any) => {
|
|
735
764
|
setUserDetails((prev: any) => {
|
|
765
|
+
if (
|
|
766
|
+
prev.getUid() !== user.getUid() ||
|
|
767
|
+
prev.getBlockedByMe() ||
|
|
768
|
+
prev.getHasBlockedMe()
|
|
769
|
+
)
|
|
770
|
+
return prev;
|
|
736
771
|
const clonedUserDetails = CommonUtils.clone(prev);
|
|
737
772
|
clonedUserDetails.setStatus(user.getStatus());
|
|
738
773
|
return clonedUserDetails;
|
|
@@ -744,13 +779,13 @@ export const CometChatDetails = (props: CometChatDetailsInterface) => {
|
|
|
744
779
|
};
|
|
745
780
|
|
|
746
781
|
useEffect(() => {
|
|
747
|
-
if(user) {
|
|
782
|
+
if (user) {
|
|
748
783
|
listners.addListener.userListener({
|
|
749
784
|
userStatusListenerId,
|
|
750
785
|
handleUserStatus,
|
|
751
786
|
});
|
|
752
|
-
}
|
|
753
|
-
if(group) {
|
|
787
|
+
}
|
|
788
|
+
if (group) {
|
|
754
789
|
listners.addListener.groupListener({
|
|
755
790
|
groupListenerId,
|
|
756
791
|
handleGroupListener,
|
|
@@ -784,7 +819,7 @@ export const CometChatDetails = (props: CometChatDetailsInterface) => {
|
|
|
784
819
|
usersAdded,
|
|
785
820
|
userAddedIn,
|
|
786
821
|
}: any) => {
|
|
787
|
-
setCurrentScreen(null)
|
|
822
|
+
setCurrentScreen(null);
|
|
788
823
|
handleGroupListener(userAddedIn);
|
|
789
824
|
};
|
|
790
825
|
const handleOwnershipChanged = ({ group, newOwner, message }: any) => {
|
|
@@ -811,7 +846,9 @@ export const CometChatDetails = (props: CometChatDetailsInterface) => {
|
|
|
811
846
|
group={groupDetails}
|
|
812
847
|
onBack={handleBackButtonClick}
|
|
813
848
|
selectionMode="none"
|
|
814
|
-
groupMemberStyle={{
|
|
849
|
+
groupMemberStyle={{
|
|
850
|
+
backIconTint: detailsStyle?.backIconTint ?? undefined,
|
|
851
|
+
}}
|
|
815
852
|
{...groupMembersConfiguration}
|
|
816
853
|
/>
|
|
817
854
|
);
|
|
@@ -831,7 +868,9 @@ export const CometChatDetails = (props: CometChatDetailsInterface) => {
|
|
|
831
868
|
<CometChatBannedMembers
|
|
832
869
|
group={groupDetails}
|
|
833
870
|
onBack={handleBackButtonClick}
|
|
834
|
-
bannedMemberStyle={{
|
|
871
|
+
bannedMemberStyle={{
|
|
872
|
+
backIconTint: detailsStyle?.backIconTint ?? undefined,
|
|
873
|
+
}}
|
|
835
874
|
{...bannedMembersConfiguration}
|
|
836
875
|
/>
|
|
837
876
|
);
|
|
@@ -846,17 +885,20 @@ export const CometChatDetails = (props: CometChatDetailsInterface) => {
|
|
|
846
885
|
);
|
|
847
886
|
return (
|
|
848
887
|
<View
|
|
849
|
-
style={
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
888
|
+
style={
|
|
889
|
+
[
|
|
890
|
+
styles.container,
|
|
891
|
+
{
|
|
892
|
+
width: detailsStyle?.width ?? '100%',
|
|
893
|
+
height: detailsStyle?.height ?? '100%',
|
|
894
|
+
backgroundColor:
|
|
895
|
+
detailsStyle?.backgroundColor ??
|
|
896
|
+
theme.palette.getBackgroundColor(),
|
|
897
|
+
borderRadius: detailsStyle?.borderRadius ?? 0,
|
|
898
|
+
} as StyleProp<ViewStyle>,
|
|
899
|
+
detailsStyle?.border ? detailsStyle?.border : {},
|
|
900
|
+
] as ViewProps
|
|
901
|
+
}
|
|
860
902
|
>
|
|
861
903
|
<Header
|
|
862
904
|
title={title}
|
|
@@ -891,8 +933,8 @@ export const CometChatDetails = (props: CometChatDetailsInterface) => {
|
|
|
891
933
|
{...(userDetails
|
|
892
934
|
? { user: userDetails }
|
|
893
935
|
: group
|
|
894
|
-
|
|
895
|
-
|
|
936
|
+
? { group: groupDetails }
|
|
937
|
+
: {})}
|
|
896
938
|
/>
|
|
897
939
|
) : (
|
|
898
940
|
<CometChatListItem
|
|
@@ -901,44 +943,47 @@ export const CometChatDetails = (props: CometChatDetailsInterface) => {
|
|
|
901
943
|
listItemStyle ? listItemStyle : { titleFont: { fontWeight: '600' } }
|
|
902
944
|
}
|
|
903
945
|
avatarName={userDetails?.getName() || groupDetails?.getName()}
|
|
904
|
-
avatarURL={{
|
|
946
|
+
avatarURL={{
|
|
947
|
+
uri: userDetails?.getAvatar() || groupDetails?.getIcon(),
|
|
948
|
+
}}
|
|
905
949
|
headViewContainerStyle={{
|
|
906
950
|
paddingRight: 15,
|
|
907
951
|
paddingLeft: 0,
|
|
908
952
|
}}
|
|
909
953
|
statusIndicatorStyle={
|
|
910
954
|
(groupDetails
|
|
911
|
-
? {
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
|
|
955
|
+
? ({
|
|
956
|
+
end: 10,
|
|
957
|
+
height: 15,
|
|
958
|
+
width: 15,
|
|
959
|
+
backgroundColor:
|
|
960
|
+
groupDetails.getType() === CometChat.GROUP_TYPE.PASSWORD
|
|
961
|
+
? protectedGroupIcon
|
|
962
|
+
? ''
|
|
963
|
+
: detailsStyle?.protectedGroupIconBackground ??
|
|
964
|
+
PASSWORD_GROUP_COLOR // Note need to add this to
|
|
965
|
+
: groupDetails.getType() === CometChat.GROUP_TYPE.PRIVATE
|
|
922
966
|
? privateGroupIcon
|
|
923
967
|
? ''
|
|
924
968
|
: detailsStyle?.privateGroupIconBackground ??
|
|
925
|
-
|
|
969
|
+
PRIVATE_GROUP_COLOR
|
|
926
970
|
: '',
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
971
|
+
borderRadius: 15,
|
|
972
|
+
...(statusIndicatorStyle ? statusIndicatorStyle : {}),
|
|
973
|
+
} as StyleProp<ViewStyle>)
|
|
930
974
|
: {
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
975
|
+
end: 10,
|
|
976
|
+
...(statusIndicatorStyle ? statusIndicatorStyle : {}),
|
|
977
|
+
}) as ViewProps
|
|
934
978
|
}
|
|
935
979
|
avatarStyle={
|
|
936
980
|
avatarStyle ? avatarStyle : { border: { borderWidth: 0 } }
|
|
937
981
|
}
|
|
938
982
|
statusIndicatorColor={
|
|
939
983
|
!disableUsersPresence &&
|
|
940
|
-
|
|
941
|
-
|
|
984
|
+
userDetails &&
|
|
985
|
+
userDetails.getStatus() === UserStatusConstants.online &&
|
|
986
|
+
!(userDetails.getBlockedByMe() || userDetails.getHasBlockedMe())
|
|
942
987
|
? detailsStyle?.onlineStatusColor ?? theme.palette.getSuccess()
|
|
943
988
|
: ''
|
|
944
989
|
}
|
|
@@ -949,27 +994,25 @@ export const CometChatDetails = (props: CometChatDetailsInterface) => {
|
|
|
949
994
|
? protectedGroupIcon
|
|
950
995
|
: ICONS.PROTECTED
|
|
951
996
|
: groupDetails.getType() === CometChat.GROUP_TYPE.PRIVATE
|
|
997
|
+
? privateGroupIcon
|
|
952
998
|
? privateGroupIcon
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
: null
|
|
999
|
+
: ICONS.PRIVATE
|
|
1000
|
+
: null
|
|
956
1001
|
: null
|
|
957
1002
|
}
|
|
958
1003
|
title={userDetails?.getName() || groupDetails?.getName()}
|
|
959
1004
|
SubtitleView={
|
|
960
1005
|
SubtitleView
|
|
961
1006
|
? () => (
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
|
|
965
|
-
|
|
1007
|
+
<SubtitleView
|
|
1008
|
+
{...(userDetails
|
|
1009
|
+
? { user: userDetails }
|
|
1010
|
+
: group
|
|
966
1011
|
? { group: groupDetails }
|
|
967
1012
|
: {})}
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
:
|
|
971
|
-
? SubtitleViewElem
|
|
972
|
-
: null
|
|
1013
|
+
/>
|
|
1014
|
+
)
|
|
1015
|
+
: SubtitleViewElem
|
|
973
1016
|
}
|
|
974
1017
|
/>
|
|
975
1018
|
)}
|
|
@@ -112,12 +112,9 @@ export const CometChatGroupsWithMessages = (props: CometChatGroupsWithMessagesIn
|
|
|
112
112
|
}
|
|
113
113
|
|
|
114
114
|
useEffect(() => {
|
|
115
|
-
BackHandler.addEventListener('hardwareBackPress', handleBack);
|
|
115
|
+
const backHandlerListener = BackHandler.addEventListener('hardwareBackPress', handleBack);
|
|
116
116
|
return () => {
|
|
117
|
-
|
|
118
|
-
'hardwareBackPress',
|
|
119
|
-
handleBack
|
|
120
|
-
);
|
|
117
|
+
backHandlerListener.remove();
|
|
121
118
|
};
|
|
122
119
|
}, [showComponent]);
|
|
123
120
|
|