quickblox-react-ui-kit 0.2.4 → 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/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/Presentation/Views/Base/BaseViewModel.d.ts +1 -0
- package/dist/Presentation/components/UI/Dialogs/MessagesView/DefaultAttachmentComponent/DefaultAttachmentComponent.d.ts +1 -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 +9 -2
- 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/index-ui.d.ts +5 -1
- package/dist/index-ui.js +101 -35
- package/package.json +1 -1
- package/src/App.tsx +1 -1
- 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/base/Subscribable/SubscriptionPerformer.ts +7 -10
- package/src/Presentation/Views/Base/BaseViewModel.ts +1 -0
- package/src/Presentation/Views/Dialogs/Dialogs.scss +3 -0
- 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/AudioAttachmentComponent/AudioAttachmentComponent.tsx +1 -1
- package/src/Presentation/components/UI/Dialogs/MessagesView/DefaultAttachmentComponent/DefaultAttachmentComponent.tsx +20 -14
- 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 +1 -1
- package/src/Presentation/components/UI/Dialogs/MessagesView/InComingMessage/InComingMessage.tsx +74 -29
- package/src/Presentation/components/UI/Dialogs/MessagesView/MessagesView.scss +12 -23
- package/src/Presentation/components/UI/Dialogs/MessagesView/MessagesView.tsx +101 -33
- 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/PreviewDialog.scss +27 -1
- package/src/Presentation/components/UI/Dialogs/PreviewDialog/PreviewDialog.tsx +6 -3
- package/src/index-ui.ts +8 -1
- package/src/index.scss +0 -1
- package/src/package_artan_react_ui.json +1 -1
- package/src/package_original.json +1 -1
- package/src/Presentation/assets/styles/_reset-styles.scss +0 -435
package/src/Presentation/components/UI/Dialogs/MessagesView/InComingMessage/InComingMessage.tsx
CHANGED
|
@@ -18,23 +18,39 @@ import { AIMessageWidget } from '../AIWidgets/AIMessageWidget';
|
|
|
18
18
|
import LoaderComponent from '../../../Placeholders/LoaderComponent/LoaderComponent';
|
|
19
19
|
import AIWidgetActions from '../AIWidgets/AIWidgetActions/AIWidgetActions';
|
|
20
20
|
import TranslateIcon from '../../../svgs/Icons/Media/Translate';
|
|
21
|
-
import AvatarContentIncomingUser
|
|
21
|
+
import AvatarContentIncomingUser, {
|
|
22
|
+
AvatarContentIncomingUserProps,
|
|
23
|
+
} from './AvatarContentIncomingUser/AvatarContentIncomingUser';
|
|
22
24
|
import { DefaultConfigurations } from '../../../../../../Data/DefaultConfigurations';
|
|
23
25
|
import useQbInitializedDataContext from '../../../../providers/QuickBloxUIKitProvider/useQbInitializedDataContext';
|
|
24
26
|
import { AIUtils } from '../../../../../../utils/utils';
|
|
25
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
40
|
onStartLoader: () => void;
|
|
41
|
+
// eslint-disable-next-line react/no-unused-prop-types
|
|
32
42
|
onStopLoader: () => void;
|
|
33
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;
|
|
51
|
+
// index?: number;
|
|
52
|
+
// updateData?: (index: number, text: string) => void;
|
|
53
|
+
// translationDATA?: Record<number, string>;
|
|
38
54
|
}) {
|
|
39
55
|
const currentContext = useQbInitializedDataContext();
|
|
40
56
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
@@ -45,6 +61,22 @@ export function InComingMessage(props: {
|
|
|
45
61
|
useState<boolean>(false);
|
|
46
62
|
const [widgetTextContent, setWidgetTextContent] = useState<string>('');
|
|
47
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
|
+
|
|
79
|
+
// const [errorAITranslate, setErrorAITranslate] = useState<boolean>(false);
|
|
48
80
|
|
|
49
81
|
const maxTokensForAITranslate =
|
|
50
82
|
currentContext.InitParams.qbConfig.configAIApi.AITranslateWidgetConfig
|
|
@@ -59,6 +91,16 @@ export function InComingMessage(props: {
|
|
|
59
91
|
//
|
|
60
92
|
useEffect(() => {
|
|
61
93
|
setWaitAIWidget(false);
|
|
94
|
+
// if (
|
|
95
|
+
// props.AIAnswerToMessage?.textToContent &&
|
|
96
|
+
// props.AIAnswerToMessage?.textToContent.length > 0
|
|
97
|
+
// ) {
|
|
98
|
+
// // setMessageTextState(props.AIAnswerToMessage?.textToContent);
|
|
99
|
+
// setWidgetTextContent(props.AIAnswerToMessage?.textToContent);
|
|
100
|
+
// setTimeout(() => {
|
|
101
|
+
// setWidgetTextContent('');
|
|
102
|
+
// }, 45 * 1000);
|
|
103
|
+
// }
|
|
62
104
|
}, [props.AIAnswerToMessage?.textToContent]);
|
|
63
105
|
|
|
64
106
|
const messageContentRender = (
|
|
@@ -71,14 +113,18 @@ export function InComingMessage(props: {
|
|
|
71
113
|
{!originalTextMessage ? (
|
|
72
114
|
<div>{widgetTextContent}</div>
|
|
73
115
|
) : (
|
|
74
|
-
<div>{mc.message}</div>
|
|
116
|
+
<div className="message-in-a-single-line">{mc.message}</div>
|
|
75
117
|
)}
|
|
76
118
|
</div>
|
|
77
119
|
);
|
|
78
120
|
let messageContent: JSX.Element = messageText;
|
|
79
|
-
|
|
80
121
|
const attachmentContentRender = (att: ChatMessageAttachmentEntity) => {
|
|
81
|
-
let contentPlaceHolder: JSX.Element =
|
|
122
|
+
let contentPlaceHolder: JSX.Element = (
|
|
123
|
+
<DefaultAttachmentComponent
|
|
124
|
+
fileName={att.file?.name || ''}
|
|
125
|
+
fileUrl={att.file?.url || ''}
|
|
126
|
+
/>
|
|
127
|
+
);
|
|
82
128
|
|
|
83
129
|
if (att.type.toString().includes(FileType.video)) {
|
|
84
130
|
contentPlaceHolder = att.file ? (
|
|
@@ -103,9 +149,13 @@ export function InComingMessage(props: {
|
|
|
103
149
|
}
|
|
104
150
|
if (att.type.toString().includes(FileType.text)) {
|
|
105
151
|
contentPlaceHolder = att.file ? (
|
|
106
|
-
<div>TEXT</div>
|
|
152
|
+
// <div>TEXT</div>
|
|
153
|
+
<DefaultAttachmentComponent
|
|
154
|
+
fileName={att.file?.name || ''}
|
|
155
|
+
fileUrl={att.file?.url || ''}
|
|
156
|
+
/>
|
|
107
157
|
) : (
|
|
108
|
-
<ImageFile applyZoom />
|
|
158
|
+
<ImageFile width="24" height="24" applyZoom />
|
|
109
159
|
);
|
|
110
160
|
}
|
|
111
161
|
let contentResult: JSX.Element = (
|
|
@@ -137,7 +187,6 @@ export function InComingMessage(props: {
|
|
|
137
187
|
{mc.attachments.map((attachment) =>
|
|
138
188
|
attachmentContentRender(attachment),
|
|
139
189
|
)}
|
|
140
|
-
{messageText}
|
|
141
190
|
</ColumnContainer>
|
|
142
191
|
);
|
|
143
192
|
}
|
|
@@ -164,6 +213,7 @@ export function InComingMessage(props: {
|
|
|
164
213
|
setWaitAITranslateWidget(true);
|
|
165
214
|
await AITranslation?.textToWidget(
|
|
166
215
|
message.message,
|
|
216
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument,@typescript-eslint/no-unsafe-call
|
|
167
217
|
AIUtils.messageEntitiesToIChatMessageCollection(
|
|
168
218
|
messagesToView,
|
|
169
219
|
currentUserId,
|
|
@@ -212,25 +262,13 @@ export function InComingMessage(props: {
|
|
|
212
262
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-call
|
|
213
263
|
AIAnswerToMessage?.textToWidget(
|
|
214
264
|
message.message,
|
|
265
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument,@typescript-eslint/no-unsafe-call
|
|
215
266
|
AIUtils.messageEntitiesToIChatMessageCollection(
|
|
216
267
|
messagesToView,
|
|
217
268
|
currentUserId,
|
|
218
269
|
maxTokensForAnswerAssist,
|
|
219
270
|
),
|
|
220
|
-
)
|
|
221
|
-
.then((answerText) => {
|
|
222
|
-
// eslint-disable-next-line promise/always-return
|
|
223
|
-
if (answerText === 'Assist failed.') {
|
|
224
|
-
props.onErrorToast('Assist failed.');
|
|
225
|
-
}
|
|
226
|
-
setWaitAIWidget(false);
|
|
227
|
-
props.onStopLoader();
|
|
228
|
-
})
|
|
229
|
-
.catch(() => {
|
|
230
|
-
props.onErrorToast('Assist failed.');
|
|
231
|
-
setWaitAIWidget(false);
|
|
232
|
-
props.onStopLoader();
|
|
233
|
-
});
|
|
271
|
+
);
|
|
234
272
|
}
|
|
235
273
|
}
|
|
236
274
|
|
|
@@ -365,12 +403,17 @@ export function InComingMessage(props: {
|
|
|
365
403
|
onMouseEnter={() => setHaveHover(true)}
|
|
366
404
|
onMouseLeave={() => setHaveHover(false)}
|
|
367
405
|
>
|
|
368
|
-
|
|
406
|
+
{props.userIconRenderer ? (
|
|
407
|
+
props.userIconRenderer({ userId: props.message.sender_id })
|
|
408
|
+
) : (
|
|
409
|
+
// <AvatarContentIncomingUser userId={props.message.sender_id} />
|
|
410
|
+
<AvatarContentIncomingUser />
|
|
411
|
+
)}
|
|
369
412
|
<div className="incoming">
|
|
370
413
|
<div className="name">
|
|
371
414
|
<div className="caption">
|
|
372
415
|
<div className="name2">
|
|
373
|
-
{
|
|
416
|
+
{senderName || props.message.sender_id.toString()}
|
|
374
417
|
</div>
|
|
375
418
|
</div>
|
|
376
419
|
</div>
|
|
@@ -379,11 +422,13 @@ export function InComingMessage(props: {
|
|
|
379
422
|
<div className="chat-bubble-background">
|
|
380
423
|
{/* <div className="message-in-a-single-line"> */}
|
|
381
424
|
{/* </div> */}
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
425
|
+
<div className="message-in-a-single-line">
|
|
426
|
+
{messageContentRender(
|
|
427
|
+
props.message,
|
|
428
|
+
widgetTextContent,
|
|
429
|
+
props.theme,
|
|
430
|
+
)}
|
|
431
|
+
</div>
|
|
387
432
|
</div>
|
|
388
433
|
{renderWidgetAITranslate(
|
|
389
434
|
props.message,
|
|
@@ -221,11 +221,11 @@ $message-view-container-ai-translate-text-color: var(--tertiary-elements);
|
|
|
221
221
|
color: $message-view-container-message-text-color;
|
|
222
222
|
}
|
|
223
223
|
&--message-content-wrapper{
|
|
224
|
-
max-width:
|
|
224
|
+
max-width: 300px;
|
|
225
225
|
max-height: 160px;
|
|
226
|
-
min-width:
|
|
226
|
+
min-width: 300px;
|
|
227
227
|
// min-height: 160px;
|
|
228
|
-
width:
|
|
228
|
+
width: 300px;
|
|
229
229
|
// height: 160px;
|
|
230
230
|
// height: 100%;
|
|
231
231
|
|
|
@@ -346,7 +346,7 @@ $message-view-container-ai-translate-text-color: var(--tertiary-elements);
|
|
|
346
346
|
box-sizing: border-box;
|
|
347
347
|
}
|
|
348
348
|
.input-text-message {
|
|
349
|
-
background: var(--
|
|
349
|
+
background: var(--chat-input);
|
|
350
350
|
border-radius: 4px;
|
|
351
351
|
//padding: 10px 8px 10px 16px;
|
|
352
352
|
display: flex;
|
|
@@ -359,16 +359,21 @@ $message-view-container-ai-translate-text-color: var(--tertiary-elements);
|
|
|
359
359
|
}
|
|
360
360
|
|
|
361
361
|
.type-message {
|
|
362
|
-
color: var(--
|
|
362
|
+
color: var(--field-border);
|
|
363
363
|
text-align: left;
|
|
364
|
-
font: var(--body-body-large
|
|
364
|
+
font: var(--body-body-large);
|
|
365
365
|
position: relative;
|
|
366
366
|
flex: 1;
|
|
367
367
|
display: flex;
|
|
368
368
|
align-items: center;
|
|
369
369
|
justify-content: flex-start;
|
|
370
370
|
}
|
|
371
|
-
|
|
371
|
+
.type-message textarea{
|
|
372
|
+
color: var(--input-elements);
|
|
373
|
+
font: var(--body-body-large);
|
|
374
|
+
border: none;
|
|
375
|
+
outline: none;
|
|
376
|
+
}
|
|
372
377
|
.right {
|
|
373
378
|
display: flex;
|
|
374
379
|
flex-direction: row;
|
|
@@ -392,19 +397,3 @@ $message-view-container-ai-translate-text-color: var(--tertiary-elements);
|
|
|
392
397
|
height: 24px;
|
|
393
398
|
position: relative;
|
|
394
399
|
}
|
|
395
|
-
|
|
396
|
-
//
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
//textarea::-webkit-scrollbar {
|
|
400
|
-
// width: 1em;
|
|
401
|
-
//}
|
|
402
|
-
//
|
|
403
|
-
//textarea::-webkit-scrollbar-track {
|
|
404
|
-
// box-shadow: inset 0 0 6px rgba(0, 0, 0, 0.3);
|
|
405
|
-
//}
|
|
406
|
-
//
|
|
407
|
-
//textarea::-webkit-scrollbar-thumb {
|
|
408
|
-
// background-color: darkgrey;
|
|
409
|
-
// outline: 1px solid slategrey;
|
|
410
|
-
//}
|
|
@@ -47,7 +47,10 @@ import { AIMessageWidget } from './AIWidgets/AIMessageWidget';
|
|
|
47
47
|
import { DialogsViewModel } from '../../../../Views/Dialogs/DialogViewModel';
|
|
48
48
|
import { HighLightLink, messageHasUrls } from './HighLightLink/HighLightLink';
|
|
49
49
|
import { OutGoingMessage } from './OutGoingMessage/OutGoingMessage';
|
|
50
|
-
import {
|
|
50
|
+
import {
|
|
51
|
+
GetUserNameFct,
|
|
52
|
+
InComingMessage,
|
|
53
|
+
} from './InComingMessage/InComingMessage';
|
|
51
54
|
import NecktieIcon from '../../svgs/Icons/AIWidgets/NecktieIcon';
|
|
52
55
|
import HandshakeIcon from '../../svgs/Icons/AIWidgets/HandshakeIcon';
|
|
53
56
|
import WhiteCheckMarkIcon from '../../svgs/Icons/AIWidgets/WhiteCheckMarkIcon';
|
|
@@ -67,6 +70,11 @@ import ToneIcon from '../../svgs/Icons/Actions/Tone';
|
|
|
67
70
|
import DefaultAttachmentComponent from './DefaultAttachmentComponent/DefaultAttachmentComponent';
|
|
68
71
|
import { AIUtils } from '../../../../../utils/utils';
|
|
69
72
|
import { ErrorToast } from './ErrorToast/ErrorToast';
|
|
73
|
+
import { AvatarContentIncomingUserProps } from './InComingMessage/AvatarContentIncomingUser/AvatarContentIncomingUser';
|
|
74
|
+
import { SystemMessageBanner } from './SystemMessageBanner/SystemMessageBanner';
|
|
75
|
+
import { SystemDateBanner } from './SystemDateBanner/SystemDateBanner';
|
|
76
|
+
// import ToneIcon from '../../svgs/Icons/Actions/Tone';
|
|
77
|
+
// import AIWidgetActions from './AIWidgets/AIWidgetActions/AIWidgetActions';
|
|
70
78
|
|
|
71
79
|
type HeaderDialogsMessagesProps = {
|
|
72
80
|
AIRephrase?: AIMessageWidget;
|
|
@@ -76,8 +84,18 @@ type HeaderDialogsMessagesProps = {
|
|
|
76
84
|
onDialogInformationHandler?: FunctionTypeVoidToVoid;
|
|
77
85
|
maxWidthToResize?: string;
|
|
78
86
|
theme?: UiKitTheme;
|
|
79
|
-
|
|
80
|
-
|
|
87
|
+
headerContent?: React.ReactNode;
|
|
88
|
+
subHeaderContent?: React.ReactNode; // I recommend removing this as it can be done with headerContent
|
|
89
|
+
upHeaderContent?: React.ReactNode; // I recommend removing this as it can be done with headerContent
|
|
90
|
+
rootStyles?: React.CSSProperties;
|
|
91
|
+
messagesContainerStyles?: React.CSSProperties;
|
|
92
|
+
userIconRenderer?: (
|
|
93
|
+
props: AvatarContentIncomingUserProps,
|
|
94
|
+
) => React.ReactElement;
|
|
95
|
+
getSenderNameFct?: (props: {
|
|
96
|
+
sender?: UserEntity;
|
|
97
|
+
userId?: number;
|
|
98
|
+
}) => Promise<string | undefined>;
|
|
81
99
|
};
|
|
82
100
|
|
|
83
101
|
// eslint-disable-next-line react/function-component-definition
|
|
@@ -96,6 +114,11 @@ const MessagesView: React.FC<HeaderDialogsMessagesProps> = ({
|
|
|
96
114
|
theme = undefined,
|
|
97
115
|
subHeaderContent = undefined,
|
|
98
116
|
upHeaderContent = undefined,
|
|
117
|
+
headerContent = undefined,
|
|
118
|
+
rootStyles = {},
|
|
119
|
+
messagesContainerStyles = {},
|
|
120
|
+
userIconRenderer = undefined,
|
|
121
|
+
getSenderNameFct,
|
|
99
122
|
}: HeaderDialogsMessagesProps) => {
|
|
100
123
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
101
124
|
const maxWidthToResizing =
|
|
@@ -223,12 +246,20 @@ const MessagesView: React.FC<HeaderDialogsMessagesProps> = ({
|
|
|
223
246
|
}, [dialogMessagesCount]);
|
|
224
247
|
//
|
|
225
248
|
|
|
226
|
-
const
|
|
227
|
-
|
|
249
|
+
const defaultGetSenderName: GetUserNameFct = (props: {
|
|
250
|
+
sender?: UserEntity;
|
|
251
|
+
}): Promise<string | undefined> => {
|
|
252
|
+
let result = 'undefined user';
|
|
253
|
+
// eslint-disable-next-line react/prop-types
|
|
254
|
+
const { sender } = props;
|
|
255
|
+
|
|
256
|
+
if (!sender) return Promise.resolve(result);
|
|
257
|
+
// eslint-disable-next-line react/prop-types
|
|
258
|
+
result =
|
|
259
|
+
// eslint-disable-next-line react/prop-types
|
|
260
|
+
sender.full_name || sender.login || sender.email || sender.id.toString();
|
|
228
261
|
|
|
229
|
-
return (
|
|
230
|
-
sender.full_name || sender.login || sender.email || sender.id.toString()
|
|
231
|
-
);
|
|
262
|
+
return Promise.resolve(result);
|
|
232
263
|
};
|
|
233
264
|
|
|
234
265
|
// function sendMessageToTranslate(message: MessageEntity) {
|
|
@@ -282,7 +313,10 @@ const MessagesView: React.FC<HeaderDialogsMessagesProps> = ({
|
|
|
282
313
|
// let contentPlaceHolder: JSX.Element = <div>{att.type.toString()}</div>;
|
|
283
314
|
|
|
284
315
|
let contentPlaceHolder: JSX.Element = (
|
|
285
|
-
<DefaultAttachmentComponent
|
|
316
|
+
<DefaultAttachmentComponent
|
|
317
|
+
fileName={att.file?.name || ''}
|
|
318
|
+
fileUrl={att.file?.url || ''}
|
|
319
|
+
/>
|
|
286
320
|
);
|
|
287
321
|
|
|
288
322
|
if (att.type.toString().includes(FileType.video)) {
|
|
@@ -309,7 +343,10 @@ const MessagesView: React.FC<HeaderDialogsMessagesProps> = ({
|
|
|
309
343
|
if (att.type.toString().includes(FileType.text)) {
|
|
310
344
|
contentPlaceHolder = att.file ? (
|
|
311
345
|
// <div>TEXT</div>
|
|
312
|
-
<DefaultAttachmentComponent
|
|
346
|
+
<DefaultAttachmentComponent
|
|
347
|
+
fileName={att.file?.name || ''}
|
|
348
|
+
fileUrl={att.file?.url || ''}
|
|
349
|
+
/>
|
|
313
350
|
) : (
|
|
314
351
|
<ImageFile width="24" height="24" applyZoom />
|
|
315
352
|
);
|
|
@@ -343,7 +380,6 @@ const MessagesView: React.FC<HeaderDialogsMessagesProps> = ({
|
|
|
343
380
|
{mc.attachments.map((attachment) =>
|
|
344
381
|
attachmentContentRender(attachment),
|
|
345
382
|
)}
|
|
346
|
-
{messageText}
|
|
347
383
|
</ColumnContainer>
|
|
348
384
|
);
|
|
349
385
|
}
|
|
@@ -368,10 +404,11 @@ const MessagesView: React.FC<HeaderDialogsMessagesProps> = ({
|
|
|
368
404
|
style={theme ? { backgroundColor: theme.disabledElements() } : {}}
|
|
369
405
|
className="message-view-container--system-message-wrapper__date_container"
|
|
370
406
|
>
|
|
371
|
-
<
|
|
407
|
+
<SystemDateBanner text={getDateShortFormatEU(message.date_sent)} />
|
|
408
|
+
{/* <div>{getDateShortFormatEU(message.date_sent)},</div> */}
|
|
372
409
|
</div>
|
|
373
410
|
{/* <div>{getTimeShort24hFormat(message.date_sent)}</div> */}
|
|
374
|
-
<
|
|
411
|
+
<SystemMessageBanner messageText={message.message} />
|
|
375
412
|
</div>
|
|
376
413
|
);
|
|
377
414
|
} else if (messageTypes === IncomingMessage) {
|
|
@@ -379,7 +416,8 @@ const MessagesView: React.FC<HeaderDialogsMessagesProps> = ({
|
|
|
379
416
|
<InComingMessage
|
|
380
417
|
key={message.id}
|
|
381
418
|
theme={theme}
|
|
382
|
-
|
|
419
|
+
senderNameFct={getSenderNameFct || defaultGetSenderName}
|
|
420
|
+
userIconRenderer={userIconRenderer}
|
|
383
421
|
message={message}
|
|
384
422
|
// element={messageContentRender(message)}
|
|
385
423
|
onStartLoader={() => {
|
|
@@ -490,7 +528,15 @@ const MessagesView: React.FC<HeaderDialogsMessagesProps> = ({
|
|
|
490
528
|
const flag = fileToSend?.size && fileToSend?.size < MAXSIZE;
|
|
491
529
|
|
|
492
530
|
if (fileToSend?.size && fileToSend?.size < MAXSIZE) {
|
|
493
|
-
|
|
531
|
+
// eslint-disable-next-line promise/catch-or-return
|
|
532
|
+
messagesViewModel
|
|
533
|
+
.sendAttachmentMessage(fileToSend)
|
|
534
|
+
.then((resultOperation) => {
|
|
535
|
+
// eslint-disable-next-line promise/always-return
|
|
536
|
+
if (!resultOperation) {
|
|
537
|
+
showErrorMessage(`Incorrect data`);
|
|
538
|
+
}
|
|
539
|
+
});
|
|
494
540
|
} else if (fileToSend) {
|
|
495
541
|
showErrorMessage(
|
|
496
542
|
`file size ${fileToSend?.size} must be less then ${MAXSIZE_FOR_MESSAGE} mb.`,
|
|
@@ -1204,6 +1250,7 @@ const MessagesView: React.FC<HeaderDialogsMessagesProps> = ({
|
|
|
1204
1250
|
setPrevTextMessage(messageText);
|
|
1205
1251
|
AIRephrase?.textToWidget(
|
|
1206
1252
|
messageText,
|
|
1253
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-call,@typescript-eslint/no-unsafe-argument
|
|
1207
1254
|
AIUtils.messageEntitiesToIChatMessageCollection(
|
|
1208
1255
|
messagesToView,
|
|
1209
1256
|
currentUserId,
|
|
@@ -1259,27 +1306,46 @@ const MessagesView: React.FC<HeaderDialogsMessagesProps> = ({
|
|
|
1259
1306
|
minWidth: `$message-view-container-wrapper-min-width`,
|
|
1260
1307
|
// width: `${maxWidthToResizing}`,
|
|
1261
1308
|
width: '100%',
|
|
1309
|
+
...rootStyles,
|
|
1262
1310
|
}
|
|
1263
|
-
:
|
|
1311
|
+
: rootStyles
|
|
1264
1312
|
}
|
|
1265
1313
|
className="message-view-container"
|
|
1266
1314
|
>
|
|
1267
|
-
|
|
1268
|
-
|
|
1269
|
-
|
|
1270
|
-
|
|
1271
|
-
|
|
1272
|
-
|
|
1273
|
-
|
|
1274
|
-
|
|
1275
|
-
|
|
1276
|
-
|
|
1277
|
-
|
|
1278
|
-
|
|
1279
|
-
|
|
1280
|
-
|
|
1281
|
-
|
|
1282
|
-
|
|
1315
|
+
{headerContent || (
|
|
1316
|
+
<div
|
|
1317
|
+
style={{
|
|
1318
|
+
flexGrow: `1`,
|
|
1319
|
+
flexShrink: `1`,
|
|
1320
|
+
flexBasis: `${maxWidthToResizing}`,
|
|
1321
|
+
}}
|
|
1322
|
+
className="message-view-container--header"
|
|
1323
|
+
>
|
|
1324
|
+
{useUpContent && upHeaderContent}
|
|
1325
|
+
<HeaderMessages
|
|
1326
|
+
dialog={messagesViewModel.entity}
|
|
1327
|
+
InformationHandler={onDialogInformationHandler}
|
|
1328
|
+
countMembers={getCountDialogMembers(dialogsViewModel.entity)}
|
|
1329
|
+
/>
|
|
1330
|
+
{useSubContent && subHeaderContent}
|
|
1331
|
+
</div>
|
|
1332
|
+
)}
|
|
1333
|
+
{/* <div */}
|
|
1334
|
+
{/* style={{ */}
|
|
1335
|
+
{/* flexGrow: `1`, */}
|
|
1336
|
+
{/* flexShrink: `1`, */}
|
|
1337
|
+
{/* flexBasis: `${maxWidthToResizing}`, */}
|
|
1338
|
+
{/* }} */}
|
|
1339
|
+
{/* className="message-view-container--header" */}
|
|
1340
|
+
{/* > */}
|
|
1341
|
+
{/* {useUpContent && upHeaderContent} */}
|
|
1342
|
+
{/* <HeaderMessages */}
|
|
1343
|
+
{/* dialog={messagesViewModel.entity} */}
|
|
1344
|
+
{/* InformationHandler={onDialogInformationHandler} */}
|
|
1345
|
+
{/* countMembers={getCountDialogMembers(dialogsViewModel.entity)} */}
|
|
1346
|
+
{/* /> */}
|
|
1347
|
+
{/* {useSubContent && subHeaderContent} */}
|
|
1348
|
+
{/* </div> */}
|
|
1283
1349
|
{showErrorToast && !messagesViewModel?.loading ? (
|
|
1284
1350
|
<ErrorToast messageText={messageErrorToast} />
|
|
1285
1351
|
) : null}
|
|
@@ -1353,11 +1419,13 @@ const MessagesView: React.FC<HeaderDialogsMessagesProps> = ({
|
|
|
1353
1419
|
flexShrink: `1`,
|
|
1354
1420
|
flexBasis: `${maxWidthToResizing}`,
|
|
1355
1421
|
backgroundColor: theme.secondaryBackground(), // var(--secondary-background);
|
|
1422
|
+
...messagesContainerStyles,
|
|
1356
1423
|
}
|
|
1357
1424
|
: {
|
|
1358
1425
|
flexGrow: `1`,
|
|
1359
1426
|
flexShrink: `1`,
|
|
1360
1427
|
flexBasis: `${maxWidthToResizing}`,
|
|
1428
|
+
...messagesContainerStyles,
|
|
1361
1429
|
}
|
|
1362
1430
|
}
|
|
1363
1431
|
className="message-view-container--messages"
|
|
@@ -1472,7 +1540,7 @@ const MessagesView: React.FC<HeaderDialogsMessagesProps> = ({
|
|
|
1472
1540
|
<input
|
|
1473
1541
|
id="btnUploadAttachment"
|
|
1474
1542
|
type="file"
|
|
1475
|
-
accept="image/*, audio/*, video/*, .pdf, .txt,"
|
|
1543
|
+
accept="image/*, audio/*, video/*, .pdf, .txt, .apk, .zip, .ipa, .ppt, .pptx, .doc, .docx, .xls, .xlsx, .json, .log"
|
|
1476
1544
|
style={{ display: 'none' }}
|
|
1477
1545
|
onChange={(event) => {
|
|
1478
1546
|
ChangeFileHandler(event);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import BaseViewModel, {
|
|
2
|
-
|
|
2
|
+
FunctionTypeFileToToBoolean,
|
|
3
3
|
FunctionTypePaginationToVoid,
|
|
4
4
|
FunctionTypeStringToVoid,
|
|
5
5
|
FunctionTypeVoidToVoid,
|
|
@@ -13,7 +13,7 @@ export interface MessagesViewModel extends BaseViewModel<DialogEntity> {
|
|
|
13
13
|
messages: MessageEntity[]; // content
|
|
14
14
|
getMessages: FunctionTypePaginationToVoid; // prepareContent
|
|
15
15
|
sendTextMessage: FunctionTypeStringToVoid;
|
|
16
|
-
sendAttachmentMessage:
|
|
16
|
+
sendAttachmentMessage: FunctionTypeFileToToBoolean;
|
|
17
17
|
release: FunctionTypeVoidToVoid; // release Content
|
|
18
18
|
sendTypingTextMessage: FunctionTypeVoidToVoid; //
|
|
19
19
|
typingText: string;
|
package/src/Presentation/components/UI/Dialogs/MessagesView/SystemDateBanner/SystemDateBanner.scss
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
.system-date-banner-chat-banner,
|
|
2
|
+
.system-date-banner-chat-banner * {
|
|
3
|
+
box-sizing: border-box;
|
|
4
|
+
}
|
|
5
|
+
.system-date-banner-chat-banner {
|
|
6
|
+
background: var(--incoming-background);
|
|
7
|
+
border-radius: 30px;
|
|
8
|
+
padding: 2px 8px 2px 8px;
|
|
9
|
+
display: flex;
|
|
10
|
+
flex-direction: row;
|
|
11
|
+
gap: 10px;
|
|
12
|
+
align-items: center;
|
|
13
|
+
justify-content: center;
|
|
14
|
+
flex-shrink: 0;
|
|
15
|
+
position: relative;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
.system-date-this-chat {
|
|
19
|
+
color: var(--secondary-text);
|
|
20
|
+
text-align: center;
|
|
21
|
+
font: var(--label-label-small, 500 11px/16px "Roboto", sans-serif);
|
|
22
|
+
position: relative;
|
|
23
|
+
}
|
package/src/Presentation/components/UI/Dialogs/MessagesView/SystemDateBanner/SystemDateBanner.tsx
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import './SystemDateBanner.scss';
|
|
3
|
+
|
|
4
|
+
type SystemDateBannerProps = {
|
|
5
|
+
text: string;
|
|
6
|
+
};
|
|
7
|
+
|
|
8
|
+
// eslint-disable-next-line react/function-component-definition
|
|
9
|
+
export const SystemDateBanner: React.FC<SystemDateBannerProps> = ({
|
|
10
|
+
text,
|
|
11
|
+
}: SystemDateBannerProps) => {
|
|
12
|
+
return (
|
|
13
|
+
<div className="system-date-banner-chat-banner">
|
|
14
|
+
<div className="system-date-this-chat">{text}</div>
|
|
15
|
+
</div>
|
|
16
|
+
);
|
|
17
|
+
};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
.system-message-chat-banner,
|
|
2
|
+
.system-message-chat-banner * {
|
|
3
|
+
box-sizing: border-box;
|
|
4
|
+
}
|
|
5
|
+
.system-message-chat-banner {
|
|
6
|
+
padding: 2px 8px 2px 8px;
|
|
7
|
+
display: flex;
|
|
8
|
+
flex-direction: row;
|
|
9
|
+
gap: 10px;
|
|
10
|
+
align-items: center;
|
|
11
|
+
justify-content: center;
|
|
12
|
+
flex-shrink: 0;
|
|
13
|
+
width: 328px;
|
|
14
|
+
position: relative;
|
|
15
|
+
}
|
|
16
|
+
.username-join-this-chat {
|
|
17
|
+
color: var(--secondary-text);
|
|
18
|
+
text-align: center;
|
|
19
|
+
font: var(--label-label-small, 500 11px/16px "Roboto", sans-serif);
|
|
20
|
+
position: relative;
|
|
21
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import './SystemMessageBanner.scss';
|
|
3
|
+
|
|
4
|
+
type SystemMessageBannerProps = {
|
|
5
|
+
messageText: string;
|
|
6
|
+
};
|
|
7
|
+
|
|
8
|
+
// eslint-disable-next-line react/function-component-definition
|
|
9
|
+
export const SystemMessageBanner: React.FC<SystemMessageBannerProps> = ({
|
|
10
|
+
messageText,
|
|
11
|
+
}: SystemMessageBannerProps) => {
|
|
12
|
+
return (
|
|
13
|
+
<div className="system-message-chat-banner">
|
|
14
|
+
<div className="username-join-this-chat">{messageText}</div>
|
|
15
|
+
</div>
|
|
16
|
+
);
|
|
17
|
+
};
|