quickblox-react-ui-kit 0.3.0-beta.2 → 0.3.0-beta.3
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/dist/Data/repository/DialogsRepository.d.ts +1 -0
- package/dist/Data/source/remote/IRemoteDataSource.d.ts +1 -0
- package/dist/Data/source/remote/RemoteDataSource.d.ts +2 -0
- package/dist/Domain/entity/DialogEventInfo.d.ts +4 -0
- package/dist/Domain/use_cases/GetAllMessagesForDialog.d.ts +3 -3
- package/dist/Domain/use_cases/UpdateCurrentDialogInDataSourceUseCase.d.ts +10 -0
- package/dist/Presentation/Views/Dialog/DialogViewModel.d.ts +2 -0
- package/dist/Presentation/Views/Dialog/MessageItem/MessageItem.d.ts +2 -2
- package/dist/Presentation/ui-components/MessageInput/MessageInput.stories.d.ts +4 -4
- package/dist/index-ui.js +549 -422
- package/dist/index-ui.js.map +1 -1
- package/dist/qb-api-calls/index.d.ts +1 -0
- package/package.json +1 -1
- package/src/App.tsx +2 -2
- package/src/Data/repository/DialogsRepository.ts +16 -0
- package/src/Data/source/remote/IRemoteDataSource.ts +2 -0
- package/src/Data/source/remote/RemoteDataSource.ts +89 -10
- package/src/Domain/entity/DialogEventInfo.ts +4 -0
- package/src/Domain/use_cases/GetAllMessagesForDialog.ts +3 -3
- package/src/Domain/use_cases/GetDialogByIdUseCase.ts +5 -1
- package/src/Domain/use_cases/UpdateCurrentDialogInDataSourceUseCase.ts +31 -0
- package/src/Presentation/Views/Dialog/DialogViewModel.ts +2 -0
- package/src/Presentation/Views/Dialog/ForwardMessageFlow/DialogsWithSearch/DialogsWithSearch.scss +10 -0
- package/src/Presentation/Views/Dialog/ForwardMessageFlow/DialogsWithSearch/DialogsWithSearch.tsx +12 -13
- package/src/Presentation/Views/Dialog/MessageItem/MessageItem.tsx +17 -9
- package/src/Presentation/Views/Dialog/useDialogViewModel.ts +64 -32
- package/src/Presentation/Views/DialogInfo/DialogInfo.scss +3 -11
- package/src/Presentation/Views/DialogInfo/MembersList/MembersList.scss +8 -99
- package/src/Presentation/Views/DialogInfo/MembersList/MembersList.tsx +9 -29
- package/src/Presentation/Views/DialogList/useDialogListViewModel.ts +83 -3
- package/src/Presentation/Views/EditDialog/EditDialog.scss +1 -40
- package/src/Presentation/Views/EditDialog/EditDialog.tsx +9 -14
- package/src/Presentation/Views/InviteMembers/InviteMembers.tsx +14 -15
- package/src/Presentation/icons/media/video-file.svg +2 -2
- package/src/Presentation/layouts/Desktop/DesktopLayout.scss +8 -8
- package/src/Presentation/layouts/Desktop/QuickBloxUIKitDesktopLayout.tsx +119 -100
- package/src/Presentation/ui-components/Avatar/avatar.stories.tsx +1 -1
- package/src/Presentation/ui-components/Badge/Badge.stories.ts +1 -1
- package/src/Presentation/ui-components/Button/Button.stories.ts +1 -1
- package/src/Presentation/ui-components/DialogBanner/DialogBanner.stories.ts +2 -1
- package/src/Presentation/ui-components/DialogItemPreview/DialogItemPreview.stories.tsx +29 -1
- package/src/Presentation/ui-components/DialogItemPreview/DialogItemPreview.tsx +4 -1
- package/src/Presentation/ui-components/DialogWindow/DialogWindow.stories.tsx +2 -1
- package/src/Presentation/ui-components/Dropdown/Dropdown.stories.tsx +2 -1
- package/src/Presentation/ui-components/Dropdown/Dropdown.tsx +4 -1
- package/src/Presentation/ui-components/Header/Header.stories.tsx +2 -1
- package/src/Presentation/ui-components/Loader/Loader.stories.ts +1 -1
- package/src/Presentation/ui-components/Message/Bubble/AttachmentBubble/AttachmentBubble.tsx +6 -1
- package/src/Presentation/ui-components/Message/Bubble/AudioBubble/AudioBubble.scss +13 -0
- package/src/Presentation/ui-components/Message/Bubble/AudioBubble/AudioBubble.tsx +16 -2
- package/src/Presentation/ui-components/Message/Bubble/VideoBubble/VideoBubble.scss +9 -0
- package/src/Presentation/ui-components/Message/Bubble/VideoBubble/VideoBubble.tsx +15 -17
- package/src/Presentation/ui-components/Message/Message.stories.tsx +80 -1
- package/src/Presentation/ui-components/MessageInput/MessageInput.stories.tsx +16 -8
- package/src/Presentation/ui-components/MessageSeparator/MessageSeparator.stories.ts +3 -1
- package/src/Presentation/ui-components/Placeholder/Placeholder.stories.tsx +2 -6
- package/src/Presentation/ui-components/PreviewFileMessage/PreviewFileMessage.stories.ts +12 -1
- package/src/Presentation/ui-components/SettingsItem/SettingsItem.stories.tsx +5 -1
- package/src/Presentation/ui-components/TextField/TextField.stories.ts +7 -2
- package/src/Presentation/ui-components/Toast/Toast.stories.tsx +1 -1
- package/src/Presentation/ui-components/UserListItem/UserListItem.stories.tsx +3 -1
- package/src/index.scss +0 -2
- package/src/qb-api-calls/index.ts +1 -0
- package/storybook-static/433.dffc897e.iframe.bundle.js +1 -0
- package/storybook-static/603.4cf0423b.iframe.bundle.js +1 -0
- package/storybook-static/{758.d99b0166.iframe.bundle.js → 758.e75a5a47.iframe.bundle.js} +3 -3
- package/storybook-static/{758.d99b0166.iframe.bundle.js.map → 758.e75a5a47.iframe.bundle.js.map} +1 -1
- package/storybook-static/{472.3c9e81e6.iframe.bundle.js → 768.e44c05aa.iframe.bundle.js} +3 -3
- package/storybook-static/{472.3c9e81e6.iframe.bundle.js.map → 768.e44c05aa.iframe.bundle.js.map} +1 -1
- package/storybook-static/{926.f14bb932.iframe.bundle.js → 926.f5308089.iframe.bundle.js} +2 -2
- package/storybook-static/{926.f14bb932.iframe.bundle.js.map → 926.f5308089.iframe.bundle.js.map} +1 -1
- package/storybook-static/Presentation-ui-components-Avatar-avatar-stories.cf806856.iframe.bundle.js +1 -0
- package/storybook-static/Presentation-ui-components-Badge-Badge-stories.9449e470.iframe.bundle.js +14 -0
- package/storybook-static/{Presentation-ui-components-Badge-Badge-stories.fea53429.iframe.bundle.js.map → Presentation-ui-components-Badge-Badge-stories.9449e470.iframe.bundle.js.map} +1 -1
- package/storybook-static/Presentation-ui-components-Button-Button-stories.4fac7996.iframe.bundle.js +1 -0
- package/storybook-static/Presentation-ui-components-DialogBanner-DialogBanner-stories.fa91d2c7.iframe.bundle.js +10 -0
- package/storybook-static/{Presentation-ui-components-DialogBanner-DialogBanner-stories.6b2a3f72.iframe.bundle.js.map → Presentation-ui-components-DialogBanner-DialogBanner-stories.fa91d2c7.iframe.bundle.js.map} +1 -1
- package/storybook-static/Presentation-ui-components-DialogItemPreview-DialogItemPreview-stories.90aa44c5.iframe.bundle.js +1 -0
- package/storybook-static/Presentation-ui-components-DialogWindow-DialogWindow-stories.3523a670.iframe.bundle.js +1 -0
- package/storybook-static/Presentation-ui-components-Dropdown-Dropdown-stories.aacf2ec2.iframe.bundle.js +1 -0
- package/storybook-static/Presentation-ui-components-Header-Header-stories.073c4507.iframe.bundle.js +1 -0
- package/storybook-static/Presentation-ui-components-Loader-Loader-stories.9bf3fb63.iframe.bundle.js +1 -0
- package/storybook-static/{Presentation-ui-components-Message-Message-stories.63bec01b.iframe.bundle.js → Presentation-ui-components-Message-Message-stories.343dfae0.iframe.bundle.js} +1 -1
- package/storybook-static/Presentation-ui-components-MessageInput-MessageInput-stories.262a0cf2.iframe.bundle.js +1 -0
- package/storybook-static/{Presentation-ui-components-MessageSeparator-MessageSeparator-stories.82483823.iframe.bundle.js → Presentation-ui-components-MessageSeparator-MessageSeparator-stories.a7d43c0b.iframe.bundle.js} +3 -3
- package/storybook-static/{Presentation-ui-components-MessageSeparator-MessageSeparator-stories.82483823.iframe.bundle.js.map → Presentation-ui-components-MessageSeparator-MessageSeparator-stories.a7d43c0b.iframe.bundle.js.map} +1 -1
- package/storybook-static/Presentation-ui-components-Placeholder-Placeholder-stories.871f508c.iframe.bundle.js +1 -0
- package/storybook-static/Presentation-ui-components-PreviewFileMessage-PreviewFileMessage-stories.1661d95b.iframe.bundle.js +1 -0
- package/storybook-static/Presentation-ui-components-SettingsItem-SettingsItem-stories.8f6fca84.iframe.bundle.js +1 -0
- package/storybook-static/Presentation-ui-components-TextField-TextField-stories.4a2eef3e.iframe.bundle.js +1 -0
- package/storybook-static/{Presentation-ui-components-Toast-Toast-stories.e26b2e07.iframe.bundle.js → Presentation-ui-components-Toast-Toast-stories.55e63162.iframe.bundle.js} +1 -1
- package/storybook-static/{Presentation-ui-components-UserListItem-UserListItem-stories.e88f4206.iframe.bundle.js → Presentation-ui-components-UserListItem-UserListItem-stories.04d3eefe.iframe.bundle.js} +1 -1
- package/storybook-static/docs-Introduction-mdx.ac401482.iframe.bundle.js +10 -0
- package/storybook-static/docs-Introduction-mdx.ac401482.iframe.bundle.js.map +1 -0
- package/storybook-static/docs-Styling-mdx.1d6c1212.iframe.bundle.js +10 -0
- package/storybook-static/docs-Styling-mdx.1d6c1212.iframe.bundle.js.map +1 -0
- package/storybook-static/iframe.html +4 -4
- package/storybook-static/index.json +1 -1
- package/storybook-static/main.597d432b.iframe.bundle.js +1 -0
- package/storybook-static/project.json +1 -1
- package/storybook-static/runtime~main.e945879b.iframe.bundle.js +1 -0
- package/storybook-static/static/css/{Presentation-ui-components-Message-Message-stories.a518b61a.chunk.css → Presentation-ui-components-Message-Message-stories.0e129b10.chunk.css} +3 -3
- package/storybook-static/static/css/{Presentation-ui-components-Message-Message-stories.a518b61a.chunk.css.map → Presentation-ui-components-Message-Message-stories.0e129b10.chunk.css.map} +1 -1
- package/storybook-static/static/css/{Presentation-ui-components-Placeholder-Placeholder-stories.1ebf88ab.chunk.css → Presentation-ui-components-Placeholder-Placeholder-stories.cb7fb80a.chunk.css} +1 -2
- package/storybook-static/static/css/Presentation-ui-components-Placeholder-Placeholder-stories.cb7fb80a.chunk.css.map +1 -0
- package/storybook-static/static/css/{main.4e852eef.css → main.6fa55a2c.css} +2 -2
- package/storybook-static/static/css/{main.4e852eef.css.map → main.6fa55a2c.css.map} +1 -1
- package/storybook-static/static/media/video-file.dc2971be489b2af7b1c04dcc55bfe881.svg +3 -0
- package/storybook-static/stories.json +1 -1
- package/storybook-static/312.0aa0e670.iframe.bundle.js +0 -1
- package/storybook-static/341.bea6d0bd.iframe.bundle.js +0 -1
- package/storybook-static/Presentation-ui-components-Avatar-avatar-stories.2fb23ae6.iframe.bundle.js +0 -1
- package/storybook-static/Presentation-ui-components-Badge-Badge-stories.fea53429.iframe.bundle.js +0 -14
- package/storybook-static/Presentation-ui-components-Button-Button-stories.f6c6437b.iframe.bundle.js +0 -1
- package/storybook-static/Presentation-ui-components-DialogBanner-DialogBanner-stories.6b2a3f72.iframe.bundle.js +0 -10
- package/storybook-static/Presentation-ui-components-DialogItemPreview-DialogItemPreview-stories.f1cb9d40.iframe.bundle.js +0 -1
- package/storybook-static/Presentation-ui-components-DialogWindow-DialogWindow-stories.0ad17c54.iframe.bundle.js +0 -1
- package/storybook-static/Presentation-ui-components-Dropdown-Dropdown-stories.3b620239.iframe.bundle.js +0 -1
- package/storybook-static/Presentation-ui-components-Header-Header-stories.45503161.iframe.bundle.js +0 -1
- package/storybook-static/Presentation-ui-components-Loader-Loader-stories.8b53bb33.iframe.bundle.js +0 -1
- package/storybook-static/Presentation-ui-components-MessageInput-MessageInput-stories.728a66ad.iframe.bundle.js +0 -1
- package/storybook-static/Presentation-ui-components-Placeholder-Placeholder-stories.0898ead6.iframe.bundle.js +0 -1
- package/storybook-static/Presentation-ui-components-PreviewFileMessage-PreviewFileMessage-stories.973cdb64.iframe.bundle.js +0 -1
- package/storybook-static/Presentation-ui-components-SettingsItem-SettingsItem-stories.0af0b8a8.iframe.bundle.js +0 -1
- package/storybook-static/Presentation-ui-components-TextField-TextField-stories.5987d2bb.iframe.bundle.js +0 -1
- package/storybook-static/main.0332574c.iframe.bundle.js +0 -1
- package/storybook-static/runtime~main.16726a14.iframe.bundle.js +0 -1
- package/storybook-static/static/css/Presentation-ui-components-Placeholder-Placeholder-stories.1ebf88ab.chunk.css.map +0 -1
- package/storybook-static/static/media/video-file.dbd1f8c63a3769f9e9a027f0922d56b2.svg +0 -3
|
@@ -4,9 +4,9 @@ $desktop-main-container-item-width: 320px;
|
|
|
4
4
|
$desktop-main-container-item-center-width: 720px;
|
|
5
5
|
// $desktop-main-container-item-center-width: 1040px;
|
|
6
6
|
|
|
7
|
-
.desktop-layout-main-container{
|
|
7
|
+
.desktop-layout-main-container {
|
|
8
8
|
// border: 1px solid var(--color-divider, #e7efff);
|
|
9
|
-
|
|
9
|
+
// border: 2px solid #6c38cc;
|
|
10
10
|
// min-height: $desktop-main-container-min-height;
|
|
11
11
|
// max-width: $desktop-main-container-max-width;
|
|
12
12
|
// height: calc(100vh - 128px);
|
|
@@ -23,8 +23,8 @@ $desktop-main-container-item-center-width: 720px;
|
|
|
23
23
|
height: 100%;
|
|
24
24
|
}
|
|
25
25
|
&__item-right {
|
|
26
|
-
border: 1px solid
|
|
27
|
-
flex: 1
|
|
26
|
+
border: 1px solid var(--divider);
|
|
27
|
+
flex: 1 0 $desktop-main-container-item-width;
|
|
28
28
|
// max-width: $desktop-main-container-item-width
|
|
29
29
|
width: 100%;
|
|
30
30
|
height: 100%;
|
|
@@ -34,14 +34,14 @@ $desktop-main-container-item-center-width: 720px;
|
|
|
34
34
|
border-style: solid;
|
|
35
35
|
border-color: var(--divider, #e7efff);
|
|
36
36
|
border-width: 1px 1px 1px 0;
|
|
37
|
-
|
|
37
|
+
// flex: 3 2 $desktop-main-container-item-center-width;
|
|
38
38
|
height: 100%;
|
|
39
39
|
width: 100%;
|
|
40
|
-
|
|
40
|
+
// min-width: 320px;
|
|
41
41
|
}
|
|
42
42
|
}
|
|
43
43
|
|
|
44
|
-
.dialog-leave-container{
|
|
44
|
+
.dialog-leave-container {
|
|
45
45
|
display: flex;
|
|
46
46
|
align-items: center;
|
|
47
47
|
justify-content: flex-end;
|
|
@@ -49,7 +49,7 @@ $desktop-main-container-item-center-width: 720px;
|
|
|
49
49
|
gap: 8px;
|
|
50
50
|
}
|
|
51
51
|
|
|
52
|
-
.empty-chat-placeholder{
|
|
52
|
+
.empty-chat-placeholder {
|
|
53
53
|
display: flex;
|
|
54
54
|
justify-content: center;
|
|
55
55
|
align-items: center;
|
|
@@ -60,6 +60,7 @@ import { MessageSeparator, Placeholder } from '../../ui-components';
|
|
|
60
60
|
import ToastProvider from '../../ui-components/Toast/ToastProvider';
|
|
61
61
|
import CreateNewDialogFlow from '../../Views/Flow/CreateDialogFlow/CreateNewDialogFlow';
|
|
62
62
|
import useModal from '../../../hooks/useModal';
|
|
63
|
+
import useQBConnection from '../../providers/QuickBloxUIKitProvider/useQBConnection';
|
|
63
64
|
|
|
64
65
|
type AIWidgetPlaceHolder = {
|
|
65
66
|
enabled: boolean;
|
|
@@ -102,16 +103,34 @@ const QuickBloxUIKitDesktopLayout: React.FC<
|
|
|
102
103
|
// @ts-ignore
|
|
103
104
|
const userName =
|
|
104
105
|
currentContext.storage.REMOTE_DATA_SOURCE.authInformation?.userName;
|
|
105
|
-
const
|
|
106
|
+
const currentUserId =
|
|
106
107
|
currentContext.storage.REMOTE_DATA_SOURCE.authInformation?.userId;
|
|
107
|
-
// const currentUserName =
|
|
108
|
-
// currentContext.storage.REMOTE_DATA_SOURCE.authInformation?.userName;
|
|
109
108
|
const sessionToken =
|
|
110
109
|
currentContext.storage.REMOTE_DATA_SOURCE.authInformation?.sessionToken;
|
|
111
110
|
|
|
112
111
|
const dialogsViewModel: DialogListViewModel =
|
|
113
112
|
useDialogListViewModel(currentContext);
|
|
114
113
|
|
|
114
|
+
// must re-create as result dialog changing
|
|
115
|
+
const messagesViewModel: DialogViewModel = useDialogViewModel(
|
|
116
|
+
dialogsViewModel.entity?.type,
|
|
117
|
+
dialogsViewModel.entity,
|
|
118
|
+
);
|
|
119
|
+
|
|
120
|
+
const { connectionRepository, browserOnline } = useQBConnection();
|
|
121
|
+
const [isOnline, setIsOnline] = useState<boolean>(browserOnline);
|
|
122
|
+
|
|
123
|
+
useEffect(() => {
|
|
124
|
+
if (
|
|
125
|
+
isOnline === false ||
|
|
126
|
+
connectionRepository.isChatConnected() === false
|
|
127
|
+
) {
|
|
128
|
+
setIsOnline(false);
|
|
129
|
+
} else {
|
|
130
|
+
setIsOnline(true);
|
|
131
|
+
}
|
|
132
|
+
}, [browserOnline, connectionRepository.isChatConnected()]);
|
|
133
|
+
|
|
115
134
|
let defaultAIRephraseWidget = AIRephrase?.AIWidget; // useDefaultTextInputWidget();
|
|
116
135
|
let defaultAITranslateWidget = AITranslate?.AIWidget;
|
|
117
136
|
let defaultAIAssistWidget = AIAssist?.AIWidget;
|
|
@@ -232,6 +251,7 @@ const QuickBloxUIKitDesktopLayout: React.FC<
|
|
|
232
251
|
const selectDialogActions = (item: BaseViewModel<DialogEntity>): void => {
|
|
233
252
|
if (!dialogsViewModel.loading) {
|
|
234
253
|
setSelectedDialog(item.entity);
|
|
254
|
+
// dialogsViewModel.entity = item.entity;
|
|
235
255
|
}
|
|
236
256
|
};
|
|
237
257
|
|
|
@@ -239,9 +259,14 @@ const QuickBloxUIKitDesktopLayout: React.FC<
|
|
|
239
259
|
const [messagesToReply, setMessagesToReply] = useState<MessageEntity[]>([]);
|
|
240
260
|
const [isMobile, width, height, breakpoint] = useMobileLayout();
|
|
241
261
|
const [clientHeight, setClientHeight] = useState<number>(0);
|
|
262
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
263
|
+
const [scrollUpToDown, setScrollUpToDown] = React.useState(false);
|
|
242
264
|
|
|
243
|
-
// const
|
|
244
|
-
//
|
|
265
|
+
// const [dialogMessagesCount, setDialogMessageCount] = useState(100);
|
|
266
|
+
// const [hasMore, setHasMore] = React.useState(true);
|
|
267
|
+
// const [messagesToView, setMessagesToView] = React.useState<MessageEntity[]>(
|
|
268
|
+
// [],
|
|
269
|
+
// );
|
|
245
270
|
|
|
246
271
|
// инициализация СДК и загрузка тестовых данных, запуск пинга - может не быть
|
|
247
272
|
// todo: добавить метод в контекст
|
|
@@ -308,19 +333,78 @@ const QuickBloxUIKitDesktopLayout: React.FC<
|
|
|
308
333
|
}
|
|
309
334
|
}, [currentContext.InitParams]);
|
|
310
335
|
|
|
311
|
-
// const
|
|
312
|
-
//
|
|
336
|
+
// const fetchMoreData = () => {
|
|
337
|
+
// if (messagesToView.length >= dialogMessagesCount) {
|
|
338
|
+
// setHasMore(false);
|
|
313
339
|
//
|
|
314
|
-
//
|
|
315
|
-
// participants = (dialogEntity as GroupDialogEntity).participantIds;
|
|
316
|
-
// } else if (dialogEntity.type === DialogType.private) {
|
|
317
|
-
// participants = [(dialogEntity as PrivateDialogEntity).participantId];
|
|
318
|
-
// } else if (dialogEntity.type === DialogType.public) {
|
|
319
|
-
// participants = [];
|
|
340
|
+
// return;
|
|
320
341
|
// }
|
|
342
|
+
// if (
|
|
343
|
+
// hasMore &&
|
|
344
|
+
// messagesToView.length > 0 &&
|
|
345
|
+
// messagesToView.length < dialogMessagesCount
|
|
346
|
+
// ) {
|
|
347
|
+
// setMessagesToView((prevState) => {
|
|
348
|
+
// const newState = [...prevState];
|
|
321
349
|
//
|
|
322
|
-
//
|
|
350
|
+
// const newMessageEntity: MessageEntity =
|
|
351
|
+
// messagesViewModel.messages[prevState.length];
|
|
352
|
+
//
|
|
353
|
+
// newState.push(newMessageEntity);
|
|
354
|
+
// // newState.unshift(newMessageEntity);
|
|
355
|
+
//
|
|
356
|
+
// return newState;
|
|
357
|
+
// });
|
|
358
|
+
// }
|
|
323
359
|
// };
|
|
360
|
+
|
|
361
|
+
// function prepareFirstPage(initData: MessageEntity[]) {
|
|
362
|
+
// const firstPageSize = messagesViewModel.messages.length;
|
|
363
|
+
//
|
|
364
|
+
// for (let i = firstPageSize - 1; i >= 0; i -= 1) {
|
|
365
|
+
// initData.push(messagesViewModel.messages[i]);
|
|
366
|
+
// }
|
|
367
|
+
// }
|
|
368
|
+
|
|
369
|
+
//
|
|
370
|
+
// useEffect(() => {
|
|
371
|
+
// setDialogMessageCount(messagesViewModel?.messages?.length || 0);
|
|
372
|
+
// if (messagesToView?.length === 0 && messagesViewModel.messages.length > 0) {
|
|
373
|
+
// const initData: MessageEntity[] = [];
|
|
374
|
+
//
|
|
375
|
+
// console.log(JSON.stringify(messagesViewModel.messages));
|
|
376
|
+
// prepareFirstPage(initData);
|
|
377
|
+
// setMessagesToView(initData);
|
|
378
|
+
// } else if (messagesViewModel.messages.length - messagesToView.length >= 1) {
|
|
379
|
+
// setHasMore(true);
|
|
380
|
+
// setScrollUpToDown(true);
|
|
381
|
+
// }
|
|
382
|
+
// }, [messagesViewModel.messages]);
|
|
383
|
+
//
|
|
384
|
+
// useEffect(() => {
|
|
385
|
+
// if (messagesViewModel.messages.length - messagesToView.length >= 1) {
|
|
386
|
+
// fetchMoreData();
|
|
387
|
+
// }
|
|
388
|
+
// }, [dialogMessagesCount]);
|
|
389
|
+
const messagePerPage = 47;
|
|
390
|
+
|
|
391
|
+
useEffect(() => {
|
|
392
|
+
if (messagesViewModel.entity) {
|
|
393
|
+
messagesViewModel.getMessages(new Pagination(0, messagePerPage));
|
|
394
|
+
}
|
|
395
|
+
}, [messagesViewModel.entity]);
|
|
396
|
+
|
|
397
|
+
const fetchMoreData = () => {
|
|
398
|
+
if (messagesViewModel.pagination.hasNextPage()) {
|
|
399
|
+
const newPagination = messagesViewModel.pagination;
|
|
400
|
+
|
|
401
|
+
newPagination.perPage = messagePerPage;
|
|
402
|
+
newPagination.nextPage();
|
|
403
|
+
|
|
404
|
+
messagesViewModel.getMessages(newPagination);
|
|
405
|
+
}
|
|
406
|
+
};
|
|
407
|
+
|
|
324
408
|
const userViewModel = useUsersListViewModel(selectedDialog);
|
|
325
409
|
const [dialogAvatarUrl, setDialogAvatarUrl] = React.useState('');
|
|
326
410
|
const getUserAvatarByUid = async () => {
|
|
@@ -417,23 +501,10 @@ const QuickBloxUIKitDesktopLayout: React.FC<
|
|
|
417
501
|
const [waitAIWidget, setWaitAIWidget] = useState<boolean>(false);
|
|
418
502
|
const [messageText, setMessageText] = useState<string>('');
|
|
419
503
|
|
|
420
|
-
// must re-create as result dialog changing
|
|
421
|
-
const messagesViewModel: DialogViewModel = useDialogViewModel(
|
|
422
|
-
dialogsViewModel.entity?.type,
|
|
423
|
-
dialogsViewModel.entity,
|
|
424
|
-
);
|
|
425
|
-
|
|
426
504
|
const [warningErrorText, setWarningErrorText] = useState<string>('');
|
|
427
505
|
// const [showErrorToast, setShowErrorToast] = useState<boolean>(false);
|
|
428
506
|
// const [messageErrorToast, setMessageErrorToast] = useState<string>('');
|
|
429
507
|
|
|
430
|
-
const [dialogMessagesCount, setDialogMessageCount] = useState(100);
|
|
431
|
-
const [hasMore, setHasMore] = React.useState(true);
|
|
432
|
-
const [scrollUpToDown, setScrollUpToDown] = React.useState(false);
|
|
433
|
-
const [messagesToView, setMessagesToView] = React.useState<MessageEntity[]>(
|
|
434
|
-
[],
|
|
435
|
-
);
|
|
436
|
-
|
|
437
508
|
const [useAudioWidget, setUseAudioWidget] = useState<boolean>(false);
|
|
438
509
|
|
|
439
510
|
const [fileToSend, setFileToSend] = useState<File | null>(null);
|
|
@@ -740,15 +811,10 @@ const QuickBloxUIKitDesktopLayout: React.FC<
|
|
|
740
811
|
//
|
|
741
812
|
useEffect(() => {
|
|
742
813
|
messagesViewModel.entity = dialogsViewModel.entity;
|
|
743
|
-
setMessagesToView([]);
|
|
814
|
+
// setMessagesToView([]);
|
|
744
815
|
setMessageText('');
|
|
745
816
|
}, [dialogsViewModel.entity]);
|
|
746
817
|
|
|
747
|
-
useEffect(() => {
|
|
748
|
-
if (messagesViewModel.entity) {
|
|
749
|
-
messagesViewModel.getMessages(new Pagination());
|
|
750
|
-
}
|
|
751
|
-
}, [messagesViewModel.entity]);
|
|
752
818
|
//
|
|
753
819
|
useEffect(() => {
|
|
754
820
|
if (!isMobile && messagesViewModel.entity) {
|
|
@@ -765,13 +831,6 @@ const QuickBloxUIKitDesktopLayout: React.FC<
|
|
|
765
831
|
};
|
|
766
832
|
}, [messagesViewModel?.loading]);
|
|
767
833
|
//
|
|
768
|
-
function prepareFirstPage(initData: MessageEntity[]) {
|
|
769
|
-
const firstPageSize = messagesViewModel.messages.length;
|
|
770
|
-
|
|
771
|
-
for (let i = firstPageSize - 1; i >= 0; i -= 1) {
|
|
772
|
-
initData.push(messagesViewModel.messages[i]);
|
|
773
|
-
}
|
|
774
|
-
}
|
|
775
834
|
|
|
776
835
|
const ChangeFileHandler = (event: React.ChangeEvent<HTMLInputElement>) => {
|
|
777
836
|
const reader = new FileReader();
|
|
@@ -786,51 +845,6 @@ const QuickBloxUIKitDesktopLayout: React.FC<
|
|
|
786
845
|
if (file !== null) reader.readAsDataURL(file);
|
|
787
846
|
};
|
|
788
847
|
|
|
789
|
-
const fetchMoreData = () => {
|
|
790
|
-
if (messagesToView.length >= dialogMessagesCount) {
|
|
791
|
-
setHasMore(false);
|
|
792
|
-
|
|
793
|
-
return;
|
|
794
|
-
}
|
|
795
|
-
if (
|
|
796
|
-
hasMore &&
|
|
797
|
-
messagesToView.length > 0 &&
|
|
798
|
-
messagesToView.length < dialogMessagesCount
|
|
799
|
-
) {
|
|
800
|
-
setMessagesToView((prevState) => {
|
|
801
|
-
const newState = [...prevState];
|
|
802
|
-
|
|
803
|
-
const newMessageEntity: MessageEntity =
|
|
804
|
-
messagesViewModel.messages[prevState.length];
|
|
805
|
-
|
|
806
|
-
newState.push(newMessageEntity);
|
|
807
|
-
// newState.unshift(newMessageEntity);
|
|
808
|
-
|
|
809
|
-
return newState;
|
|
810
|
-
});
|
|
811
|
-
}
|
|
812
|
-
};
|
|
813
|
-
|
|
814
|
-
//
|
|
815
|
-
useEffect(() => {
|
|
816
|
-
setDialogMessageCount(messagesViewModel?.messages?.length || 0);
|
|
817
|
-
if (messagesToView?.length === 0 && messagesViewModel.messages.length > 0) {
|
|
818
|
-
const initData: MessageEntity[] = [];
|
|
819
|
-
|
|
820
|
-
console.log(JSON.stringify(messagesViewModel.messages));
|
|
821
|
-
prepareFirstPage(initData);
|
|
822
|
-
setMessagesToView(initData);
|
|
823
|
-
} else if (messagesViewModel.messages.length - messagesToView.length >= 1) {
|
|
824
|
-
setHasMore(true);
|
|
825
|
-
setScrollUpToDown(true);
|
|
826
|
-
}
|
|
827
|
-
}, [messagesViewModel.messages]);
|
|
828
|
-
//
|
|
829
|
-
useEffect(() => {
|
|
830
|
-
if (messagesViewModel.messages.length - messagesToView.length >= 1) {
|
|
831
|
-
fetchMoreData();
|
|
832
|
-
}
|
|
833
|
-
}, [dialogMessagesCount]);
|
|
834
848
|
//
|
|
835
849
|
//
|
|
836
850
|
const maxWidthToResizing =
|
|
@@ -877,8 +891,9 @@ const QuickBloxUIKitDesktopLayout: React.FC<
|
|
|
877
891
|
|
|
878
892
|
function getSectionData(messages2View: MessageEntity[]) {
|
|
879
893
|
const groupMessages: { [date: string]: MessageEntity[] } = {};
|
|
894
|
+
const reversedMessages = [...messages2View].reverse();
|
|
880
895
|
|
|
881
|
-
|
|
896
|
+
reversedMessages.forEach((message) => {
|
|
882
897
|
const date = new Date(message.created_at);
|
|
883
898
|
|
|
884
899
|
date.setUTCHours(0, 0, 0, 0);
|
|
@@ -893,12 +908,18 @@ const QuickBloxUIKitDesktopLayout: React.FC<
|
|
|
893
908
|
Object.keys(groupMessages).forEach((date) => {
|
|
894
909
|
groupMessages[date].sort((a, b) => a.date_sent - b.date_sent);
|
|
895
910
|
});
|
|
896
|
-
const sections: SectionItem<MessageEntity>[] = Object.keys(
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
911
|
+
const sections: SectionItem<MessageEntity>[] = Object.keys(groupMessages)
|
|
912
|
+
.sort((a, b) => a.localeCompare(b))
|
|
913
|
+
.map((date) => ({
|
|
914
|
+
title: date,
|
|
915
|
+
data: { [date]: groupMessages[date] },
|
|
916
|
+
}));
|
|
917
|
+
// const sections: SectionItem<MessageEntity>[] = Object.keys(
|
|
918
|
+
// groupMessages,
|
|
919
|
+
// ).map((date) => ({
|
|
920
|
+
// title: date,
|
|
921
|
+
// data: { [date]: groupMessages[date] },
|
|
922
|
+
// }));
|
|
902
923
|
|
|
903
924
|
return sections;
|
|
904
925
|
}
|
|
@@ -1148,9 +1169,7 @@ const QuickBloxUIKitDesktopLayout: React.FC<
|
|
|
1148
1169
|
renderMessageList={
|
|
1149
1170
|
messagesViewModel &&
|
|
1150
1171
|
messagesViewModel.messages &&
|
|
1151
|
-
messagesViewModel.messages.length > 0 &&
|
|
1152
|
-
messagesToView &&
|
|
1153
|
-
messagesToView.length > 0 && (
|
|
1172
|
+
messagesViewModel.messages.length > 0 && (
|
|
1154
1173
|
<SectionList
|
|
1155
1174
|
resetScroll={scrollUpToDown}
|
|
1156
1175
|
className="messages-container"
|
|
@@ -1179,7 +1198,7 @@ const QuickBloxUIKitDesktopLayout: React.FC<
|
|
|
1179
1198
|
<MessageItem
|
|
1180
1199
|
// defaultGetSenderName={defaultGetSenderName}
|
|
1181
1200
|
message={message}
|
|
1182
|
-
|
|
1201
|
+
currentUserId={currentUserId || -1}
|
|
1183
1202
|
enableForwarding={enableForwarding}
|
|
1184
1203
|
enableReplying={enableReplying}
|
|
1185
1204
|
onReply={(m: MessageEntity) => {
|
|
@@ -1203,12 +1222,12 @@ const QuickBloxUIKitDesktopLayout: React.FC<
|
|
|
1203
1222
|
onError={(messageError: string) => {
|
|
1204
1223
|
toast(messageError);
|
|
1205
1224
|
}}
|
|
1206
|
-
messagesToView={
|
|
1225
|
+
messagesToView={messagesViewModel.messages}
|
|
1207
1226
|
maxTokens={maxTokensForAIRephrase}
|
|
1208
1227
|
/>
|
|
1209
1228
|
))
|
|
1210
1229
|
}
|
|
1211
|
-
sections={getSectionData(
|
|
1230
|
+
sections={getSectionData(messagesViewModel.messages)}
|
|
1212
1231
|
/>
|
|
1213
1232
|
)
|
|
1214
1233
|
}
|
|
@@ -1260,8 +1279,8 @@ const QuickBloxUIKitDesktopLayout: React.FC<
|
|
|
1260
1279
|
setMessageErrorToast={(e: string) => {
|
|
1261
1280
|
toast(e);
|
|
1262
1281
|
}}
|
|
1263
|
-
messagesToView={
|
|
1264
|
-
currentUserId={
|
|
1282
|
+
messagesToView={messagesViewModel.messages}
|
|
1283
|
+
currentUserId={currentUserId || -1}
|
|
1265
1284
|
maxTokensForAIRephrase={maxTokensForAIRephrase}
|
|
1266
1285
|
rephraseTones={rephraseTones}
|
|
1267
1286
|
/>
|
|
@@ -3,7 +3,7 @@ import type { Meta, StoryObj } from '@storybook/react';
|
|
|
3
3
|
import Badge from './Badge';
|
|
4
4
|
|
|
5
5
|
const meta: Meta<typeof Badge> = {
|
|
6
|
-
title: 'Badge',
|
|
6
|
+
title: '@quickblox-react-ui-kit/Presentation/ui-components/Badge',
|
|
7
7
|
component: Badge,
|
|
8
8
|
tags: ['autodocs'],
|
|
9
9
|
parameters: {
|
|
@@ -3,7 +3,7 @@ import type { Meta, StoryObj } from '@storybook/react';
|
|
|
3
3
|
import DialogBanner from './DialogBanner';
|
|
4
4
|
|
|
5
5
|
const meta = {
|
|
6
|
-
title: 'DialogBanner',
|
|
6
|
+
title: '@quickblox-react-ui-kit/Presentation/ui-components/DialogBanner',
|
|
7
7
|
component: DialogBanner,
|
|
8
8
|
tags: ['autodocs'],
|
|
9
9
|
parameters: {
|
|
@@ -32,6 +32,7 @@ export default meta;
|
|
|
32
32
|
type Story = StoryObj<typeof meta>;
|
|
33
33
|
|
|
34
34
|
export const DialogBannerDefault: Story = {
|
|
35
|
+
name: 'DialogBanner Default',
|
|
35
36
|
args: {
|
|
36
37
|
text: '3 new messages',
|
|
37
38
|
},
|
|
@@ -14,7 +14,7 @@ import PreviewFileMessage from '../PreviewFileMessage/PreviewFileMessage';
|
|
|
14
14
|
import Dropdown from '../Dropdown/Dropdown';
|
|
15
15
|
|
|
16
16
|
const meta: Meta<typeof DialogItemPreview> = {
|
|
17
|
-
title: 'DialogItemPreview',
|
|
17
|
+
title: '@quickblox-react-ui-kit/Presentation/ui-components/DialogItemPreview',
|
|
18
18
|
tags: ['autodocs'],
|
|
19
19
|
component: DialogItemPreview,
|
|
20
20
|
decorators: [],
|
|
@@ -111,13 +111,21 @@ export default meta;
|
|
|
111
111
|
type Story = StoryObj<typeof meta>;
|
|
112
112
|
|
|
113
113
|
export const DialogItemPreviewDefault: Story = {
|
|
114
|
+
name: 'DialogItemPreview Default',
|
|
114
115
|
args: {
|
|
115
116
|
title: 'Name',
|
|
116
117
|
avatar: <Avatar size="lg" icon={<UserSvg />} />,
|
|
117
118
|
},
|
|
119
|
+
render: (args) => {
|
|
120
|
+
// eslint-disable-next-line no-param-reassign
|
|
121
|
+
args.date = new Date(args.date!).toLocaleDateString();
|
|
122
|
+
|
|
123
|
+
return <DialogItemPreview {...args} />;
|
|
124
|
+
},
|
|
118
125
|
};
|
|
119
126
|
|
|
120
127
|
export const DialogItemPreviewFullScreen: Story = {
|
|
128
|
+
name: 'DialogItemPreview FullScreen',
|
|
121
129
|
args: {
|
|
122
130
|
title: 'Name',
|
|
123
131
|
avatar: <Avatar size="lg" icon={<UserSvg />} />,
|
|
@@ -131,9 +139,16 @@ export const DialogItemPreviewFullScreen: Story = {
|
|
|
131
139
|
defaultViewport: 'responsive',
|
|
132
140
|
},
|
|
133
141
|
},
|
|
142
|
+
render: (args) => {
|
|
143
|
+
// eslint-disable-next-line no-param-reassign
|
|
144
|
+
args.date = new Date(args.date!).toLocaleDateString();
|
|
145
|
+
|
|
146
|
+
return <DialogItemPreview {...args} />;
|
|
147
|
+
},
|
|
134
148
|
};
|
|
135
149
|
|
|
136
150
|
export const DialogItemPreviewMobileScreen: Story = {
|
|
151
|
+
name: 'DialogItemPreview MobileScreen',
|
|
137
152
|
args: {
|
|
138
153
|
title: 'Name',
|
|
139
154
|
avatar: <Avatar size="lg" icon={<UserSvg />} />,
|
|
@@ -147,9 +162,16 @@ export const DialogItemPreviewMobileScreen: Story = {
|
|
|
147
162
|
defaultViewport: 'iphonese2',
|
|
148
163
|
},
|
|
149
164
|
},
|
|
165
|
+
render: (args) => {
|
|
166
|
+
// eslint-disable-next-line no-param-reassign
|
|
167
|
+
args.date = new Date(args.date!).toLocaleDateString();
|
|
168
|
+
|
|
169
|
+
return <DialogItemPreview {...args} />;
|
|
170
|
+
},
|
|
150
171
|
};
|
|
151
172
|
|
|
152
173
|
export const DialogItemPreviewMobileScreenIPad: Story = {
|
|
174
|
+
name: 'DialogItemPreview MobileScreen IPad',
|
|
153
175
|
args: {
|
|
154
176
|
title: 'Name',
|
|
155
177
|
avatar: <Avatar size="lg" icon={<UserSvg />} />,
|
|
@@ -163,4 +185,10 @@ export const DialogItemPreviewMobileScreenIPad: Story = {
|
|
|
163
185
|
defaultViewport: 'ipad',
|
|
164
186
|
},
|
|
165
187
|
},
|
|
188
|
+
render: (args) => {
|
|
189
|
+
// eslint-disable-next-line no-param-reassign
|
|
190
|
+
args.date = new Date(args.date!).toLocaleDateString();
|
|
191
|
+
|
|
192
|
+
return <DialogItemPreview {...args} />;
|
|
193
|
+
},
|
|
166
194
|
};
|
|
@@ -53,7 +53,10 @@ const DialogItemPreview: React.FC<DialogItemPreviewProps> = ({
|
|
|
53
53
|
<div className="dialog-item-preview__content-bottom-message">
|
|
54
54
|
{lastMessage}
|
|
55
55
|
</div>
|
|
56
|
-
<div
|
|
56
|
+
<div
|
|
57
|
+
onClick={(event) => event.stopPropagation()}
|
|
58
|
+
className="dialog-item-preview__content-bottom-controls"
|
|
59
|
+
>
|
|
57
60
|
{badge}
|
|
58
61
|
{contextMenu && (
|
|
59
62
|
<div className="dialog-item-preview__content-bottom-controls-menu">
|
|
@@ -5,7 +5,7 @@ import DialogWindow from './DialogWindow';
|
|
|
5
5
|
import Button from '../Button/Button';
|
|
6
6
|
|
|
7
7
|
const meta: Meta<typeof DialogWindow> = {
|
|
8
|
-
title: '
|
|
8
|
+
title: '@quickblox-react-ui-kit/Presentation/ui-components/DialogWindow',
|
|
9
9
|
component: DialogWindow,
|
|
10
10
|
tags: ['autodocs'],
|
|
11
11
|
parameters: {
|
|
@@ -102,5 +102,6 @@ function DialogWindowExample() {
|
|
|
102
102
|
}
|
|
103
103
|
|
|
104
104
|
export const DialogWindowDefault: StoryDefault = {
|
|
105
|
+
name: 'DialogWindow Default',
|
|
105
106
|
render: () => <DialogWindowExample />,
|
|
106
107
|
};
|
|
@@ -5,7 +5,7 @@ import Dropdown from './Dropdown';
|
|
|
5
5
|
import Button from '../Button/Button';
|
|
6
6
|
|
|
7
7
|
const meta: Meta<typeof Dropdown> = {
|
|
8
|
-
title: 'Dropdown',
|
|
8
|
+
title: '@quickblox-react-ui-kit/Presentation/ui-components/Dropdown',
|
|
9
9
|
component: Dropdown,
|
|
10
10
|
tags: ['autodocs'],
|
|
11
11
|
parameters: {
|
|
@@ -20,6 +20,7 @@ const meta: Meta<typeof Dropdown> = {
|
|
|
20
20
|
},
|
|
21
21
|
argTypes: {
|
|
22
22
|
children: {
|
|
23
|
+
control: false,
|
|
23
24
|
table: {
|
|
24
25
|
defaultValue: {
|
|
25
26
|
summary: null,
|
|
@@ -53,7 +53,10 @@ export default function Dropdown({
|
|
|
53
53
|
}
|
|
54
54
|
};
|
|
55
55
|
|
|
56
|
-
if (isOpen)
|
|
56
|
+
if (isOpen)
|
|
57
|
+
document.addEventListener('click', handleBlur, {
|
|
58
|
+
capture: true,
|
|
59
|
+
});
|
|
57
60
|
|
|
58
61
|
return () => document.removeEventListener('click', handleBlur);
|
|
59
62
|
}, [isOpen]);
|
|
@@ -13,7 +13,7 @@ import {
|
|
|
13
13
|
import Avatar from '../Avatar/Avatar';
|
|
14
14
|
|
|
15
15
|
const meta: Meta = {
|
|
16
|
-
title: 'Header',
|
|
16
|
+
title: '@quickblox-react-ui-kit/Presentation/ui-components/Header',
|
|
17
17
|
component: Header,
|
|
18
18
|
tags: ['autodocs'],
|
|
19
19
|
parameters: {
|
|
@@ -42,6 +42,7 @@ const meta: Meta = {
|
|
|
42
42
|
},
|
|
43
43
|
},
|
|
44
44
|
badge: {
|
|
45
|
+
control: false,
|
|
45
46
|
description: 'Badge or dialog status',
|
|
46
47
|
},
|
|
47
48
|
children: {
|
|
@@ -52,7 +52,12 @@ export default function AttachmentBubble({
|
|
|
52
52
|
/>
|
|
53
53
|
);
|
|
54
54
|
}
|
|
55
|
-
|
|
55
|
+
|
|
56
|
+
if (
|
|
57
|
+
attachment.type.toString().split('/')[1] !== 'heic' &&
|
|
58
|
+
attachment.type.toString().split('/')[1] !== 'heif' &&
|
|
59
|
+
attachment.type.toString().includes(FileType.image)
|
|
60
|
+
) {
|
|
56
61
|
return <ImageBubble title={attachment.file?.name || ''} href={fileUrl} />;
|
|
57
62
|
}
|
|
58
63
|
|
|
@@ -3,6 +3,12 @@
|
|
|
3
3
|
gap: 5px;
|
|
4
4
|
flex-direction: row;
|
|
5
5
|
align-items: center;
|
|
6
|
+
|
|
7
|
+
&__equalizer-time {
|
|
8
|
+
display: flex;
|
|
9
|
+
flex-direction: column;
|
|
10
|
+
gap: 2px;
|
|
11
|
+
}
|
|
6
12
|
}
|
|
7
13
|
.audio-body{
|
|
8
14
|
padding: 5px;
|
|
@@ -40,6 +46,13 @@
|
|
|
40
46
|
}
|
|
41
47
|
}
|
|
42
48
|
|
|
49
|
+
.time-play {
|
|
50
|
+
color: var(--secondary-text, #636d78);
|
|
51
|
+
text-align: left;
|
|
52
|
+
font: var(--label-label-small);
|
|
53
|
+
height: 16px;
|
|
54
|
+
}
|
|
55
|
+
|
|
43
56
|
.audio-bubble-background {
|
|
44
57
|
|
|
45
58
|
&__incoming {
|