quickblox-react-ui-kit 0.2.3 → 0.2.5
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/README.md +3 -2
- package/dist/CommonTypes/FunctionResult.d.ts +5 -1
- package/dist/Data/DefaultConfigurations.d.ts +2 -2
- package/dist/Data/repository/DialogsRepository.d.ts +1 -0
- package/dist/Data/repository/EventMessagesRepository.d.ts +1 -0
- package/dist/Data/repository/MessagesRepository.d.ts +2 -2
- package/dist/Domain/entity/NotificationTypes.d.ts +1 -0
- package/dist/Domain/repository/IDialogsRepository.d.ts +1 -0
- package/dist/Domain/repository/IMessagesRepository.d.ts +2 -2
- package/dist/Domain/use_cases/CreateDialogUseCase.d.ts +2 -1
- package/dist/Domain/use_cases/LeaveDialogUseCase.d.ts +2 -1
- package/dist/Domain/use_cases/RemoveUsersFromTheDialogUseCase.d.ts +2 -1
- package/dist/Domain/use_cases/SubscribeToDialogEventsUseCase.d.ts +1 -0
- package/dist/Domain/use_cases/UpdateDialogUseCase.d.ts +2 -1
- package/dist/Domain/use_cases/ai/AIAnswerAssistUseCase.d.ts +13 -0
- package/dist/Domain/use_cases/ai/AIAnswerAssistWithProxyUseCase.d.ts +13 -0
- package/dist/Domain/use_cases/ai/AITranslateUseCase.d.ts +14 -0
- package/dist/Domain/use_cases/ai/AITranslateWithProxyUseCase.d.ts +14 -0
- package/dist/Presentation/Views/Base/BaseViewModel.d.ts +3 -0
- package/dist/Presentation/components/UI/Dialogs/MessagesView/AIWidgets/AIMessageWidget.d.ts +4 -1
- package/dist/Presentation/components/UI/Dialogs/MessagesView/AIWidgets/AIWidgetActions/AIWidgetActions.d.ts +3 -2
- package/dist/Presentation/components/UI/Dialogs/MessagesView/AIWidgets/Tone.d.ts +5 -13
- package/dist/Presentation/components/UI/Dialogs/MessagesView/DefaultAttachmentComponent/DefaultAttachmentComponent.d.ts +8 -0
- package/dist/Presentation/components/UI/Dialogs/MessagesView/ErrorToast/ErrorToast.d.ts +7 -0
- package/dist/Presentation/components/UI/Dialogs/MessagesView/InComingMessage/AvatarContentIncomingUser/AvatarContentIncomingUser.d.ts +3 -0
- package/dist/Presentation/components/UI/Dialogs/MessagesView/InComingMessage/InComingMessage.d.ts +12 -3
- package/dist/Presentation/components/UI/Dialogs/MessagesView/MessagesView.d.ts +10 -0
- package/dist/Presentation/components/UI/Dialogs/MessagesView/MessagesViewModel.d.ts +2 -2
- package/dist/Presentation/components/UI/Dialogs/MessagesView/SystemDateBanner/SystemDateBanner.d.ts +7 -0
- package/dist/Presentation/components/UI/Dialogs/MessagesView/SystemMessageBanner/SystemMessageBanner.d.ts +7 -0
- package/dist/Presentation/components/UI/Dialogs/PreviewDialog/PreviewAudioFile/PreviewAudioFile.d.ts +7 -0
- package/dist/Presentation/components/UI/Dialogs/PreviewDialog/PreviewDefaultFile/PreviewDefaultFile.d.ts +7 -0
- package/dist/Presentation/components/UI/Dialogs/PreviewDialog/PreviewImageFile/PreviewImageFile.d.ts +8 -0
- package/dist/Presentation/components/UI/Dialogs/PreviewDialog/PreviewVideoFile/PreviewVideoFile.d.ts +7 -0
- package/dist/Presentation/components/UI/svgs/Icons/AIWidgets/BotIcon/BotIcon.d.ts +4 -0
- package/dist/QBconfig.d.ts +14 -3
- package/dist/index-ui.d.ts +5 -1
- package/dist/index-ui.js +410 -61
- package/dist/utils/utils.d.ts +9 -0
- package/global.d.ts +12 -4
- package/package.json +5 -1
- package/src/App.tsx +1 -1
- package/src/CommonTypes/FunctionResult.ts +6 -1
- package/src/Data/DefaultConfigurations.ts +155 -19
- package/src/Data/repository/DialogsRepository.ts +4 -0
- package/src/Data/repository/EventMessagesRepository.ts +34 -0
- package/src/Data/repository/MessagesRepository.ts +16 -10
- package/src/Data/source/exception/MapperDTOException.ts +3 -0
- package/src/Data/source/remote/RemoteDataSource.ts +134 -112
- package/src/Domain/entity/NotificationTypes.ts +2 -0
- package/src/Domain/repository/IDialogsRepository.ts +2 -0
- package/src/Domain/repository/IMessagesRepository.ts +2 -2
- package/src/Domain/use_cases/CreateDialogUseCase.ts +8 -1
- package/src/Domain/use_cases/GetAllDialogsUseCaseWithMock.ts +1 -0
- package/src/Domain/use_cases/LeaveDialogUseCase.ts +8 -1
- package/src/Domain/use_cases/RemoveUsersFromTheDialogUseCase.ts +40 -17
- package/src/Domain/use_cases/SendTextMessageUseCase.ts +3 -2
- package/src/Domain/use_cases/SubscribeToDialogEventsUseCase.ts +21 -0
- package/src/Domain/use_cases/UpdateDialogUseCase.ts +8 -1
- package/src/Domain/use_cases/ai/AIAnswerAssistUseCase.ts +69 -0
- package/src/Domain/use_cases/ai/AIAnswerAssistWithProxyUseCase.ts +71 -0
- package/src/Domain/use_cases/ai/AIRephraseUseCase.ts +38 -36
- package/src/Domain/use_cases/ai/AIRephraseWithProxyUseCase.ts +25 -21
- package/src/Domain/use_cases/ai/AITranslateUseCase.ts +76 -0
- package/src/Domain/use_cases/ai/AITranslateWithProxyUseCase.ts +79 -0
- package/src/Domain/use_cases/base/Subscribable/SubscriptionPerformer.ts +7 -10
- package/src/Presentation/Views/Base/BaseViewModel.ts +3 -0
- package/src/Presentation/Views/Dialogs/Dialogs.scss +3 -0
- package/src/Presentation/Views/Dialogs/Dialogs.tsx +1 -1
- package/src/Presentation/Views/Dialogs/useDialogsViewModel.ts +109 -48
- package/src/Presentation/assets/styles/_variables.scss +19 -0
- package/src/Presentation/components/UI/Buttons/MainButton/MainButton.scss +9 -0
- package/src/Presentation/components/UI/Dialogs/EditDialog/EditDialog.scss +3 -0
- package/src/Presentation/components/UI/Dialogs/InviteMembers/InviteMembers.scss +3 -0
- package/src/Presentation/components/UI/Dialogs/MembersList/MembersList.scss +3 -0
- package/src/Presentation/components/UI/Dialogs/MessagesView/AIWidgets/AIMessageWidget.ts +7 -2
- package/src/Presentation/components/UI/Dialogs/MessagesView/AIWidgets/AIWidgetActions/AIWidgetActions.tsx +10 -4
- package/src/Presentation/components/UI/Dialogs/MessagesView/AIWidgets/Tone.ts +29 -15
- package/src/Presentation/components/UI/Dialogs/MessagesView/AIWidgets/UseDefaultAIAssistAnswerWidget.tsx +10 -6
- package/src/Presentation/components/UI/Dialogs/MessagesView/AIWidgets/UseDefaultAIAssistAnswerWidgetWithProxy.tsx +10 -6
- package/src/Presentation/components/UI/Dialogs/MessagesView/AIWidgets/UseDefaultAIRephraseMessageWidget.tsx +17 -0
- package/src/Presentation/components/UI/Dialogs/MessagesView/AIWidgets/UseDefaultAIRephraseMessageWidgetWithProxy.tsx +16 -0
- package/src/Presentation/components/UI/Dialogs/MessagesView/AIWidgets/UseDefaultAITranslateWidget.tsx +13 -12
- package/src/Presentation/components/UI/Dialogs/MessagesView/AIWidgets/UseDefaultAITranslateWidgetWithProxy.tsx +13 -12
- package/src/Presentation/components/UI/Dialogs/MessagesView/AudioAttachmentComponent/AudioAttachmentComponent.tsx +1 -1
- package/src/Presentation/components/UI/Dialogs/MessagesView/DefaultAttachmentComponent/DefaultAttachmentComponent.scss +76 -0
- package/src/Presentation/components/UI/Dialogs/MessagesView/DefaultAttachmentComponent/DefaultAttachmentComponent.tsx +40 -0
- package/src/Presentation/components/UI/Dialogs/MessagesView/ErrorToast/ErrorToast.scss +26 -0
- package/src/Presentation/components/UI/Dialogs/MessagesView/ErrorToast/ErrorToast.tsx +25 -0
- package/src/Presentation/components/UI/Dialogs/MessagesView/ImageAttachmentComponent/ImageAttachmentComponent.tsx +8 -6
- package/src/Presentation/components/UI/Dialogs/MessagesView/InComingMessage/AvatarContentIncomingUser/AvatarContentIncomingUser.tsx +6 -0
- package/src/Presentation/components/UI/Dialogs/MessagesView/InComingMessage/InComingMessage.scss +5 -7
- package/src/Presentation/components/UI/Dialogs/MessagesView/InComingMessage/InComingMessage.tsx +138 -405
- package/src/Presentation/components/UI/Dialogs/MessagesView/MessagesView.scss +14 -26
- package/src/Presentation/components/UI/Dialogs/MessagesView/MessagesView.tsx +658 -429
- package/src/Presentation/components/UI/Dialogs/MessagesView/MessagesViewModel.ts +2 -2
- package/src/Presentation/components/UI/Dialogs/MessagesView/OutGoingMessage/OutGoingMessage.tsx +1 -1
- package/src/Presentation/components/UI/Dialogs/MessagesView/SystemDateBanner/SystemDateBanner.scss +23 -0
- package/src/Presentation/components/UI/Dialogs/MessagesView/SystemDateBanner/SystemDateBanner.tsx +17 -0
- package/src/Presentation/components/UI/Dialogs/MessagesView/SystemMessageBanner/SystemMessageBanner.scss +21 -0
- package/src/Presentation/components/UI/Dialogs/MessagesView/SystemMessageBanner/SystemMessageBanner.tsx +17 -0
- package/src/Presentation/components/UI/Dialogs/MessagesView/useMessagesViewModel.ts +124 -83
- package/src/Presentation/components/UI/Dialogs/PreviewDialog/PreviewAudioFile/PreviewAudioFile.scss +62 -0
- package/src/Presentation/components/UI/Dialogs/PreviewDialog/PreviewAudioFile/PreviewAudioFile.tsx +25 -0
- package/src/Presentation/components/UI/Dialogs/PreviewDialog/PreviewDefaultFile/PreviewDefaultFile.scss +61 -0
- package/src/Presentation/components/UI/Dialogs/PreviewDialog/PreviewDefaultFile/PreviewDefaultFile.tsx +32 -0
- package/src/Presentation/components/UI/Dialogs/PreviewDialog/PreviewDialog.scss +29 -3
- package/src/Presentation/components/UI/Dialogs/PreviewDialog/PreviewDialog.tsx +55 -4
- package/src/Presentation/components/UI/Dialogs/PreviewDialog/PreviewImageFile/PreviewImageFile.scss +40 -0
- package/src/Presentation/components/UI/Dialogs/PreviewDialog/PreviewImageFile/PreviewImageFile.tsx +26 -0
- package/src/Presentation/components/UI/Dialogs/PreviewDialog/PreviewVideoFile/PreviewVideoFile.scss +62 -0
- package/src/Presentation/components/UI/Dialogs/PreviewDialog/PreviewVideoFile/PreviewVideoFile.tsx +25 -0
- package/src/Presentation/components/UI/svgs/Icons/AIWidgets/BotIcon/BotIcon.svg +5 -0
- package/src/Presentation/components/UI/svgs/Icons/AIWidgets/BotIcon/BotIcon.tsx +50 -0
- package/src/Presentation/components/layouts/Desktop/QuickBloxUIKitDesktopLayout.tsx +3 -15
- package/src/Presentation/components/providers/QuickBloxUIKitProvider/useQbInitializedDataContext.ts +15 -14
- package/src/QBconfig.ts +156 -10
- package/src/index-ui.ts +8 -1
- package/src/index.scss +0 -1
- package/src/package_artan_react_ui.json +13 -9
- package/src/package_original.json +5 -1
- package/src/utils/utils.ts +63 -0
- package/src/Presentation/assets/styles/_reset-styles.scss +0 -435
package/src/Presentation/components/UI/Dialogs/MessagesView/InComingMessage/InComingMessage.tsx
CHANGED
|
@@ -15,30 +15,44 @@ import ImageFile from '../../../svgs/Icons/Media/ImageFile';
|
|
|
15
15
|
import ColumnContainer from '../../../../containers/ColumnContainer/ColumnContainer';
|
|
16
16
|
import { HighLightLink, messageHasUrls } from '../HighLightLink/HighLightLink';
|
|
17
17
|
import { AIMessageWidget } from '../AIWidgets/AIMessageWidget';
|
|
18
|
-
import { loopToLimitTokens } from '../../../../../../utils/utils';
|
|
19
18
|
import LoaderComponent from '../../../Placeholders/LoaderComponent/LoaderComponent';
|
|
20
|
-
import { IChatMessage } from '../../../../../../Data/source/AISource';
|
|
21
|
-
import AssistAnswer from '../../../svgs/Icons/Actions/AssistAnswer';
|
|
22
19
|
import AIWidgetActions from '../AIWidgets/AIWidgetActions/AIWidgetActions';
|
|
23
20
|
import TranslateIcon from '../../../svgs/Icons/Media/Translate';
|
|
24
|
-
import AvatarContentIncomingUser
|
|
21
|
+
import AvatarContentIncomingUser, {
|
|
22
|
+
AvatarContentIncomingUserProps,
|
|
23
|
+
} from './AvatarContentIncomingUser/AvatarContentIncomingUser';
|
|
25
24
|
import { DefaultConfigurations } from '../../../../../../Data/DefaultConfigurations';
|
|
25
|
+
import useQbInitializedDataContext from '../../../../providers/QuickBloxUIKitProvider/useQbInitializedDataContext';
|
|
26
|
+
import { AIUtils } from '../../../../../../utils/utils';
|
|
27
|
+
import BotIcon from '../../../svgs/Icons/AIWidgets/BotIcon/BotIcon';
|
|
28
|
+
import { UserEntity } from '../../../../../../Domain/entity/UserEntity';
|
|
29
|
+
import DefaultAttachmentComponent from '../DefaultAttachmentComponent/DefaultAttachmentComponent';
|
|
30
|
+
|
|
31
|
+
export type GetUserNameFct = (props: {
|
|
32
|
+
userId?: number;
|
|
33
|
+
sender?: UserEntity;
|
|
34
|
+
}) => Promise<string | undefined>;
|
|
26
35
|
|
|
27
36
|
export function InComingMessage(props: {
|
|
28
37
|
theme: UiKitTheme | undefined;
|
|
29
|
-
|
|
38
|
+
senderNameFct: GetUserNameFct;
|
|
30
39
|
message: MessageEntity;
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
40
|
+
onStartLoader: () => void;
|
|
41
|
+
// eslint-disable-next-line react/no-unused-prop-types
|
|
42
|
+
onStopLoader: () => void;
|
|
43
|
+
onErrorToast: (messageError: string) => void;
|
|
34
44
|
currentUserId?: number;
|
|
35
45
|
messagesToView: MessageEntity[];
|
|
36
46
|
AITranslation?: AIMessageWidget;
|
|
37
47
|
AIAnswerToMessage?: AIMessageWidget;
|
|
48
|
+
userIconRenderer?: (
|
|
49
|
+
props: AvatarContentIncomingUserProps,
|
|
50
|
+
) => React.ReactElement;
|
|
38
51
|
// index?: number;
|
|
39
52
|
// updateData?: (index: number, text: string) => void;
|
|
40
53
|
// translationDATA?: Record<number, string>;
|
|
41
54
|
}) {
|
|
55
|
+
const currentContext = useQbInitializedDataContext();
|
|
42
56
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
43
57
|
const [haveHover, setHaveHover] = useState(false);
|
|
44
58
|
// const [openMenu, setOpenMenu] = useState(false);
|
|
@@ -47,21 +61,29 @@ export function InComingMessage(props: {
|
|
|
47
61
|
useState<boolean>(false);
|
|
48
62
|
const [widgetTextContent, setWidgetTextContent] = useState<string>('');
|
|
49
63
|
const [originalTextMessage, setOriginalTextMessage] = useState<boolean>(true);
|
|
64
|
+
const [senderName, setSenderName] = useState<string | undefined>('');
|
|
65
|
+
|
|
66
|
+
useEffect(() => {
|
|
67
|
+
props
|
|
68
|
+
.senderNameFct({
|
|
69
|
+
userId: props.message.sender_id,
|
|
70
|
+
sender: props.message.sender,
|
|
71
|
+
})
|
|
72
|
+
// eslint-disable-next-line promise/always-return
|
|
73
|
+
.then((name) => {
|
|
74
|
+
setSenderName(name);
|
|
75
|
+
})
|
|
76
|
+
.catch(() => console.log(`unexpected error: `));
|
|
77
|
+
}, [props.message.sender_id]);
|
|
78
|
+
|
|
50
79
|
// const [errorAITranslate, setErrorAITranslate] = useState<boolean>(false);
|
|
51
80
|
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
// setMessageTextState(props.AIRephraseMessage?.textToContent);
|
|
59
|
-
// setWidgetTextContent(props.AIRephraseMessage?.textToContent);
|
|
60
|
-
// setTimeout(() => {
|
|
61
|
-
// setWidgetTextContent('');
|
|
62
|
-
// }, 45 * 1000);
|
|
63
|
-
// }
|
|
64
|
-
// }, [props.AIRephraseMessage?.textToContent]);
|
|
81
|
+
const maxTokensForAITranslate =
|
|
82
|
+
currentContext.InitParams.qbConfig.configAIApi.AITranslateWidgetConfig
|
|
83
|
+
.maxTokens;
|
|
84
|
+
const maxTokensForAnswerAssist =
|
|
85
|
+
currentContext.InitParams.qbConfig.configAIApi.AIAnswerAssistWidgetConfig
|
|
86
|
+
.maxTokens;
|
|
65
87
|
|
|
66
88
|
useEffect(() => {
|
|
67
89
|
setWaitAIWidget(false);
|
|
@@ -91,14 +113,18 @@ export function InComingMessage(props: {
|
|
|
91
113
|
{!originalTextMessage ? (
|
|
92
114
|
<div>{widgetTextContent}</div>
|
|
93
115
|
) : (
|
|
94
|
-
<div>{mc.message}</div>
|
|
116
|
+
<div className="message-in-a-single-line">{mc.message}</div>
|
|
95
117
|
)}
|
|
96
118
|
</div>
|
|
97
119
|
);
|
|
98
120
|
let messageContent: JSX.Element = messageText;
|
|
99
|
-
|
|
100
121
|
const attachmentContentRender = (att: ChatMessageAttachmentEntity) => {
|
|
101
|
-
let contentPlaceHolder: JSX.Element =
|
|
122
|
+
let contentPlaceHolder: JSX.Element = (
|
|
123
|
+
<DefaultAttachmentComponent
|
|
124
|
+
fileName={att.file?.name || ''}
|
|
125
|
+
fileUrl={att.file?.url || ''}
|
|
126
|
+
/>
|
|
127
|
+
);
|
|
102
128
|
|
|
103
129
|
if (att.type.toString().includes(FileType.video)) {
|
|
104
130
|
contentPlaceHolder = att.file ? (
|
|
@@ -123,9 +149,13 @@ export function InComingMessage(props: {
|
|
|
123
149
|
}
|
|
124
150
|
if (att.type.toString().includes(FileType.text)) {
|
|
125
151
|
contentPlaceHolder = att.file ? (
|
|
126
|
-
<div>TEXT</div>
|
|
152
|
+
// <div>TEXT</div>
|
|
153
|
+
<DefaultAttachmentComponent
|
|
154
|
+
fileName={att.file?.name || ''}
|
|
155
|
+
fileUrl={att.file?.url || ''}
|
|
156
|
+
/>
|
|
127
157
|
) : (
|
|
128
|
-
<ImageFile applyZoom />
|
|
158
|
+
<ImageFile width="24" height="24" applyZoom />
|
|
129
159
|
);
|
|
130
160
|
}
|
|
131
161
|
let contentResult: JSX.Element = (
|
|
@@ -157,7 +187,6 @@ export function InComingMessage(props: {
|
|
|
157
187
|
{mc.attachments.map((attachment) =>
|
|
158
188
|
attachmentContentRender(attachment),
|
|
159
189
|
)}
|
|
160
|
-
{messageText}
|
|
161
190
|
</ColumnContainer>
|
|
162
191
|
);
|
|
163
192
|
}
|
|
@@ -172,32 +201,6 @@ export function InComingMessage(props: {
|
|
|
172
201
|
return messageContent;
|
|
173
202
|
};
|
|
174
203
|
|
|
175
|
-
const messageEntitiesToIChatMessageCollection = (
|
|
176
|
-
messageEntities: MessageEntity[],
|
|
177
|
-
currentUserId?: number,
|
|
178
|
-
): IChatMessage[] => {
|
|
179
|
-
const MAX_TOKENS = 3584;
|
|
180
|
-
const items = messageEntities.filter(
|
|
181
|
-
(it) =>
|
|
182
|
-
!it.notification_type ||
|
|
183
|
-
(it.notification_type && it.notification_type.length === 0),
|
|
184
|
-
);
|
|
185
|
-
const messages = loopToLimitTokens(
|
|
186
|
-
MAX_TOKENS,
|
|
187
|
-
items,
|
|
188
|
-
({ message }) => message || '',
|
|
189
|
-
).reverse();
|
|
190
|
-
const chatCompletionMessages: IChatMessage[] = messages.map(
|
|
191
|
-
({ message, sender_id }) => ({
|
|
192
|
-
role: sender_id === currentUserId ? 'user' : 'assistant',
|
|
193
|
-
content: message,
|
|
194
|
-
}),
|
|
195
|
-
);
|
|
196
|
-
|
|
197
|
-
//
|
|
198
|
-
return chatCompletionMessages;
|
|
199
|
-
};
|
|
200
|
-
|
|
201
204
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
202
205
|
async function sendMessageToTranslate(
|
|
203
206
|
message: MessageEntity,
|
|
@@ -206,31 +209,37 @@ export function InComingMessage(props: {
|
|
|
206
209
|
AITranslation?: AIMessageWidget,
|
|
207
210
|
selectedLanguage?: string,
|
|
208
211
|
) {
|
|
209
|
-
// setErrorAITranslate(false);
|
|
210
212
|
if (!waitAITranslateWidget) {
|
|
211
213
|
setWaitAITranslateWidget(true);
|
|
212
214
|
await AITranslation?.textToWidget(
|
|
213
215
|
message.message,
|
|
214
|
-
|
|
216
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument,@typescript-eslint/no-unsafe-call
|
|
217
|
+
AIUtils.messageEntitiesToIChatMessageCollection(
|
|
218
|
+
messagesToView,
|
|
219
|
+
currentUserId,
|
|
220
|
+
maxTokensForAITranslate,
|
|
221
|
+
),
|
|
215
222
|
{
|
|
216
223
|
language:
|
|
217
224
|
selectedLanguage ||
|
|
218
|
-
DefaultConfigurations.getDefaultLanguageForAITranslate(
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
// 'English',
|
|
225
|
+
DefaultConfigurations.getDefaultLanguageForAITranslate(
|
|
226
|
+
currentContext.InitParams.qbConfig.configAIApi
|
|
227
|
+
.AITranslateWidgetConfig,
|
|
228
|
+
),
|
|
223
229
|
},
|
|
224
230
|
)
|
|
225
231
|
.then((textTranslate) => {
|
|
226
232
|
// eslint-disable-next-line promise/always-return
|
|
227
233
|
setWidgetTextContent(textTranslate || '');
|
|
234
|
+
// eslint-disable-next-line promise/always-return
|
|
235
|
+
if (textTranslate === 'Translation failed.') {
|
|
236
|
+
props.onErrorToast('Translation failed.');
|
|
237
|
+
}
|
|
228
238
|
setWaitAITranslateWidget(false);
|
|
229
239
|
setOriginalTextMessage(false);
|
|
230
240
|
})
|
|
231
241
|
.catch(() => {
|
|
232
|
-
|
|
233
|
-
// setErrorAITranslate(true);
|
|
242
|
+
props.onErrorToast('Translation failed.');
|
|
234
243
|
setWaitAITranslateWidget(false);
|
|
235
244
|
setOriginalTextMessage(true);
|
|
236
245
|
});
|
|
@@ -249,11 +258,16 @@ export function InComingMessage(props: {
|
|
|
249
258
|
) {
|
|
250
259
|
if (!waitAIWidget) {
|
|
251
260
|
setWaitAIWidget(true);
|
|
252
|
-
props.
|
|
261
|
+
props.onStartLoader();
|
|
253
262
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-call
|
|
254
263
|
AIAnswerToMessage?.textToWidget(
|
|
255
264
|
message.message,
|
|
256
|
-
|
|
265
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument,@typescript-eslint/no-unsafe-call
|
|
266
|
+
AIUtils.messageEntitiesToIChatMessageCollection(
|
|
267
|
+
messagesToView,
|
|
268
|
+
currentUserId,
|
|
269
|
+
maxTokensForAnswerAssist,
|
|
270
|
+
),
|
|
257
271
|
);
|
|
258
272
|
}
|
|
259
273
|
}
|
|
@@ -270,17 +284,23 @@ export function InComingMessage(props: {
|
|
|
270
284
|
<div className="caption2">
|
|
271
285
|
<div
|
|
272
286
|
className="ai-translate-action"
|
|
287
|
+
style={{
|
|
288
|
+
cursor: !waitAITranslateWidget ? 'pointer' : '',
|
|
289
|
+
}}
|
|
273
290
|
onClick={() => {
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
291
|
+
console.log('click translate....');
|
|
292
|
+
if (!waitAITranslateWidget) {
|
|
293
|
+
if (originalTextMessage) {
|
|
294
|
+
sendMessageToTranslate(
|
|
295
|
+
mc,
|
|
296
|
+
messagesToView,
|
|
297
|
+
currentUserId,
|
|
298
|
+
AITranslate,
|
|
299
|
+
);
|
|
300
|
+
} else {
|
|
301
|
+
setOriginalTextMessage(true);
|
|
302
|
+
setWidgetTextContent('');
|
|
303
|
+
}
|
|
284
304
|
}
|
|
285
305
|
}}
|
|
286
306
|
>
|
|
@@ -288,8 +308,14 @@ export function InComingMessage(props: {
|
|
|
288
308
|
</div>
|
|
289
309
|
</div>
|
|
290
310
|
<AIWidgetActions
|
|
311
|
+
disabled={!waitAITranslateWidget}
|
|
291
312
|
widgetToRender={
|
|
292
|
-
<div
|
|
313
|
+
<div
|
|
314
|
+
className="icon-translate"
|
|
315
|
+
style={{
|
|
316
|
+
cursor: !waitAITranslateWidget ? 'pointer' : '',
|
|
317
|
+
}}
|
|
318
|
+
>
|
|
293
319
|
<TranslateIcon
|
|
294
320
|
width="16"
|
|
295
321
|
height="16"
|
|
@@ -298,11 +324,15 @@ export function InComingMessage(props: {
|
|
|
298
324
|
/>
|
|
299
325
|
</div>
|
|
300
326
|
}
|
|
301
|
-
items={DefaultConfigurations.getAdditionalLanguagesForAITranslate(
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
327
|
+
items={DefaultConfigurations.getAdditionalLanguagesForAITranslate(
|
|
328
|
+
currentContext.InitParams.qbConfig.configAIApi
|
|
329
|
+
.AITranslateWidgetConfig,
|
|
330
|
+
).map((item) => {
|
|
331
|
+
return {
|
|
332
|
+
title: item,
|
|
333
|
+
action: () => {
|
|
334
|
+
console.log('click translate....');
|
|
335
|
+
if (!waitAITranslateWidget) {
|
|
306
336
|
sendMessageToTranslate(
|
|
307
337
|
mc,
|
|
308
338
|
messagesToView,
|
|
@@ -310,204 +340,12 @@ export function InComingMessage(props: {
|
|
|
310
340
|
AITranslate,
|
|
311
341
|
item,
|
|
312
342
|
);
|
|
313
|
-
}
|
|
314
|
-
}
|
|
315
|
-
}
|
|
316
|
-
)}
|
|
317
|
-
// items={[
|
|
318
|
-
// {
|
|
319
|
-
// title: 'English',
|
|
320
|
-
// // eslint-disable-next-line @typescript-eslint/no-empty-function
|
|
321
|
-
// action: () => {
|
|
322
|
-
// sendMessageToTranslate(
|
|
323
|
-
// mc,
|
|
324
|
-
// messagesToView,
|
|
325
|
-
// currentUserId,
|
|
326
|
-
// AITranslation,
|
|
327
|
-
// 'English',
|
|
328
|
-
// );
|
|
329
|
-
// },
|
|
330
|
-
// },
|
|
331
|
-
// {
|
|
332
|
-
// title: 'Ukrainian',
|
|
333
|
-
// action: () => {
|
|
334
|
-
// sendMessageToTranslate(
|
|
335
|
-
// mc,
|
|
336
|
-
// messagesToView,
|
|
337
|
-
// currentUserId,
|
|
338
|
-
// AITranslation,
|
|
339
|
-
// 'Ukrainian',
|
|
340
|
-
// );
|
|
341
|
-
// },
|
|
342
|
-
// },
|
|
343
|
-
// {
|
|
344
|
-
// title: 'Spanish',
|
|
345
|
-
// action: () => {
|
|
346
|
-
// sendMessageToTranslate(
|
|
347
|
-
// mc,
|
|
348
|
-
// messagesToView,
|
|
349
|
-
// currentUserId,
|
|
350
|
-
// AITranslation,
|
|
351
|
-
// 'Spanish',
|
|
352
|
-
// );
|
|
353
|
-
// },
|
|
354
|
-
// },
|
|
355
|
-
// {
|
|
356
|
-
// title: 'Portuguese',
|
|
357
|
-
// action: () => {
|
|
358
|
-
// sendMessageToTranslate(
|
|
359
|
-
// mc,
|
|
360
|
-
// messagesToView,
|
|
361
|
-
// currentUserId,
|
|
362
|
-
// AITranslation,
|
|
363
|
-
// 'Portuguese',
|
|
364
|
-
// );
|
|
365
|
-
// },
|
|
366
|
-
// },
|
|
367
|
-
// {
|
|
368
|
-
// title: 'French',
|
|
369
|
-
// action: () => {
|
|
370
|
-
// sendMessageToTranslate(
|
|
371
|
-
// mc,
|
|
372
|
-
// messagesToView,
|
|
373
|
-
// currentUserId,
|
|
374
|
-
// AITranslation,
|
|
375
|
-
// 'French',
|
|
376
|
-
// );
|
|
377
|
-
// },
|
|
378
|
-
// },
|
|
379
|
-
// // {
|
|
380
|
-
// // title: 'German',
|
|
381
|
-
// // action: () => {},
|
|
382
|
-
// // },
|
|
383
|
-
// ]}
|
|
343
|
+
}
|
|
344
|
+
},
|
|
345
|
+
};
|
|
346
|
+
})}
|
|
384
347
|
/>
|
|
385
348
|
</div>
|
|
386
|
-
// <div className="widget-ai-translate-with-choice-languages-container">
|
|
387
|
-
// <div
|
|
388
|
-
// className="widget-ai-translate-with-choice-languages-container--default-language"
|
|
389
|
-
// onClick={() => {
|
|
390
|
-
// if (originalTextMessage) {
|
|
391
|
-
// sendMessageToTranslate(
|
|
392
|
-
// mc,
|
|
393
|
-
// messagesToView,
|
|
394
|
-
// currentUserId,
|
|
395
|
-
// AITranslation,
|
|
396
|
-
// );
|
|
397
|
-
// } else {
|
|
398
|
-
// setOriginalTextMessage(true);
|
|
399
|
-
// setWidgetTextContent('');
|
|
400
|
-
// }
|
|
401
|
-
// }}
|
|
402
|
-
// >
|
|
403
|
-
// {originalTextMessage ? 'Show translation' : 'Show original'}
|
|
404
|
-
// </div>
|
|
405
|
-
// <div className="widget-ai-translate-with-choice-languages-container--separator">
|
|
406
|
-
// {' '}
|
|
407
|
-
// </div>
|
|
408
|
-
// <div className="widget-ai-translate-with-choice-languages-container--select-language">
|
|
409
|
-
// <AIWidgetActions
|
|
410
|
-
// widgetToRender={
|
|
411
|
-
// <AIWidgetIcon
|
|
412
|
-
// applyZoom
|
|
413
|
-
// color="var(--main-elements)"
|
|
414
|
-
// width="16"
|
|
415
|
-
// height="16"
|
|
416
|
-
// />
|
|
417
|
-
// }
|
|
418
|
-
// items={[
|
|
419
|
-
// {
|
|
420
|
-
// title: 'English',
|
|
421
|
-
// // eslint-disable-next-line @typescript-eslint/no-empty-function
|
|
422
|
-
// action: () => {
|
|
423
|
-
// sendMessageToTranslate(
|
|
424
|
-
// mc,
|
|
425
|
-
// messagesToView,
|
|
426
|
-
// currentUserId,
|
|
427
|
-
// AITranslation,
|
|
428
|
-
// 'English',
|
|
429
|
-
// );
|
|
430
|
-
// },
|
|
431
|
-
// },
|
|
432
|
-
// {
|
|
433
|
-
// title: 'Ukrainian',
|
|
434
|
-
// action: () => {
|
|
435
|
-
// sendMessageToTranslate(
|
|
436
|
-
// mc,
|
|
437
|
-
// messagesToView,
|
|
438
|
-
// currentUserId,
|
|
439
|
-
// AITranslation,
|
|
440
|
-
// 'Ukrainian',
|
|
441
|
-
// );
|
|
442
|
-
// },
|
|
443
|
-
// },
|
|
444
|
-
// {
|
|
445
|
-
// title: 'Spanish',
|
|
446
|
-
// action: () => {
|
|
447
|
-
// sendMessageToTranslate(
|
|
448
|
-
// mc,
|
|
449
|
-
// messagesToView,
|
|
450
|
-
// currentUserId,
|
|
451
|
-
// AITranslation,
|
|
452
|
-
// 'Spanish',
|
|
453
|
-
// );
|
|
454
|
-
// },
|
|
455
|
-
// },
|
|
456
|
-
// {
|
|
457
|
-
// title: 'Portuguese',
|
|
458
|
-
// action: () => {
|
|
459
|
-
// sendMessageToTranslate(
|
|
460
|
-
// mc,
|
|
461
|
-
// messagesToView,
|
|
462
|
-
// currentUserId,
|
|
463
|
-
// AITranslation,
|
|
464
|
-
// 'Portuguese',
|
|
465
|
-
// );
|
|
466
|
-
// },
|
|
467
|
-
// },
|
|
468
|
-
// {
|
|
469
|
-
// title: 'French',
|
|
470
|
-
// action: () => {
|
|
471
|
-
// sendMessageToTranslate(
|
|
472
|
-
// mc,
|
|
473
|
-
// messagesToView,
|
|
474
|
-
// currentUserId,
|
|
475
|
-
// AITranslation,
|
|
476
|
-
// 'French',
|
|
477
|
-
// );
|
|
478
|
-
// },
|
|
479
|
-
// },
|
|
480
|
-
// // {
|
|
481
|
-
// // title: 'German',
|
|
482
|
-
// // action: () => {},
|
|
483
|
-
// // },
|
|
484
|
-
// ]}
|
|
485
|
-
// />
|
|
486
|
-
// </div>
|
|
487
|
-
// {waitAITranslateWidget && (
|
|
488
|
-
// <div
|
|
489
|
-
// className="widget-ai-translate-with-choice-languages-container--separator"
|
|
490
|
-
// style={{
|
|
491
|
-
// height: '16px',
|
|
492
|
-
// width: '16px',
|
|
493
|
-
// }}
|
|
494
|
-
// >
|
|
495
|
-
// <LoaderComponent
|
|
496
|
-
// width="16"
|
|
497
|
-
// height="16"
|
|
498
|
-
// color="var(--color-background-info)"
|
|
499
|
-
// />
|
|
500
|
-
// </div>
|
|
501
|
-
// )}
|
|
502
|
-
// {errorAITranslate && (
|
|
503
|
-
// <div className="widget-ai-translate-with-choice-languages-container--separator">
|
|
504
|
-
// <ErrorMessageIcon
|
|
505
|
-
// errorMessageText="OpenAI server does not response"
|
|
506
|
-
// errorsDescriptions={[]}
|
|
507
|
-
// />
|
|
508
|
-
// </div>
|
|
509
|
-
// )}
|
|
510
|
-
// </div>
|
|
511
349
|
)
|
|
512
350
|
);
|
|
513
351
|
};
|
|
@@ -520,9 +358,14 @@ export function InComingMessage(props: {
|
|
|
520
358
|
) => {
|
|
521
359
|
return (
|
|
522
360
|
AIAnswer && (
|
|
523
|
-
<div
|
|
361
|
+
<div
|
|
362
|
+
className="ai-assist-answer"
|
|
363
|
+
style={{
|
|
364
|
+
cursor: !waitAIWidget ? 'pointer' : '',
|
|
365
|
+
}}
|
|
366
|
+
>
|
|
524
367
|
<div
|
|
525
|
-
className="icon"
|
|
368
|
+
className="ai-assist-icon"
|
|
526
369
|
onClick={() =>
|
|
527
370
|
sendMessageToAIAssistAnswer(
|
|
528
371
|
mc,
|
|
@@ -541,11 +384,11 @@ export function InComingMessage(props: {
|
|
|
541
384
|
overflow: 'visible',
|
|
542
385
|
}}
|
|
543
386
|
>
|
|
544
|
-
<
|
|
387
|
+
<BotIcon
|
|
545
388
|
width="24"
|
|
546
|
-
height="
|
|
389
|
+
height="25"
|
|
547
390
|
applyZoom
|
|
548
|
-
color="var(--
|
|
391
|
+
color="var(--primary)"
|
|
549
392
|
/>
|
|
550
393
|
</div>
|
|
551
394
|
</div>
|
|
@@ -560,12 +403,17 @@ export function InComingMessage(props: {
|
|
|
560
403
|
onMouseEnter={() => setHaveHover(true)}
|
|
561
404
|
onMouseLeave={() => setHaveHover(false)}
|
|
562
405
|
>
|
|
563
|
-
|
|
406
|
+
{props.userIconRenderer ? (
|
|
407
|
+
props.userIconRenderer({ userId: props.message.sender_id })
|
|
408
|
+
) : (
|
|
409
|
+
// <AvatarContentIncomingUser userId={props.message.sender_id} />
|
|
410
|
+
<AvatarContentIncomingUser />
|
|
411
|
+
)}
|
|
564
412
|
<div className="incoming">
|
|
565
413
|
<div className="name">
|
|
566
414
|
<div className="caption">
|
|
567
415
|
<div className="name2">
|
|
568
|
-
{
|
|
416
|
+
{senderName || props.message.sender_id.toString()}
|
|
569
417
|
</div>
|
|
570
418
|
</div>
|
|
571
419
|
</div>
|
|
@@ -574,11 +422,13 @@ export function InComingMessage(props: {
|
|
|
574
422
|
<div className="chat-bubble-background">
|
|
575
423
|
{/* <div className="message-in-a-single-line"> */}
|
|
576
424
|
{/* </div> */}
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
425
|
+
<div className="message-in-a-single-line">
|
|
426
|
+
{messageContentRender(
|
|
427
|
+
props.message,
|
|
428
|
+
widgetTextContent,
|
|
429
|
+
props.theme,
|
|
430
|
+
)}
|
|
431
|
+
</div>
|
|
582
432
|
</div>
|
|
583
433
|
{renderWidgetAITranslate(
|
|
584
434
|
props.message,
|
|
@@ -626,122 +476,5 @@ export function InComingMessage(props: {
|
|
|
626
476
|
</div>
|
|
627
477
|
</div>
|
|
628
478
|
</div>
|
|
629
|
-
// <div
|
|
630
|
-
// className="message-view-container--incoming-message-wrapper"
|
|
631
|
-
// onMouseEnter={() => setHaveHover(true)}
|
|
632
|
-
// onMouseLeave={() => setHaveHover(false)}
|
|
633
|
-
// >
|
|
634
|
-
// <div className="message-view-container--incoming-message-wrapper__message">
|
|
635
|
-
// <div className="message-view-container--incoming-message-wrapper__avatar">
|
|
636
|
-
// <div
|
|
637
|
-
// style={
|
|
638
|
-
// props.theme
|
|
639
|
-
// ? { backgroundColor: props.theme.disabledElements() }
|
|
640
|
-
// : {}
|
|
641
|
-
// }
|
|
642
|
-
// className="message-view-container__sender-avatar"
|
|
643
|
-
// >
|
|
644
|
-
// <User
|
|
645
|
-
// width="24"
|
|
646
|
-
// height="24"
|
|
647
|
-
// applyZoom
|
|
648
|
-
// color="var(--secondary-text)"
|
|
649
|
-
// />
|
|
650
|
-
// </div>
|
|
651
|
-
// </div>
|
|
652
|
-
// <div className="message-view-container--incoming-message-container">
|
|
653
|
-
// <div
|
|
654
|
-
// style={props.theme ? { color: props.theme.secondaryText() } : {}}
|
|
655
|
-
// className="message-view-container__sender-name"
|
|
656
|
-
// >
|
|
657
|
-
// {props.senderName || props.message.sender_id.toString()}
|
|
658
|
-
// </div>
|
|
659
|
-
// <div
|
|
660
|
-
// style={
|
|
661
|
-
// props.theme
|
|
662
|
-
// ? {
|
|
663
|
-
// color: props.theme.mainText(),
|
|
664
|
-
// backgroundColor: props.theme.incomingBackground(),
|
|
665
|
-
// }
|
|
666
|
-
// : {}
|
|
667
|
-
// }
|
|
668
|
-
// className="message-view-container__sender-message"
|
|
669
|
-
// >
|
|
670
|
-
// {/* eslint-disable-next-line @typescript-eslint/no-unsafe-argument */}
|
|
671
|
-
// {messageContentRender(
|
|
672
|
-
// props.message,
|
|
673
|
-
// widgetTextContent,
|
|
674
|
-
// props.theme,
|
|
675
|
-
// )}
|
|
676
|
-
// </div>
|
|
677
|
-
// </div>
|
|
678
|
-
// {haveHover || openMenu ? (
|
|
679
|
-
// <div
|
|
680
|
-
// className="message-view-container--incoming-message-wrapper--context-menu"
|
|
681
|
-
// onClick={() => {
|
|
682
|
-
// setOpenMenu(!openMenu);
|
|
683
|
-
// }}
|
|
684
|
-
// >
|
|
685
|
-
// <EditDots
|
|
686
|
-
// color={
|
|
687
|
-
// props.theme
|
|
688
|
-
// ? props.theme.secondaryText()
|
|
689
|
-
// : 'var(--secondary-text)'
|
|
690
|
-
// }
|
|
691
|
-
// />
|
|
692
|
-
// {/* {openMenu ? ( */}
|
|
693
|
-
// {/* <DropDownMenu */}
|
|
694
|
-
// {/* items={contextMessageMenu} */}
|
|
695
|
-
// {/* itemsAI={contextMessageMenuAI} */}
|
|
696
|
-
// {/* /> */}
|
|
697
|
-
// {/* ) : null} */}
|
|
698
|
-
// </div>
|
|
699
|
-
// ) : (
|
|
700
|
-
// <div
|
|
701
|
-
// style={props.theme ? { color: props.theme.mainText() } : {}}
|
|
702
|
-
// className="message-view-container__incoming-time"
|
|
703
|
-
// >
|
|
704
|
-
// {getTimeShort24hFormat(props.message.date_sent)}
|
|
705
|
-
// </div>
|
|
706
|
-
// )}
|
|
707
|
-
//
|
|
708
|
-
// <div
|
|
709
|
-
// className="message-view-container__incoming-time"
|
|
710
|
-
// onClick={props.onClick}
|
|
711
|
-
// >
|
|
712
|
-
// {/* {props.renderWidget} */}
|
|
713
|
-
// {renderWidgetAIAssist(
|
|
714
|
-
// props.message,
|
|
715
|
-
// props.messagesToView,
|
|
716
|
-
// props.currentUserId,
|
|
717
|
-
// props.AITranslation,
|
|
718
|
-
// props.AIAnswerToMessage,
|
|
719
|
-
// )}
|
|
720
|
-
// </div>
|
|
721
|
-
// {waitAIWidget && (
|
|
722
|
-
// <div
|
|
723
|
-
// className="message-view-container__incoming-time"
|
|
724
|
-
// style={{
|
|
725
|
-
// height: '24px',
|
|
726
|
-
// width: '24px',
|
|
727
|
-
// }}
|
|
728
|
-
// >
|
|
729
|
-
// <LoaderComponent
|
|
730
|
-
// width="24"
|
|
731
|
-
// height="24"
|
|
732
|
-
// color="var(--color-background-info)"
|
|
733
|
-
// />
|
|
734
|
-
// </div>
|
|
735
|
-
// )}
|
|
736
|
-
// </div>
|
|
737
|
-
// <div className="message-view-container__widget-ai-translate">
|
|
738
|
-
// {renderWidgetAITranslate(
|
|
739
|
-
// props.message,
|
|
740
|
-
// props.messagesToView,
|
|
741
|
-
// props.currentUserId,
|
|
742
|
-
// props.AITranslation,
|
|
743
|
-
// )}
|
|
744
|
-
// </div>
|
|
745
|
-
// </div>
|
|
746
479
|
);
|
|
747
480
|
}
|