@cometchat/chat-uikit-react-native 4.3.12 → 4.3.13
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/CometChatDetails/CometChatDetails.tsx +4 -2
- package/src/CometChatGroupMembers/CometChatGroupMembers.tsx +26 -11
- package/src/CometChatMessageComposer/CometChatMessageComposer.tsx +9 -1
- package/src/CometChatMessageHeader/CometChatMessageHeader.tsx +1 -1
- package/src/CometChatMessageInformation/CometChatMessageInformation.tsx +9 -6
- package/src/CometChatMessageList/CometChatMessageList.tsx +3 -0
- package/src/CometChatMessageList/MessageListConfiguration.ts +2 -0
- package/src/shared/constants/UIKitConstants.ts +12 -1
- package/src/shared/formatters/CometChatMentionsFormatter/CometChatMentionsFormatter.tsx +46 -1
- package/src/shared/views/CometChatList/CometChatList.tsx +0 -2
package/package.json
CHANGED
|
@@ -39,6 +39,7 @@ import { CometChatGroupsMembers } from '../CometChatGroupMembers';
|
|
|
39
39
|
import { CometChatContextType } from '../shared/base/Types';
|
|
40
40
|
import { CometChatUIEventHandler } from '../shared/events/CometChatUIEventHandler/CometChatUIEventHandler';
|
|
41
41
|
import { CometChatTransferOwnershipInterface } from '../CometChatTransferOwnership/CometChatTransferOwnership';
|
|
42
|
+
import { CommonUtils } from '../shared/utils/CommonUtils';
|
|
42
43
|
|
|
43
44
|
export interface ModalDetailsInterface {
|
|
44
45
|
title: string;
|
|
@@ -737,8 +738,9 @@ export const CometChatDetails = (props: CometChatDetailsInterface) => {
|
|
|
737
738
|
|
|
738
739
|
const handleUserStatus = (user) => {
|
|
739
740
|
setUserDetails((prev) => {
|
|
740
|
-
|
|
741
|
-
|
|
741
|
+
const clonedUserDetails = CommonUtils.clone(prev);
|
|
742
|
+
clonedUserDetails.setStatus(user.getStatus());
|
|
743
|
+
return clonedUserDetails;
|
|
742
744
|
});
|
|
743
745
|
};
|
|
744
746
|
|
|
@@ -19,6 +19,7 @@ import { getUnixTimestamp, getUnixTimestampInMilliseconds } from "../shared/util
|
|
|
19
19
|
import { CometChatContextType } from "../shared/base/Types";
|
|
20
20
|
import { CometChatUIEventHandler } from "../shared/events/CometChatUIEventHandler/CometChatUIEventHandler";
|
|
21
21
|
import { StatusIndicatorStyleInterface } from "../shared/views/CometChatStatusIndicator/StatusIndicatorStyle";
|
|
22
|
+
import { CommonUtils } from "../shared/utils/CommonUtils";
|
|
22
23
|
|
|
23
24
|
// Note: Omit all the unwanted props
|
|
24
25
|
export interface CometChatGroupsMembersInterface extends
|
|
@@ -333,19 +334,19 @@ export const CometChatGroupsMembers = (props: CometChatGroupsMembersInterface) =
|
|
|
333
334
|
|
|
334
335
|
function getStatusIndicatorColor(
|
|
335
336
|
groupMember: CometChat.GroupMember
|
|
336
|
-
|
|
337
|
+
): string | null {
|
|
337
338
|
if (
|
|
338
|
-
|
|
339
|
-
|
|
339
|
+
props.disableUsersPresence ||
|
|
340
|
+
(groupMember?.getStatus && groupMember.getStatus()) === CometChatUiKitConstants.UserStatusConstants.offline
|
|
340
341
|
) {
|
|
341
|
-
|
|
342
|
+
return null;
|
|
342
343
|
}
|
|
343
344
|
return (
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
345
|
+
groupMemberStyle?.onlineStatusColor ||
|
|
346
|
+
theme.palette.getSuccess() ||
|
|
347
|
+
null
|
|
347
348
|
);
|
|
348
|
-
|
|
349
|
+
}
|
|
349
350
|
|
|
350
351
|
const ItemView = ({ item: member, ...props }) => {
|
|
351
352
|
if (ListItemView)
|
|
@@ -373,6 +374,8 @@ export const CometChatGroupsMembers = (props: CometChatGroupsMembersInterface) =
|
|
|
373
374
|
avatarURL={member.avatar}
|
|
374
375
|
listItemStyle={_listItemStyle}
|
|
375
376
|
avatarStyle={_avatarStyle}
|
|
377
|
+
hideSeparator={hideSeparator}
|
|
378
|
+
separatorColor={_groupMemberStyle?.separatorColor}
|
|
376
379
|
statusIndicatorStyle={_statusIndicatorStyle}
|
|
377
380
|
TailView={TailView ? () => <TailView {...member} /> : ScopeChangeUI.bind(this, member, groupScopeStyle)} //Note: should return prop to TailView
|
|
378
381
|
options={() => (options && options(member)) || swipeOptions(member, (id) => kickUser(id, member), () => banUser(member))} //Note: should have options
|
|
@@ -395,7 +398,7 @@ export const CometChatGroupsMembers = (props: CometChatGroupsMembersInterface) =
|
|
|
395
398
|
const {
|
|
396
399
|
height = "100%",
|
|
397
400
|
width = "100%",
|
|
398
|
-
backgroundColor =
|
|
401
|
+
backgroundColor = _groupScopeStyle.backgroundColor,
|
|
399
402
|
border = new BorderStyle({}),
|
|
400
403
|
borderRadius = 4,
|
|
401
404
|
titleTextFont = new FontStyle({ fontSize: 14 }),
|
|
@@ -572,12 +575,24 @@ export const CometChatGroupsMembers = (props: CometChatGroupsMembersInterface) =
|
|
|
572
575
|
groupMemberListenerId,
|
|
573
576
|
new CometChat.UserListener({
|
|
574
577
|
onUserOnline: (onlineUser: any) => {
|
|
578
|
+
|
|
579
|
+
let item = groupRef.current.getListItem(onlineUser.uid);
|
|
580
|
+
if (item) {
|
|
581
|
+
let updatedConversation = CommonUtils.clone(item);
|
|
582
|
+
updatedConversation.setStatus(onlineUser.status);
|
|
583
|
+
groupRef.current.updateList(updatedConversation);
|
|
584
|
+
}
|
|
585
|
+
|
|
575
586
|
/* when someuser/friend comes online, user will be received here */
|
|
576
|
-
groupRef.current.updateUser(onlineUser);
|
|
577
587
|
},
|
|
578
588
|
onUserOffline: (offlineUser: any) => {
|
|
589
|
+
let item = groupRef.current.getListItem(offlineUser.uid);
|
|
590
|
+
if (item) {
|
|
591
|
+
let updatedConversation = CommonUtils.clone(item);
|
|
592
|
+
updatedConversation.setStatus(offlineUser.status);
|
|
593
|
+
groupRef.current.updateList(updatedConversation);
|
|
594
|
+
}
|
|
579
595
|
/* when someuser/friend went offline, user will be received here */
|
|
580
|
-
groupRef.current.updateUser(offlineUser);
|
|
581
596
|
},
|
|
582
597
|
})
|
|
583
598
|
);
|
|
@@ -42,6 +42,7 @@ import {
|
|
|
42
42
|
import { CometChatSoundManager, ChatConfigurator } from '../shared';
|
|
43
43
|
import {
|
|
44
44
|
ConversationOptionConstants,
|
|
45
|
+
MentionsVisibility,
|
|
45
46
|
MessageTypeConstants,
|
|
46
47
|
MetadataConstants,
|
|
47
48
|
ReceiverTypeConstants,
|
|
@@ -1496,7 +1497,14 @@ export const CometChatMessageComposer = React.forwardRef(
|
|
|
1496
1497
|
setShowMentionList(true);
|
|
1497
1498
|
|
|
1498
1499
|
let formatter = allFormatters.current.get(tracker);
|
|
1499
|
-
formatter
|
|
1500
|
+
if (formatter instanceof CometChatMentionsFormatter) {
|
|
1501
|
+
let shouldShowMentionList = (formatter.getVisibleIn() === MentionsVisibility.both) || (formatter.getVisibleIn() === MentionsVisibility.usersConversationOnly && user) || (formatter.getVisibleIn() === MentionsVisibility.groupsConversationOnly && group);
|
|
1502
|
+
if (shouldShowMentionList) {
|
|
1503
|
+
formatter.search(searchString);
|
|
1504
|
+
}
|
|
1505
|
+
} else {
|
|
1506
|
+
formatter.search(searchString);
|
|
1507
|
+
}
|
|
1500
1508
|
|
|
1501
1509
|
} else {
|
|
1502
1510
|
activeCharacter.current = "";
|
|
@@ -437,7 +437,7 @@ export const CometChatMessageHeader = (
|
|
|
437
437
|
statusIndicatorColor={
|
|
438
438
|
disableUsersPresence
|
|
439
439
|
? 'transparent'
|
|
440
|
-
: user &&
|
|
440
|
+
: user && userStatus === UserStatusConstants.online
|
|
441
441
|
? style.onlineStatusColor || theme.palette.getSuccess()
|
|
442
442
|
: 'transparent'
|
|
443
443
|
}
|
|
@@ -246,7 +246,7 @@ export const CometChatMessageInformation = (props: CometChatMessageInformationIn
|
|
|
246
246
|
});
|
|
247
247
|
setTemplateLoading(false)
|
|
248
248
|
}
|
|
249
|
-
|
|
249
|
+
|
|
250
250
|
return (
|
|
251
251
|
<View style={[
|
|
252
252
|
{
|
|
@@ -306,11 +306,14 @@ export const CometChatMessageInformation = (props: CometChatMessageInformationIn
|
|
|
306
306
|
<ErrorView /> :
|
|
307
307
|
recipients.length == 0 ?
|
|
308
308
|
<EmptyView /> :
|
|
309
|
-
<
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
309
|
+
<View style={{ minHeight: 0, maxHeight: "60%" }}>
|
|
310
|
+
<FlatList
|
|
311
|
+
style={{ backgroundColor: 'transparent' }}
|
|
312
|
+
contentContainerStyle={{ paddingBottom: "20%" }}
|
|
313
|
+
data={recipients}
|
|
314
|
+
renderItem={renderReceipients}
|
|
315
|
+
/>
|
|
316
|
+
</View>
|
|
314
317
|
}
|
|
315
318
|
</View>
|
|
316
319
|
)
|
|
@@ -48,6 +48,7 @@ export interface CometChatMessageListProps {
|
|
|
48
48
|
emptyStateText?: String,
|
|
49
49
|
ErrorStateView?: (e: CometChat.CometChatException) => JSX.Element,
|
|
50
50
|
errorStateText?: String,
|
|
51
|
+
hideError?: boolean,
|
|
51
52
|
LoadingStateView?: () => JSX.Element,
|
|
52
53
|
disableReceipt?: boolean,
|
|
53
54
|
disableSoundForMessages?: boolean,
|
|
@@ -140,6 +141,7 @@ export const CometChatMessageList = memo(forwardRef<
|
|
|
140
141
|
emptyStateText = localize("NO_MESSAGES_FOUND"),
|
|
141
142
|
ErrorStateView,
|
|
142
143
|
errorStateText = localize("SOMETHING_WRONG"),
|
|
144
|
+
hideError,
|
|
143
145
|
LoadingStateView,
|
|
144
146
|
disableReceipt = false,
|
|
145
147
|
disableSoundForMessages,
|
|
@@ -1800,6 +1802,7 @@ export const CometChatMessageList = memo(forwardRef<
|
|
|
1800
1802
|
}, [])
|
|
1801
1803
|
|
|
1802
1804
|
const getErrorStateView = useCallback(() => {
|
|
1805
|
+
if (hideError) return null;
|
|
1803
1806
|
if (ErrorStateView)
|
|
1804
1807
|
return ErrorStateView(new CometChat.CometChatException({ message: "Something went wrong" }));
|
|
1805
1808
|
return (
|
|
@@ -25,6 +25,7 @@ import { EmojiKeyboardStyle } from '../shared/views/CometChatEmojiKeyboard';
|
|
|
25
25
|
export interface MessageListConfigurationInterface {
|
|
26
26
|
ErrorStateView?: (e: CometChat.CometChatException) => JSX.Element;
|
|
27
27
|
errorStateText?: String;
|
|
28
|
+
hideError?: boolean,
|
|
28
29
|
EmptyStateView?: () => JSX.Element;
|
|
29
30
|
emptyStateText?: String;
|
|
30
31
|
LoadingStateView?: () => JSX.Element;
|
|
@@ -110,6 +111,7 @@ export class MessageListConfiguration
|
|
|
110
111
|
implements MessageListConfigurationInterface {
|
|
111
112
|
ErrorStateView: (e: CometChat.CometChatException) => JSX.Element;
|
|
112
113
|
errorStateText?: String;
|
|
114
|
+
hideError?: boolean;
|
|
113
115
|
EmptyStateView: () => JSX.Element;
|
|
114
116
|
emptyStateText?: String;
|
|
115
117
|
LoadingStateView: () => JSX.Element;
|
|
@@ -228,7 +228,7 @@ export const ReceiverTypeConstants = {
|
|
|
228
228
|
|
|
229
229
|
export const UserStatusConstants = {
|
|
230
230
|
online: CometChat.USER_STATUS.ONLINE,
|
|
231
|
-
offline: CometChat.USER_STATUS.
|
|
231
|
+
offline: CometChat.USER_STATUS.OFFLINE,
|
|
232
232
|
blocked: 'blocked',
|
|
233
233
|
unblocked: 'unblocked',
|
|
234
234
|
};
|
|
@@ -379,3 +379,14 @@ export enum goalType {
|
|
|
379
379
|
anyAction = CometChat.GoalType.ANY_ACTION,
|
|
380
380
|
none = CometChat.GoalType.NONE
|
|
381
381
|
}
|
|
382
|
+
|
|
383
|
+
export enum MentionsType {
|
|
384
|
+
users,
|
|
385
|
+
usersAndGroupMembers,
|
|
386
|
+
}
|
|
387
|
+
|
|
388
|
+
export enum MentionsVisibility {
|
|
389
|
+
both,
|
|
390
|
+
usersConversationOnly,
|
|
391
|
+
groupsConversationOnly,
|
|
392
|
+
}
|
|
@@ -7,6 +7,7 @@ import { CometChatUIEventHandler, CometChatUIEvents } from '../../events';
|
|
|
7
7
|
import { localize } from '../../resources';
|
|
8
8
|
import { SuggestionItem } from '../../views/CometChatSuggestionList';
|
|
9
9
|
import { CometChatUIKit } from '../../CometChatUiKit';
|
|
10
|
+
import { MentionsType, MentionsVisibility } from '../../constants/UIKitConstants';
|
|
10
11
|
|
|
11
12
|
/**
|
|
12
13
|
* Represents the CometChatMentionsFormatter class.
|
|
@@ -50,6 +51,20 @@ export class CometChatMentionsFormatter extends CometChatTextFormatter {
|
|
|
50
51
|
*/
|
|
51
52
|
protected limit: number = 10;
|
|
52
53
|
|
|
54
|
+
/**
|
|
55
|
+
* visibleIn property to determine where the mentions should be visible.
|
|
56
|
+
* @type {MentionsVisibility}
|
|
57
|
+
* @default MentionsVisibility.both
|
|
58
|
+
*/
|
|
59
|
+
protected visibleIn: MentionsVisibility = MentionsVisibility.both;
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* type property to determine the type of mention list.
|
|
63
|
+
* @type {MentionsType}
|
|
64
|
+
* @default MentionsType.usersAndGroupMembers
|
|
65
|
+
*/
|
|
66
|
+
protected type: MentionsType = MentionsType.usersAndGroupMembers;
|
|
67
|
+
|
|
53
68
|
/**
|
|
54
69
|
* Initializes a new CometChatMentionsFormatter.
|
|
55
70
|
* @param {CometChat.User} loggedInUser - The user who is currently logged in.
|
|
@@ -127,7 +142,7 @@ export class CometChatMentionsFormatter extends CometChatTextFormatter {
|
|
|
127
142
|
|
|
128
143
|
search(searchKey: string): void {
|
|
129
144
|
if (this.shouldLoadLocalData(searchKey)) return;
|
|
130
|
-
let requestBuilder = this.customRequest || (this.group ? new CometChat.GroupMembersRequestBuilder(this.group.getGuid()) : new CometChat.UsersRequestBuilder());
|
|
145
|
+
let requestBuilder = this.customRequest || ((this.group && this.type === MentionsType.usersAndGroupMembers) ? new CometChat.GroupMembersRequestBuilder(this.group.getGuid()) : new CometChat.UsersRequestBuilder());
|
|
131
146
|
|
|
132
147
|
this.searchRequest = requestBuilder.setLimit(10)
|
|
133
148
|
.setSearchKeyword(searchKey)
|
|
@@ -376,6 +391,36 @@ export class CometChatMentionsFormatter extends CometChatTextFormatter {
|
|
|
376
391
|
}
|
|
377
392
|
}
|
|
378
393
|
|
|
394
|
+
/**
|
|
395
|
+
* Sets the type of mention list.
|
|
396
|
+
* @param type - The type of mention list.
|
|
397
|
+
*/
|
|
398
|
+
setType(type: MentionsType) {
|
|
399
|
+
this.type = type;
|
|
400
|
+
}
|
|
401
|
+
|
|
402
|
+
/**
|
|
403
|
+
* Sets the visibleIn property to determine where the mentions should be visible.
|
|
404
|
+
* @param visibleIn - The visibleIn property to set.
|
|
405
|
+
*/
|
|
406
|
+
setVisibleIn(visibleIn: MentionsVisibility) {
|
|
407
|
+
this.visibleIn = visibleIn;
|
|
408
|
+
}
|
|
409
|
+
|
|
410
|
+
/**
|
|
411
|
+
* Retrieves the visibleIn property to determine where the mentions should be visible.
|
|
412
|
+
*/
|
|
413
|
+
getVisibleIn() {
|
|
414
|
+
return this.visibleIn;
|
|
415
|
+
}
|
|
416
|
+
|
|
417
|
+
/**
|
|
418
|
+
* Retrieves the type of mention list.
|
|
419
|
+
*/
|
|
420
|
+
getType() {
|
|
421
|
+
return this.type;
|
|
422
|
+
}
|
|
423
|
+
|
|
379
424
|
getErrorString() {
|
|
380
425
|
return (`${localize("MENTION_UPTO")} ${this.limit} ${this.limit === 1 ? localize("TIME") : localize("TIMES")} ${localize("AT_A_TIME")}.`);
|
|
381
426
|
}
|