@cometchat/chat-uikit-react-native 4.3.2 → 4.3.4
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/AndroidManifest.xml +3 -4
- package/android/src/main/java/com/reactnativecometchatuikit/CometchatUiKitPackage.java +0 -1
- package/android/src/main/java/com/reactnativecometchatuikit/FileManager.java +125 -7
- package/android/src/main/java/com/reactnativecometchatuikit/ImageManager.java +1 -1
- package/ios/CommonUtil.h +4 -0
- package/ios/CommonUtil.m +27 -0
- package/package.json +1 -1
- package/src/AI/AIAssistBot/AIAssistBotDecorator.tsx +0 -3
- package/src/CometChatConversations/CometChatConversations.tsx +151 -66
- package/src/CometChatConversations/ConversationsConfiguration.ts +25 -4
- package/src/CometChatConversations/style.ts +5 -1
- package/src/CometChatConversationsWithMessages/CometChatConversationsWithMessages.tsx +29 -29
- package/src/CometChatMessageComposer/CometChatMessageComposer.tsx +598 -63
- package/src/CometChatMessageComposer/MessageComposerConfiguration.tsx +12 -1
- package/src/CometChatMessageComposer/resources/Info.png +0 -0
- package/src/CometChatMessageComposer/resources/index.ts +3 -1
- package/src/CometChatMessageHeader/listners.ts +0 -2
- package/src/CometChatMessageList/CometChatMessageList.tsx +139 -30
- package/src/CometChatMessageList/MessageListConfiguration.ts +19 -6
- package/src/CometChatMessages/CometChatMessages.tsx +16 -16
- package/src/CometChatThreadedMessages/CometChatThreadedMessages.tsx +41 -3
- package/src/calls/CallingExtentionDecorator.tsx +5 -5
- package/src/calls/CometChatCallButtons/CometChatCallButtons.tsx +3 -3
- package/src/calls/CometChatIncomingCall/CometChatIncomingCall.tsx +2 -0
- package/src/calls/CometChatOutgoingCall/CometChatOutgoingCall.tsx +2 -0
- package/src/extensions/CollaborativeDocument/CollaborativeDocumentExtensionDecorator.tsx +3 -3
- package/src/extensions/CollaborativeWhiteboard/CollaborativeWhiteboardExtensionDecorator.tsx +3 -3
- package/src/extensions/LinkPreview/LinkPreviewBubble.tsx +51 -15
- package/src/extensions/LinkPreview/LinkPreviewExtentionDecorator.tsx +4 -4
- package/src/extensions/MessageTranslation/MessageTranslationBubble.tsx +31 -9
- package/src/extensions/MessageTranslation/MessageTranslationDecorator.tsx +83 -6
- package/src/extensions/Polls/Polls.tsx +106 -70
- package/src/extensions/Polls/PollsDecorator.tsx +3 -2
- package/src/extensions/Stickers/CometChatStickerKeyboard/style.ts +3 -3
- package/src/extensions/Stickers/StickersExtensionDecorator.tsx +14 -6
- package/src/extensions/TextModeration/TextModerationExtensionDecorator.tsx +3 -3
- package/src/index.ts +29 -8
- package/src/shared/CometChatUiKit/CometChatUIKit.ts +146 -24
- package/src/shared/CometChatUiKit/index.ts +1 -1
- package/src/shared/base/vars.ts +13 -0
- package/src/shared/constants/UIKitConstants.ts +6 -0
- package/src/shared/events/CometChatUIEventHandler/CometChatUIEventHandler.ts +7 -0
- package/src/shared/events/CometChatUIEventHandler/Listener.ts +11 -1
- package/src/shared/events/CometChatUIEvents.ts +3 -1
- package/src/shared/formatters/CometChatMentionsFormatter/CometChatMentionsFormatter.tsx +380 -0
- package/src/shared/formatters/CometChatMentionsFormatter/MentionTextStyle.ts +14 -0
- package/src/shared/formatters/CometChatMentionsFormatter/index.ts +7 -0
- package/src/shared/formatters/CometChatTextFormatter.ts +253 -0
- package/src/shared/formatters/CometChatUrlsFormatter/index.tsx +146 -0
- package/src/shared/formatters/index.ts +11 -0
- package/src/shared/framework/DataSource.ts +21 -16
- package/src/shared/framework/DataSourceDecorator.tsx +29 -13
- package/src/shared/framework/MessageDataSource.tsx +215 -49
- package/src/shared/helper/useKeyboard.tsx +20 -2
- package/src/shared/index.ts +31 -11
- package/src/shared/libs/ImageZoom/ReactNativeZoomableView.tsx +1040 -0
- package/src/shared/libs/ImageZoom/ReactNativeZoomableViewWithGestures.tsx +223 -0
- package/src/shared/libs/ImageZoom/helper.ts +144 -0
- package/src/shared/libs/ImageZoom/index.tsx +13 -0
- package/src/shared/libs/ImageZoom/types/index.ts +186 -0
- package/src/shared/libs/VideoPlayer/Video.js +0 -24
- package/src/shared/libs/VideoPlayerControls/assets/img/back.png +0 -0
- package/src/shared/libs/VideoPlayerControls/components/Back/Back.tsx +1 -1
- package/src/shared/resources/CometChatLocalize/CometChatLocalize.ts +2 -0
- package/src/shared/resources/CometChatLocalize/resources/ar/translation.json +11 -1
- package/src/shared/resources/CometChatLocalize/resources/de/translation.json +11 -1
- package/src/shared/resources/CometChatLocalize/resources/en/translation.json +10 -1
- package/src/shared/resources/CometChatLocalize/resources/es/translation.json +11 -1
- package/src/shared/resources/CometChatLocalize/resources/fr/translation.json +11 -1
- package/src/shared/resources/CometChatLocalize/resources/hi/translation.json +10 -1
- package/src/shared/resources/CometChatLocalize/resources/hu/translation.json +315 -0
- package/src/shared/resources/CometChatLocalize/resources/lt/translation.json +11 -1
- package/src/shared/resources/CometChatLocalize/resources/ms/translation.json +11 -1
- package/src/shared/resources/CometChatLocalize/resources/pt/translation.json +12 -1
- package/src/shared/resources/CometChatLocalize/resources/ru/translation.json +11 -1
- package/src/shared/resources/CometChatLocalize/resources/sv/translation.json +11 -1
- package/src/shared/resources/CometChatLocalize/resources/zh/translation.json +11 -1
- package/src/shared/resources/CometChatLocalize/resources/zh-tw/translation.json +11 -1
- package/src/shared/resources/CometChatTheme/Palette.ts +16 -0
- package/src/shared/utils/InteractiveMessageUtils.ts +39 -1
- package/src/shared/utils/NetworkUtils.tsx +5 -0
- package/src/shared/utils/PermissionUtil.ts +142 -0
- package/src/shared/views/CometChatActionSheet/CometChatActionSheet.tsx +1 -0
- package/src/shared/views/CometChatAudioBubble/CometChatAudioBubble.tsx +8 -6
- package/src/shared/views/CometChatAvatar/CometChatAvatar.tsx +5 -1
- package/src/shared/views/CometChatFileBubble/CometChatFileBubble.tsx +12 -11
- package/src/shared/views/CometChatImageBubble/CometChatImageBubble.tsx +70 -22
- package/src/shared/views/CometChatImageBubble/assets/index.ts +5 -0
- package/src/shared/views/CometChatImageBubble/assets/spineer.png +0 -0
- package/src/shared/views/CometChatImageViewerModal/ImageViewerModal.tsx +106 -0
- package/src/shared/views/CometChatImageViewerModal/index.tsx +1 -0
- package/src/shared/views/CometChatImageViewerModal/resources/Back.png +0 -0
- package/src/shared/views/CometChatImageViewerModal/resources/index.ts +5 -0
- package/src/shared/views/CometChatList/CometChatList.tsx +10 -1
- package/src/shared/views/CometChatMessageInput/CometChatMessageInput.tsx +3 -2
- package/src/shared/views/{CometChatReactionsList/CometChatReactionsList.tsx → CometChatReactionList/CometChatReactionList.tsx} +17 -17
- package/src/shared/views/CometChatReactionList/ReactionListConfiguration.tsx +14 -0
- package/src/shared/views/CometChatReactionList/index.ts +12 -0
- package/src/shared/views/CometChatReactions/CometChatReactions.tsx +3 -3
- package/src/shared/views/CometChatSchedulerBubble/CometChatSchedulerBubble.tsx +12 -0
- package/src/shared/views/CometChatSuggestionList/CometChatSuggestionList.tsx +64 -0
- package/src/shared/views/CometChatSuggestionList/SuggestionItem.ts +48 -0
- package/src/shared/views/CometChatSuggestionList/SuggestionListConfiguration.ts +23 -0
- package/src/shared/views/CometChatSuggestionList/index.ts +11 -0
- package/src/shared/views/CometChatTextBubble/CometChatTextBubble.tsx +33 -46
- package/src/shared/views/CometChatTextBubble/TextBubbleStyle.ts +0 -14
- package/src/shared/views/CometChatTextBubble/index.ts +2 -3
- package/src/shared/views/CometChatVideoBubble/CometChatVideoBubble.tsx +6 -4
- package/src/shared/views/index.ts +14 -8
- package/android/src/main/java/com/reactnativecometchatuikit/VideoManager.java +0 -40
- package/src/shared/libs/VideoPlayerControls/assets/img/back@2x.png +0 -0
- package/src/shared/libs/VideoPlayerControls/assets/img/back@3x.png +0 -0
- package/src/shared/utils/PermissionUtilIOS.ts +0 -104
- package/src/shared/views/CometChatReactionsList/ReactionsListConfiguration.tsx +0 -14
- package/src/shared/views/CometChatReactionsList/index.ts +0 -12
- /package/src/shared/views/{CometChatReactionsList/ReactionsListStyle.tsx → CometChatReactionList/ReactionListStyle.tsx} +0 -0
- /package/src/shared/views/{CometChatReactionsList → CometChatReactionList}/resources/Spineer.png +0 -0
- /package/src/shared/views/{CometChatReactionsList → CometChatReactionList}/resources/index.ts +0 -0
|
@@ -5,14 +5,15 @@ import { localize } from "../../shared/resources";
|
|
|
5
5
|
import { CometChatBottomSheet} from "../../shared/views";
|
|
6
6
|
import { ChatConfigurator, DataSource, DataSourceDecorator } from "../../shared/framework";
|
|
7
7
|
import { CometChatTheme } from "../../shared/resources/CometChatTheme";
|
|
8
|
-
import { MessageBubbleAlignmentType, MessageCategoryConstants } from "../../shared/constants/UIKitConstants";
|
|
8
|
+
import { AdditionalBubbleStylingParams, MessageBubbleAlignmentType, MessageCategoryConstants } from "../../shared/constants/UIKitConstants";
|
|
9
9
|
import { ExtensionTypeConstants } from "../ExtensionConstants";
|
|
10
|
-
import { Image, TouchableOpacity } from "react-native";
|
|
10
|
+
import { Image, Keyboard, TouchableOpacity } from "react-native";
|
|
11
11
|
import { CometChatStickerBubble } from "./StickersBubble";
|
|
12
12
|
import { StickerConfigurationInterface } from "./StickerConfiguration";
|
|
13
13
|
import { StickerIcon } from "./resources";
|
|
14
14
|
import { CometChatStickerKeyboard } from "./CometChatStickerKeyboard";
|
|
15
15
|
import { CometChatUIKit } from "../../shared/CometChatUiKit/CometChatUIKit";
|
|
16
|
+
import { isKeyboardVisible } from "../../shared/helper/useKeyboard";
|
|
16
17
|
|
|
17
18
|
export class StickersExtensionDecorator extends DataSourceDecorator {
|
|
18
19
|
|
|
@@ -27,8 +28,8 @@ export class StickersExtensionDecorator extends DataSourceDecorator {
|
|
|
27
28
|
return message.getDeletedBy() != null;
|
|
28
29
|
}
|
|
29
30
|
|
|
30
|
-
getAllMessageTemplates(theme: CometChatTheme): CometChatMessageTemplate[] {
|
|
31
|
-
let templates = super.getAllMessageTemplates(theme);
|
|
31
|
+
getAllMessageTemplates(theme: CometChatTheme, additionalParams?: AdditionalBubbleStylingParams): CometChatMessageTemplate[] {
|
|
32
|
+
let templates = super.getAllMessageTemplates(theme, additionalParams);
|
|
32
33
|
templates.push(
|
|
33
34
|
new CometChatMessageTemplate({
|
|
34
35
|
type: ExtensionTypeConstants.sticker,
|
|
@@ -90,8 +91,15 @@ export class StickersExtensionDecorator extends DataSourceDecorator {
|
|
|
90
91
|
}
|
|
91
92
|
|
|
92
93
|
let views:JSX.Element[] = super.getAuxiliaryOptions(user,group,id)
|
|
93
|
-
views.push(<TouchableOpacity onPress={() => {
|
|
94
|
-
|
|
94
|
+
views.push(<TouchableOpacity key={"sticker"} onPress={() => {
|
|
95
|
+
if (isKeyboardVisible) {
|
|
96
|
+
Keyboard.dismiss();
|
|
97
|
+
setTimeout(() => {
|
|
98
|
+
setShowKeyboard(true);
|
|
99
|
+
}, 1000);
|
|
100
|
+
} else {
|
|
101
|
+
setShowKeyboard(true);
|
|
102
|
+
}
|
|
95
103
|
}} style={{justifyContent: "center"}}>
|
|
96
104
|
<Image
|
|
97
105
|
source={StickerIcon}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { DataSource, DataSourceDecorator } from "../../shared/framework";
|
|
2
2
|
import { CometChat } from "@cometchat/chat-sdk-react-native";
|
|
3
|
-
import { MessageBubbleAlignmentType } from "../../shared/constants/UIKitConstants";
|
|
3
|
+
import { AdditionalBubbleStylingParams, MessageBubbleAlignmentType } from "../../shared/constants/UIKitConstants";
|
|
4
4
|
import { CometChatTheme } from "../../shared/resources/CometChatTheme";
|
|
5
5
|
import { ExtensionConstants } from "../ExtensionConstants";
|
|
6
6
|
import { getExtentionData } from "../ExtensionModerator";
|
|
@@ -20,10 +20,10 @@ export class TextModerationExtensionDecorator extends DataSourceDecorator {
|
|
|
20
20
|
}
|
|
21
21
|
}
|
|
22
22
|
|
|
23
|
-
getTextMessageBubble(messageText: string, message: CometChat.TextMessage, alignment: MessageBubbleAlignmentType, theme: CometChatTheme) {
|
|
23
|
+
getTextMessageBubble(messageText: string, message: CometChat.TextMessage, alignment: MessageBubbleAlignmentType, theme: CometChatTheme, additionalParams?: AdditionalBubbleStylingParams) {
|
|
24
24
|
|
|
25
25
|
var text : string = this.checkModeration(message)
|
|
26
|
-
return super.getTextMessageBubble(text , message , alignment, theme);
|
|
26
|
+
return super.getTextMessageBubble(text , message , alignment, theme, additionalParams);
|
|
27
27
|
}
|
|
28
28
|
|
|
29
29
|
|
package/src/index.ts
CHANGED
|
@@ -149,10 +149,10 @@ import {
|
|
|
149
149
|
ReactionsConfigurationInterface,
|
|
150
150
|
ReactionsStyle,
|
|
151
151
|
ReactionsStyleInterface,
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
152
|
+
CometChatReactionList,
|
|
153
|
+
CometChatReactionListInterface,
|
|
154
|
+
ReactionListConfiguration,
|
|
155
|
+
ReactionListConfigurationInterface,
|
|
156
156
|
ReactionListStyle,
|
|
157
157
|
ReactionListStyleInterface,
|
|
158
158
|
CometChatQuickReactions,
|
|
@@ -166,6 +166,15 @@ import {
|
|
|
166
166
|
EmojiKeyboardConfiguration,
|
|
167
167
|
EmojiKeyboardStyle,
|
|
168
168
|
|
|
169
|
+
CometChatMentionsFormatter,
|
|
170
|
+
CometChatTextFormatter,
|
|
171
|
+
CometChatUrlsFormatter,
|
|
172
|
+
MentionTextStyle,
|
|
173
|
+
CometChatSuggestionList,
|
|
174
|
+
CometChatSuggestionListInterface,
|
|
175
|
+
SuggestionListConfiguration,
|
|
176
|
+
SuggestionListConfigurationInterface,
|
|
177
|
+
SuggestionItem,
|
|
169
178
|
} from './shared';
|
|
170
179
|
|
|
171
180
|
import {
|
|
@@ -699,10 +708,10 @@ export {
|
|
|
699
708
|
ReactionsConfigurationInterface,
|
|
700
709
|
ReactionsStyle,
|
|
701
710
|
ReactionsStyleInterface,
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
711
|
+
CometChatReactionList,
|
|
712
|
+
CometChatReactionListInterface,
|
|
713
|
+
ReactionListConfiguration,
|
|
714
|
+
ReactionListConfigurationInterface,
|
|
706
715
|
ReactionListStyle,
|
|
707
716
|
ReactionListStyleInterface,
|
|
708
717
|
CometChatQuickReactions,
|
|
@@ -718,6 +727,18 @@ export {
|
|
|
718
727
|
EmojiKeyboardConfiguration,
|
|
719
728
|
EmojiKeyboardStyle,
|
|
720
729
|
/* Emoji Keyboard */
|
|
730
|
+
|
|
731
|
+
/* Text Formatters */
|
|
732
|
+
CometChatMentionsFormatter,
|
|
733
|
+
CometChatTextFormatter,
|
|
734
|
+
CometChatUrlsFormatter,
|
|
735
|
+
MentionTextStyle,
|
|
736
|
+
CometChatSuggestionList,
|
|
737
|
+
CometChatSuggestionListInterface,
|
|
738
|
+
SuggestionItem,
|
|
739
|
+
SuggestionListConfiguration,
|
|
740
|
+
SuggestionListConfigurationInterface
|
|
741
|
+
/* Text Formatters */
|
|
721
742
|
|
|
722
743
|
};
|
|
723
744
|
|
|
@@ -26,11 +26,17 @@ import { AISmartRepliesExtension } from "../../AI/AISmartReplies/AISmartReplies"
|
|
|
26
26
|
import { AIConversationSummaryExtension } from "../../AI/AIConversationSummary/AIConversationSummaryExtension";
|
|
27
27
|
import { AIAssistBotExtension } from "../../AI/AIAssistBot/AIAssistBotExtension";
|
|
28
28
|
import { SchedulerMessage } from "../modals/InteractiveData/InteractiveMessage";
|
|
29
|
-
import {
|
|
29
|
+
import { permissionUtil } from "../utils/PermissionUtil";
|
|
30
|
+
import {
|
|
31
|
+
getUnixTimestamp,
|
|
32
|
+
} from '../../shared/utils/CometChatMessageHelper';
|
|
30
33
|
|
|
31
34
|
export class CometChatUIKit {
|
|
32
35
|
static uiKitSettings: UIKitSettings;
|
|
33
|
-
static aiFeatures:AIExtensionDataSource[]
|
|
36
|
+
static aiFeatures: AIExtensionDataSource[]
|
|
37
|
+
static loggedInUser: null | CometChat.User = null;
|
|
38
|
+
private static loginListenerID: string = ``;
|
|
39
|
+
private static isLoginListenerAttached: boolean = false;
|
|
34
40
|
static init(uiKitSettings: UIKitSettings): Promise<boolean> {
|
|
35
41
|
|
|
36
42
|
//perform sdk init taking values from uiKitSettings
|
|
@@ -47,17 +53,29 @@ export class CometChatUIKit {
|
|
|
47
53
|
|
|
48
54
|
appSetting.subscriptionType = uiKitSettings.subscriptionType;
|
|
49
55
|
|
|
56
|
+
CometChatUIKit.attachListener();
|
|
57
|
+
|
|
50
58
|
return CometChat.init(uiKitSettings.appId, appSetting.build()).then(
|
|
51
59
|
() => {
|
|
52
60
|
CometChat.setSource("uikit-v4", Platform.OS, "react-native")
|
|
53
61
|
ListenerInitializer.attachListeners();
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
62
|
+
|
|
63
|
+
CometChat.getLoggedinUser()
|
|
64
|
+
.then(user => {
|
|
65
|
+
console.log("setting logged in user", user);
|
|
66
|
+
CometChatUIKit.setLoggedInUser(user);
|
|
67
|
+
if (user) {
|
|
68
|
+
this.enableExtensions();
|
|
58
69
|
}
|
|
59
70
|
})
|
|
60
|
-
|
|
71
|
+
.catch(error => {
|
|
72
|
+
// CometChatUIKit.setLoggedInUser(null);
|
|
73
|
+
})
|
|
74
|
+
permissionUtil.init().then(res => {
|
|
75
|
+
if (res !== true) {
|
|
76
|
+
console.warn("[IOS] Permission initialization failed.");
|
|
77
|
+
}
|
|
78
|
+
})
|
|
61
79
|
}, error => {
|
|
62
80
|
// console.log("Initialization failed with error:", error);
|
|
63
81
|
}
|
|
@@ -75,8 +93,8 @@ export class CometChatUIKit {
|
|
|
75
93
|
new LinkPreviewExtention(),
|
|
76
94
|
new PollsExtension(),
|
|
77
95
|
new ImageModerationExtension()
|
|
78
|
-
]
|
|
79
|
-
|
|
96
|
+
]
|
|
97
|
+
|
|
80
98
|
static defaultAIFeatures: AIExtensionDataSource[] = [
|
|
81
99
|
new AISmartRepliesExtension(),
|
|
82
100
|
new AIConversationStarterExtension(),
|
|
@@ -84,6 +102,29 @@ export class CometChatUIKit {
|
|
|
84
102
|
new AIAssistBotExtension()
|
|
85
103
|
]
|
|
86
104
|
|
|
105
|
+
private static attachListener() {
|
|
106
|
+
if (CometChatUIKit.isLoginListenerAttached) {
|
|
107
|
+
CometChatUIKit.removeListener();
|
|
108
|
+
CometChatUIKit.isLoginListenerAttached = false;
|
|
109
|
+
CometChatUIKit.loginListenerID = ``;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
CometChatUIKit.loginListenerID = `__CometChatLoginListener__`;
|
|
113
|
+
CometChat.addLoginListener(
|
|
114
|
+
CometChatUIKit.loginListenerID,
|
|
115
|
+
new CometChat.LoginListener({
|
|
116
|
+
onLoggedIn: (user: CometChat.User) => {
|
|
117
|
+
CometChatUIKit.setLoggedInUser(user);
|
|
118
|
+
},
|
|
119
|
+
onLoggedOut: () => {
|
|
120
|
+
CometChatUIKit.removeLoggedInUser();
|
|
121
|
+
},
|
|
122
|
+
})
|
|
123
|
+
);
|
|
124
|
+
CometChatUIKit.isLoginListenerAttached = true;
|
|
125
|
+
|
|
126
|
+
}
|
|
127
|
+
|
|
87
128
|
private static enableExtensions() {
|
|
88
129
|
ChatConfigurator.init(); //re-initialize data source
|
|
89
130
|
|
|
@@ -94,16 +135,16 @@ export class CometChatUIKit {
|
|
|
94
135
|
let extensionList: ExtensionsDataSource[] = this.uiKitSettings?.extensions || this.defaultExtensions;
|
|
95
136
|
let aiFeaturesList: AIExtensionDataSource[] = this.uiKitSettings?.aiFeatures || this.defaultAIFeatures;
|
|
96
137
|
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
138
|
+
if (extensionList.length > 0) {
|
|
139
|
+
extensionList.forEach((extension: ExtensionsDataSource) => {
|
|
140
|
+
extension?.enable();
|
|
141
|
+
});
|
|
142
|
+
}
|
|
143
|
+
if (aiFeaturesList.length > 0) {
|
|
144
|
+
aiFeaturesList.forEach((aiFeatures: AIExtensionDataSource) => {
|
|
145
|
+
aiFeatures.enable();
|
|
146
|
+
})
|
|
147
|
+
}
|
|
107
148
|
|
|
108
149
|
|
|
109
150
|
}
|
|
@@ -112,17 +153,34 @@ export class CometChatUIKit {
|
|
|
112
153
|
if (CometChatUIKit.checkAuthSettings(Promise.reject)) null
|
|
113
154
|
let user = await CometChat.getLoggedinUser().catch((e) => Promise.reject(e))
|
|
114
155
|
if (user == null) {
|
|
115
|
-
|
|
156
|
+
throw(new CometChat.CometChatException({ code: "NOT_FOUND", message: "Login user not found" }));
|
|
116
157
|
} else {
|
|
117
158
|
this.enableExtensions()
|
|
118
159
|
}
|
|
119
160
|
return user;
|
|
120
161
|
}
|
|
121
162
|
|
|
163
|
+
private static setLoggedInUser(user: CometChat.User | null) {
|
|
164
|
+
this.loggedInUser = user;
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
private static removeLoggedInUser() {
|
|
168
|
+
this.loggedInUser = null;
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
private static removeListener() {
|
|
172
|
+
if (CometChatUIKit.isLoginListenerAttached) {
|
|
173
|
+
CometChat.removeLoginListener(CometChatUIKit.loginListenerID);
|
|
174
|
+
CometChatUIKit.isLoginListenerAttached = false;
|
|
175
|
+
CometChatUIKit.loginListenerID = ``;
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
|
|
122
179
|
static async login({ uid, authToken }: { uid?: string, authToken?: string }): Promise<CometChat.User> {
|
|
123
180
|
if (CometChatUIKit.checkAuthSettings(Promise.reject)) null
|
|
124
181
|
if (uid) {
|
|
125
182
|
let user = await CometChat.login(uid, CometChatUIKit.uiKitSettings?.authKey).catch(e => Promise.reject(e));
|
|
183
|
+
CometChatUIKit.setLoggedInUser(user)
|
|
126
184
|
this.enableExtensions()
|
|
127
185
|
return user;
|
|
128
186
|
}
|
|
@@ -182,6 +240,16 @@ export class CometChatUIKit {
|
|
|
182
240
|
///[sendCustomMessage] used to send a custom message
|
|
183
241
|
static sendCustomMessage(message: CometChat.CustomMessage): Promise<CometChat.CustomMessage | CometChat.BaseMessage> {
|
|
184
242
|
return new Promise((resolve, reject) => {
|
|
243
|
+
|
|
244
|
+
if (!message.getMuid()) {
|
|
245
|
+
message.setMuid(String(getUnixTimestamp()));
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
if(!message.getSender()){
|
|
249
|
+
message.setSender(this.loggedInUser);
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
|
|
185
253
|
CometChatUIKitHelper.onMessageSent(message, messageStatus.inprogress);
|
|
186
254
|
CometChat.sendCustomMessage(message)
|
|
187
255
|
.then(customMessage => {
|
|
@@ -189,7 +257,7 @@ export class CometChatUIKit {
|
|
|
189
257
|
resolve(customMessage);
|
|
190
258
|
})
|
|
191
259
|
.catch(err => {
|
|
192
|
-
if(message.data)
|
|
260
|
+
if (message.data)
|
|
193
261
|
message.data.metaData = { ...(message.data.metaData ? message.data.metaData : {}), error: true }
|
|
194
262
|
CometChatUIKitHelper.onMessageSent(message, messageStatus.error);
|
|
195
263
|
reject(err);
|
|
@@ -200,6 +268,16 @@ export class CometChatUIKit {
|
|
|
200
268
|
///[sendMediaMessage] used to send a media message
|
|
201
269
|
static sendMediaMessage(message: CometChat.MediaMessage): Promise<CometChat.MediaMessage | CometChat.BaseMessage> {
|
|
202
270
|
return new Promise((resolve, reject) => {
|
|
271
|
+
|
|
272
|
+
|
|
273
|
+
if (!message.getMuid()) {
|
|
274
|
+
message.setMuid(String(getUnixTimestamp()));
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
if(!message.getSender()){
|
|
278
|
+
message.setSender(this.loggedInUser);
|
|
279
|
+
}
|
|
280
|
+
|
|
203
281
|
let hasAttachment;
|
|
204
282
|
try {
|
|
205
283
|
hasAttachment = message.getAttachment();
|
|
@@ -231,7 +309,7 @@ export class CometChatUIKit {
|
|
|
231
309
|
resolve(mediaMessage);
|
|
232
310
|
})
|
|
233
311
|
.catch(err => {
|
|
234
|
-
if(message.data)
|
|
312
|
+
if (message.data)
|
|
235
313
|
message.data.metaData = { ...(message.data.metaData ? message.data.metaData : {}), error: true }
|
|
236
314
|
CometChatUIKitHelper.onMessageSent(message, messageStatus.error);
|
|
237
315
|
reject(err);
|
|
@@ -242,6 +320,17 @@ export class CometChatUIKit {
|
|
|
242
320
|
///[sendTextMessage] used to send a text message
|
|
243
321
|
static sendTextMessage(message: CometChat.TextMessage): Promise<CometChat.TextMessage | CometChat.BaseMessage> {
|
|
244
322
|
return new Promise((resolve, reject) => {
|
|
323
|
+
|
|
324
|
+
|
|
325
|
+
if (!message?.getMuid()) {
|
|
326
|
+
message.setMuid(String(getUnixTimestamp()));
|
|
327
|
+
}
|
|
328
|
+
|
|
329
|
+
if(!message?.getSender()){
|
|
330
|
+
message.setSender(this.loggedInUser);
|
|
331
|
+
}
|
|
332
|
+
|
|
333
|
+
|
|
245
334
|
CometChatUIKitHelper.onMessageSent(message, messageStatus.inprogress);
|
|
246
335
|
CometChat.sendMessage(message)
|
|
247
336
|
.then(textMessage => {
|
|
@@ -249,7 +338,7 @@ export class CometChatUIKit {
|
|
|
249
338
|
resolve(textMessage);
|
|
250
339
|
})
|
|
251
340
|
.catch(err => {
|
|
252
|
-
if(message.data)
|
|
341
|
+
if (message.data)
|
|
253
342
|
message.data.metaData = { ...(message.data.metaData ? message.data.metaData : {}), error: true }
|
|
254
343
|
CometChatUIKitHelper.onMessageSent(message, messageStatus.error);
|
|
255
344
|
reject(err);
|
|
@@ -265,13 +354,20 @@ export class CometChatUIKit {
|
|
|
265
354
|
*/
|
|
266
355
|
static sendSchedulerMessage(message: SchedulerMessage, disableLocalEvents: boolean = false): Promise<CometChat.TextMessage | CometChat.BaseMessage> {
|
|
267
356
|
return new Promise((resolve, reject) => {
|
|
357
|
+
|
|
358
|
+
if (!message.getMuid()) {
|
|
359
|
+
message.setMuid(String(getUnixTimestamp()));
|
|
360
|
+
}
|
|
361
|
+
|
|
362
|
+
if(!message.getSender()){
|
|
363
|
+
message.setSender(this.loggedInUser);
|
|
364
|
+
}
|
|
268
365
|
if (!disableLocalEvents) {
|
|
269
366
|
CometChatUIKitHelper.onMessageSent(message, messageStatus.inprogress);
|
|
270
367
|
}
|
|
271
368
|
|
|
272
369
|
CometChat.sendInteractiveMessage(message)
|
|
273
370
|
.then((message: CometChat.BaseMessage) => {
|
|
274
|
-
console.log("message sent successfully", message.getSentAt())
|
|
275
371
|
if (!disableLocalEvents) {
|
|
276
372
|
CometChatUIKitHelper.onMessageSent(message, messageStatus.success);
|
|
277
373
|
}
|
|
@@ -295,6 +391,15 @@ export class CometChatUIKit {
|
|
|
295
391
|
*/
|
|
296
392
|
static sendFormMessage(message: FormMessage, disableLocalEvents: boolean = false): Promise<CometChat.TextMessage | CometChat.BaseMessage> {
|
|
297
393
|
return new Promise((resolve, reject) => {
|
|
394
|
+
|
|
395
|
+
if (!message.getMuid()) {
|
|
396
|
+
message.setMuid(String(getUnixTimestamp()));
|
|
397
|
+
}
|
|
398
|
+
|
|
399
|
+
if(!message.getSender()){
|
|
400
|
+
message.setSender(this.loggedInUser);
|
|
401
|
+
}
|
|
402
|
+
|
|
298
403
|
if (!disableLocalEvents) {
|
|
299
404
|
CometChatUIKitHelper.onMessageSent(message, messageStatus.inprogress);
|
|
300
405
|
}
|
|
@@ -325,6 +430,14 @@ export class CometChatUIKit {
|
|
|
325
430
|
*/
|
|
326
431
|
static sendCardMessage(message: CardMessage, disableLocalEvents: boolean = false): Promise<CometChat.TextMessage | CometChat.BaseMessage> {
|
|
327
432
|
return new Promise((resolve, reject) => {
|
|
433
|
+
|
|
434
|
+
if (!message.getMuid()) {
|
|
435
|
+
message.setMuid(String(getUnixTimestamp()));
|
|
436
|
+
}
|
|
437
|
+
|
|
438
|
+
if(!message.getSender()){
|
|
439
|
+
message.setSender(this.loggedInUser);
|
|
440
|
+
}
|
|
328
441
|
if (!disableLocalEvents) {
|
|
329
442
|
CometChatUIKitHelper.onMessageSent(message, messageStatus.inprogress);
|
|
330
443
|
}
|
|
@@ -356,6 +469,15 @@ export class CometChatUIKit {
|
|
|
356
469
|
*/
|
|
357
470
|
static sendCustomInteractiveMessage(message: CustomInteractiveMessage, disableLocalEvents: boolean = false): Promise<CometChat.TextMessage | CometChat.BaseMessage> {
|
|
358
471
|
return new Promise((resolve, reject) => {
|
|
472
|
+
|
|
473
|
+
if (!message.getMuid()) {
|
|
474
|
+
message.setMuid(String(getUnixTimestamp()));
|
|
475
|
+
}
|
|
476
|
+
|
|
477
|
+
if(!message.getSender()){
|
|
478
|
+
message.setSender(this.loggedInUser);
|
|
479
|
+
}
|
|
480
|
+
|
|
359
481
|
if (!disableLocalEvents) {
|
|
360
482
|
CometChatUIKitHelper.onMessageSent(message, messageStatus.inprogress);
|
|
361
483
|
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
//@ts-ignore
|
|
2
2
|
import { CometChat } from '@cometchat/chat-sdk-react-native'
|
|
3
|
+
import { CometChatTextFormatter } from '../views';
|
|
3
4
|
|
|
4
5
|
export const USER_ONLINE_STATUS = 'online'
|
|
5
6
|
export const NO_USERS_FOUND = "no_users_found";
|
|
@@ -383,3 +384,8 @@ export enum goalType {
|
|
|
383
384
|
anyAction = CometChat.GoalType.ANY_ACTION,
|
|
384
385
|
none = CometChat.GoalType.NONE
|
|
385
386
|
}
|
|
387
|
+
|
|
388
|
+
export type AdditionalBubbleStylingParams = {
|
|
389
|
+
textFormatters?: CometChatTextFormatter[],
|
|
390
|
+
disableMentions?: boolean
|
|
391
|
+
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { SuggestionItem } from "../../views";
|
|
1
2
|
import {
|
|
2
3
|
CallListener,
|
|
3
4
|
CallUIEventListener,
|
|
@@ -360,6 +361,12 @@ export class CometChatUIEventHandler {
|
|
|
360
361
|
case listener._eventListener.ccComposeMessage?.name:
|
|
361
362
|
listener._eventListener.ccComposeMessage(param);
|
|
362
363
|
break;
|
|
364
|
+
// case listener._eventListener.ccMentionClick?.name:
|
|
365
|
+
// listener._eventListener.ccMentionClick(param);
|
|
366
|
+
// break;
|
|
367
|
+
case listener._eventListener.ccSuggestionData?.name:
|
|
368
|
+
listener._eventListener.ccSuggestionData(param as { id: string, data: Array<SuggestionItem> });
|
|
369
|
+
break;
|
|
363
370
|
}
|
|
364
371
|
})
|
|
365
372
|
}
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { SuggestionItem } from "../../views";
|
|
2
|
+
|
|
1
3
|
export function isFalsy($false) {
|
|
2
4
|
if ($false != null) {
|
|
3
5
|
if (typeof $false == "string") $false = $false.trim();
|
|
@@ -221,6 +223,8 @@ type UIEvents = {
|
|
|
221
223
|
ccToggleBottomSheet?: (item)=>void,
|
|
222
224
|
openChat?: (item)=>void,
|
|
223
225
|
ccComposeMessage?:(item)=>void,
|
|
226
|
+
// ccMentionClick?:(item)=>void,
|
|
227
|
+
ccSuggestionData?:(item: {id: string | number, data: Array<SuggestionItem>})=>void,
|
|
224
228
|
}
|
|
225
229
|
export class UIEventListener {
|
|
226
230
|
showPanel?: (item)=>void;
|
|
@@ -228,18 +232,24 @@ export class UIEventListener {
|
|
|
228
232
|
ccToggleBottomSheet?: (item)=>void;
|
|
229
233
|
openChat?: (item)=>void;
|
|
230
234
|
ccComposeMessage?:(item)=>void;
|
|
235
|
+
// ccMentionClick?:(item)=>void;
|
|
236
|
+
ccSuggestionData?:(item: {id: string | number, data: Array<SuggestionItem>})=>void;
|
|
231
237
|
constructor({
|
|
232
238
|
showPanel,
|
|
233
239
|
hidePanel,
|
|
234
240
|
ccToggleBottomSheet,
|
|
235
241
|
openChat,
|
|
236
|
-
ccComposeMessage
|
|
242
|
+
ccComposeMessage,
|
|
243
|
+
// ccMentionClick,
|
|
244
|
+
ccSuggestionData,
|
|
237
245
|
}: UIEvents) {
|
|
238
246
|
if (!isFalsy(hidePanel)) this.hidePanel = hidePanel;
|
|
239
247
|
if (!isFalsy(showPanel)) this.showPanel = showPanel;
|
|
240
248
|
if (!isFalsy(openChat)) this.openChat = openChat;
|
|
241
249
|
if (!isFalsy(ccToggleBottomSheet)) this.ccToggleBottomSheet = ccToggleBottomSheet;
|
|
242
250
|
if (!isFalsy(ccComposeMessage)) this.ccComposeMessage = ccComposeMessage;
|
|
251
|
+
// if (!isFalsy(ccMentionClick)) this.ccMentionClick = ccMentionClick;
|
|
252
|
+
if (!isFalsy(ccSuggestionData)) this.ccSuggestionData = ccSuggestionData;
|
|
243
253
|
}
|
|
244
254
|
}
|
|
245
255
|
export class GroupUIEventListener {
|
|
@@ -14,6 +14,8 @@ export enum CometChatUIEvents {
|
|
|
14
14
|
hidePanel = 'hidePanel',
|
|
15
15
|
openChat = 'openChat',
|
|
16
16
|
ccToggleBottomSheet = 'ccToggleBottomSheet',
|
|
17
|
-
ccComposeMessage = "ccComposeMessage"
|
|
17
|
+
ccComposeMessage = "ccComposeMessage",
|
|
18
|
+
// ccMentionClick = "ccMentionClick",
|
|
19
|
+
ccSuggestionData = "ccSuggestionData",
|
|
18
20
|
|
|
19
21
|
}
|