quickblox-react-ui-kit 0.5.1-beta.1 → 0.5.1-join-dialog-off.1
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/CommonTypes/BaseViewModel.d.ts +2 -0
- package/dist/CommonTypes/BaseViewModel.d.ts.map +1 -1
- package/dist/CommonTypes/CommonTypes.d.ts +1 -0
- package/dist/CommonTypes/CommonTypes.d.ts.map +1 -1
- package/dist/Data/Stubs.d.ts.map +1 -1
- package/dist/Data/dto/dialog/RemoteDialogDTO.d.ts +1 -0
- package/dist/Data/dto/dialog/RemoteDialogDTO.d.ts.map +1 -1
- package/dist/Data/mapper/DialogRemoteDTOMapper.d.ts.map +1 -1
- package/dist/Data/repository/DialogsRepository.d.ts +3 -0
- package/dist/Data/repository/DialogsRepository.d.ts.map +1 -1
- package/dist/Data/source/remote/IRemoteDataSource.d.ts +3 -0
- package/dist/Data/source/remote/IRemoteDataSource.d.ts.map +1 -1
- package/dist/Data/source/remote/Mapper/DialogDTOMapper.d.ts.map +1 -1
- package/dist/Data/source/remote/RemoteDataSource.d.ts +3 -0
- package/dist/Data/source/remote/RemoteDataSource.d.ts.map +1 -1
- package/dist/Domain/repository/IDialogsRepository.d.ts +3 -0
- package/dist/Domain/repository/IDialogsRepository.d.ts.map +1 -1
- package/dist/Domain/use_cases/CreateDialogWithAutoJoinUseCase.d.ts +13 -0
- package/dist/Domain/use_cases/CreateDialogWithAutoJoinUseCase.d.ts.map +1 -0
- package/dist/Domain/use_cases/JoinFromTheDialogUseCase.d.ts +11 -0
- package/dist/Domain/use_cases/JoinFromTheDialogUseCase.d.ts.map +1 -0
- package/dist/Domain/use_cases/UnJoinFromTheDialogUseCase.d.ts +11 -0
- package/dist/Domain/use_cases/UnJoinFromTheDialogUseCase.d.ts.map +1 -0
- package/dist/Presentation/Views/Dialog/useDialogViewModel.d.ts.map +1 -1
- package/dist/Presentation/Views/DialogInfo/DialogInfo.d.ts.map +1 -1
- package/dist/Presentation/Views/DialogList/DialogListViewModel.d.ts +4 -1
- package/dist/Presentation/Views/DialogList/DialogListViewModel.d.ts.map +1 -1
- package/dist/Presentation/Views/DialogList/useDialogListViewModel.d.ts.map +1 -1
- package/dist/Presentation/Views/EditDialog/EditDialog.d.ts.map +1 -1
- package/dist/Presentation/Views/Flow/CreateDialogFlow/CreateNewDialogFlow.d.ts.map +1 -1
- package/dist/QBconfig.d.ts.map +1 -1
- package/dist/index-ui.js +438 -90
- package/dist/qb-api-calls/index.d.ts +2 -0
- package/dist/qb-api-calls/index.d.ts.map +1 -1
- package/package.json +2 -2
- package/src/CommonTypes/BaseViewModel.ts +4 -0
- package/src/CommonTypes/CommonTypes.ts +1 -0
- package/src/Data/Stubs.ts +20 -10
- package/src/Data/dto/dialog/RemoteDialogDTO.ts +4 -0
- package/src/Data/mapper/DialogRemoteDTOMapper.ts +6 -0
- package/src/Data/repository/DialogsRepository.ts +57 -0
- package/src/Data/source/remote/IRemoteDataSource.ts +10 -0
- package/src/Data/source/remote/Mapper/DialogDTOMapper.ts +13 -0
- package/src/Data/source/remote/RemoteDataSource.ts +163 -65
- package/src/Domain/repository/IDialogsRepository.ts +10 -0
- package/src/Domain/use_cases/CreateDialogWithAutoJoinUseCase.ts +77 -0
- package/src/Domain/use_cases/JoinFromTheDialogUseCase.ts +61 -0
- package/src/Domain/use_cases/UnJoinFromTheDialogUseCase.ts +61 -0
- package/src/Presentation/Views/Dialog/useDialogViewModel.ts +46 -4
- package/src/Presentation/Views/DialogInfo/DialogInfo.tsx +36 -1
- package/src/Presentation/Views/DialogList/DialogListViewModel.ts +4 -1
- package/src/Presentation/Views/DialogList/useDialogListViewModel.ts +141 -12
- package/src/Presentation/Views/EditDialog/EditDialog.scss +18 -0
- package/src/Presentation/Views/EditDialog/EditDialog.tsx +10 -1
- package/src/Presentation/Views/Flow/CreateDialogFlow/CreateNewDialogFlow.tsx +25 -10
- package/src/Presentation/layouts/Desktop/DesktopLayout.scss +7 -0
- package/src/Presentation/ui-components/Header/Header.scss +7 -0
- package/src/QBconfig.ts +2 -0
- package/src/qb-api-calls/index.ts +88 -42
- package/storybook-static/{217.07d5c7a3.iframe.bundle.js → 217.f067a49f.iframe.bundle.js} +3 -3
- package/storybook-static/{217.07d5c7a3.iframe.bundle.js.map → 217.f067a49f.iframe.bundle.js.map} +1 -1
- package/storybook-static/{363.a2d33b79.iframe.bundle.js → 363.f6fcc1b9.iframe.bundle.js} +2 -2
- package/storybook-static/844.be4346f2.iframe.bundle.js +95 -0
- package/storybook-static/844.be4346f2.iframe.bundle.js.map +1 -0
- package/storybook-static/Presentation-ui-components-DialogWindow-DialogWindow-stories.46997cb0.iframe.bundle.js +2 -0
- package/storybook-static/Presentation-ui-components-Header-Header-stories.a4edfcc6.iframe.bundle.js +2 -0
- package/storybook-static/{Presentation-ui-components-MessageInput-MessageInput-stories.9b4b2514.iframe.bundle.js → Presentation-ui-components-MessageInput-MessageInput-stories.2af0de55.iframe.bundle.js} +1 -1
- package/storybook-static/docs-Introduction-mdx.46ed11c4.iframe.bundle.js +1 -0
- package/storybook-static/docs-Styling-mdx.3a86be03.iframe.bundle.js +1 -0
- package/storybook-static/iframe.html +2 -2
- package/storybook-static/project.json +1 -1
- package/storybook-static/{runtime~main.940703c6.iframe.bundle.js → runtime~main.ebabbef9.iframe.bundle.js} +1 -1
- package/storybook-static/sb-addons/essentials-backgrounds-5/manager-bundle.js +1 -1
- package/storybook-static/sb-addons/essentials-controls-2/manager-bundle.js +8 -8
- package/storybook-static/sb-addons/essentials-docs-4/manager-bundle.js +4 -4
- package/storybook-static/sb-addons/essentials-measure-8/manager-bundle.js +1 -1
- package/storybook-static/sb-addons/essentials-outline-9/manager-bundle.js +1 -1
- package/storybook-static/sb-addons/essentials-viewport-6/manager-bundle.js +1 -1
- package/storybook-static/sb-addons/interactions-11/manager-bundle.js +1 -1
- package/storybook-static/sb-addons/onboarding-1/manager-bundle.js +1 -1
- package/storybook-static/sb-manager/globals-module-info.js +1 -0
- package/storybook-static/sb-manager/globals-runtime.js +10372 -9836
- package/storybook-static/sb-manager/runtime.js +119 -119
- package/webpack.app.config.js +3 -3
- package/storybook-static/844.e8bfd664.iframe.bundle.js +0 -95
- package/storybook-static/844.e8bfd664.iframe.bundle.js.map +0 -1
- package/storybook-static/Presentation-ui-components-DialogWindow-DialogWindow-stories.a724643f.iframe.bundle.js +0 -2
- package/storybook-static/Presentation-ui-components-Header-Header-stories.978f0af5.iframe.bundle.js +0 -2
- package/storybook-static/docs-Introduction-mdx.5addfa61.iframe.bundle.js +0 -1
- package/storybook-static/docs-Styling-mdx.9f4235f1.iframe.bundle.js +0 -1
- /package/storybook-static/{217.07d5c7a3.iframe.bundle.js.LICENSE.txt → 217.f067a49f.iframe.bundle.js.LICENSE.txt} +0 -0
- /package/storybook-static/{363.a2d33b79.iframe.bundle.js.LICENSE.txt → 363.f6fcc1b9.iframe.bundle.js.LICENSE.txt} +0 -0
- /package/storybook-static/{844.e8bfd664.iframe.bundle.js.LICENSE.txt → 844.be4346f2.iframe.bundle.js.LICENSE.txt} +0 -0
- /package/storybook-static/{Presentation-ui-components-DialogWindow-DialogWindow-stories.a724643f.iframe.bundle.js.LICENSE.txt → Presentation-ui-components-DialogWindow-DialogWindow-stories.46997cb0.iframe.bundle.js.LICENSE.txt} +0 -0
- /package/storybook-static/{Presentation-ui-components-Header-Header-stories.978f0af5.iframe.bundle.js.LICENSE.txt → Presentation-ui-components-Header-Header-stories.a4edfcc6.iframe.bundle.js.LICENSE.txt} +0 -0
|
@@ -25,11 +25,12 @@ import UiKitTheme from '../../themes/UiKitTheme';
|
|
|
25
25
|
import { UserEntity } from '../../../Domain/entity/UserEntity';
|
|
26
26
|
import useUsersListViewModel from './UsersList/useUsersListViewModel';
|
|
27
27
|
import { PrivateDialogEntity } from '../../../Domain/entity/PrivateDialogEntity';
|
|
28
|
-
import { CloseSvg, GroupChatSvg, LeaveSvg } from '../../icons';
|
|
28
|
+
import { CloseSvg, GroupChatSvg, LeaveSvg, SettingsFilledSvg } from '../../icons';
|
|
29
29
|
import { Badge, Button, DialogWindow, SettingsItem } from '../../ui-components';
|
|
30
30
|
import useModal from '../../../hooks/useModal';
|
|
31
31
|
import Header from '../../ui-components/Header/Header';
|
|
32
32
|
import InviteMembers from '../InviteMembers/InviteMembers';
|
|
33
|
+
import { stringifyError } from '../../../utils/parse';
|
|
33
34
|
|
|
34
35
|
type HeaderDialogsProps = {
|
|
35
36
|
dialog: DialogEntity;
|
|
@@ -487,6 +488,40 @@ const DialogInfo = ({
|
|
|
487
488
|
</Button>
|
|
488
489
|
</div>
|
|
489
490
|
</DialogWindow>
|
|
491
|
+
<SettingsItem
|
|
492
|
+
icon={<SettingsFilledSvg />}
|
|
493
|
+
title="UnJoin dialog"
|
|
494
|
+
onClick={!disableAction ? () => {
|
|
495
|
+
dialogViewModel
|
|
496
|
+
.unJoinDialog(dialog as GroupDialogEntity)
|
|
497
|
+
.then((result) => {
|
|
498
|
+
return result;
|
|
499
|
+
})
|
|
500
|
+
.catch((e) => {
|
|
501
|
+
console.log('exception in UnJoinDialogFlow', stringifyError(e));
|
|
502
|
+
});
|
|
503
|
+
}: undefined}
|
|
504
|
+
className={cn('dialog-info-leave', {
|
|
505
|
+
'dialog-info-leave--disable': disableAction,
|
|
506
|
+
})}
|
|
507
|
+
/>
|
|
508
|
+
<SettingsItem
|
|
509
|
+
icon={<SettingsFilledSvg />}
|
|
510
|
+
title="Join dialog"
|
|
511
|
+
onClick={!disableAction ? () => {
|
|
512
|
+
dialogViewModel
|
|
513
|
+
.joinToDialog(dialog as GroupDialogEntity)
|
|
514
|
+
.then((result) => {
|
|
515
|
+
return result;
|
|
516
|
+
})
|
|
517
|
+
.catch((e) => {
|
|
518
|
+
console.log('exception in JoinDialogFlow', stringifyError(e));
|
|
519
|
+
});
|
|
520
|
+
}: undefined}
|
|
521
|
+
className={cn('dialog-info-leave', {
|
|
522
|
+
'dialog-info-leave--disable': disableAction,
|
|
523
|
+
})}
|
|
524
|
+
/>
|
|
490
525
|
</ColumnContainer>
|
|
491
526
|
</div>
|
|
492
527
|
);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import BaseViewModel, {
|
|
2
2
|
FunctionTypeBooleanToVoid,
|
|
3
3
|
FunctionTypeDialogEntityToBoolean,
|
|
4
|
-
FunctionTypeDialogEntityToDialogEntity,
|
|
4
|
+
FunctionTypeDialogEntityToDialogEntity, FunctionTypeDialogEntityWithAutoJoinToDialogEntity,
|
|
5
5
|
FunctionTypeFileToFileEntity,
|
|
6
6
|
FunctionTypePaginationToVoid,
|
|
7
7
|
FunctionTypeVoidToVoid,
|
|
@@ -18,8 +18,11 @@ export interface DialogListViewModel extends BaseViewModel<DialogEntity> {
|
|
|
18
18
|
release: FunctionTypeVoidToVoid; // release Content
|
|
19
19
|
setWaitLoadingStatus: FunctionTypeBooleanToVoid; // set loading state
|
|
20
20
|
createDialog: FunctionTypeDialogEntityToDialogEntity;
|
|
21
|
+
createDialogForAutoJoin: FunctionTypeDialogEntityWithAutoJoinToDialogEntity;
|
|
21
22
|
updateDialog: FunctionTypeDialogEntityToDialogEntity;
|
|
22
23
|
deleteDialog: FunctionTypeDialogEntityToBoolean;
|
|
24
|
+
unJoinDialog: FunctionTypeDialogEntityToBoolean;
|
|
25
|
+
joinToDialog: FunctionTypeDialogEntityToBoolean;
|
|
23
26
|
uploadFile: FunctionTypeFileToFileEntity;
|
|
24
27
|
removeMembers: FunctionTypeDialogEntityToBoolean;
|
|
25
28
|
}
|
|
@@ -33,6 +33,8 @@ import UsersRepository from '../../../Data/repository/UsersRepository';
|
|
|
33
33
|
import { UserEntity } from '../../../Domain/entity/UserEntity';
|
|
34
34
|
import { DefaultConfigurations } from '../../../Data/DefaultConfigurations';
|
|
35
35
|
import { UpdateCurrentDialogInDataSourceUseCase } from '../../../Domain/use_cases/UpdateCurrentDialogInDataSourceUseCase';
|
|
36
|
+
import { CreateDialogWithAutoJoinUseCase } from '../../../Domain/use_cases/CreateDialogWithAutoJoinUseCase';
|
|
37
|
+
import { UnJoinFromTheDialogUseCase } from '../../../Domain/use_cases/UnJoinFromTheDialogUseCase';
|
|
36
38
|
|
|
37
39
|
export default function useDialogListViewModel(
|
|
38
40
|
currentContext: QBDataContextType,
|
|
@@ -245,20 +247,36 @@ export default function useDialogListViewModel(
|
|
|
245
247
|
.then((newItem) => {
|
|
246
248
|
//
|
|
247
249
|
setDialogs((prevDialogs) => {
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
250
|
+
let updatedDialogs: PublicDialogEntity[];
|
|
251
|
+
|
|
252
|
+
if (newItem.type === DialogType.private) {
|
|
253
|
+
const filteredDialogs = prevDialogs.filter(d => d.id !== newItem.id);
|
|
254
|
+
updatedDialogs = [...filteredDialogs, newItem as PublicDialogEntity];
|
|
255
|
+
} else {
|
|
256
|
+
updatedDialogs = [...prevDialogs, newItem as PublicDialogEntity];
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
const sortedDialogs = updatedDialogs.sort((a, b) => {
|
|
260
|
+
const aDate = a.lastMessage?.dateSent ?? a.updatedAt;
|
|
261
|
+
const bDate = b.lastMessage?.dateSent ?? b.updatedAt;
|
|
262
|
+
return new Date(bDate).getTime() - new Date(aDate).getTime();
|
|
259
263
|
});
|
|
260
264
|
|
|
261
|
-
return
|
|
265
|
+
return sortedDialogs;
|
|
266
|
+
// const newDialogs = [
|
|
267
|
+
// ...prevDialogs,
|
|
268
|
+
// newItem as PublicDialogEntity,
|
|
269
|
+
// ];
|
|
270
|
+
//
|
|
271
|
+
// const sortedData = [...newDialogs].sort((a, b) => {
|
|
272
|
+
// return b.lastMessage.dateSent && a.lastMessage.dateSent
|
|
273
|
+
// ? new Date(b.lastMessage.dateSent).getTime() -
|
|
274
|
+
// new Date(a.lastMessage.dateSent).getTime()
|
|
275
|
+
// : new Date(b.updatedAt).getTime() -
|
|
276
|
+
// new Date(a.updatedAt).getTime();
|
|
277
|
+
// });
|
|
278
|
+
//
|
|
279
|
+
// return sortedData;
|
|
262
280
|
});
|
|
263
281
|
//
|
|
264
282
|
})
|
|
@@ -376,6 +394,37 @@ export default function useDialogListViewModel(
|
|
|
376
394
|
return Promise.reject(resultDialog);
|
|
377
395
|
};
|
|
378
396
|
|
|
397
|
+
const createDialogForAutoJoin = async (
|
|
398
|
+
dialogInfo: GroupDialogEntity, disableAutoJoin: boolean
|
|
399
|
+
): Promise<DialogEntity> => {
|
|
400
|
+
const textInformationMessage = `${currentUserName} create the chat`;
|
|
401
|
+
const createDialogWitAutoJoinUseCase: CreateDialogWithAutoJoinUseCase = new CreateDialogWithAutoJoinUseCase(
|
|
402
|
+
eventMessageRepository,
|
|
403
|
+
new DialogsRepository(
|
|
404
|
+
currentContext.storage.LOCAL_DATA_SOURCE,
|
|
405
|
+
remoteDataSourceMock,
|
|
406
|
+
),
|
|
407
|
+
dialogInfo,
|
|
408
|
+
textInformationMessage,
|
|
409
|
+
);
|
|
410
|
+
const resultDialog: DialogEntity = await createDialogWitAutoJoinUseCase
|
|
411
|
+
.execute()
|
|
412
|
+
.catch((e) => {
|
|
413
|
+
console.log('EXCEPTION IN CREATE NEW DIALOG WITH AUTO JOIN: ', stringifyError(e));
|
|
414
|
+
setNewDialog(undefined);
|
|
415
|
+
|
|
416
|
+
throw new Error(stringifyError(e));
|
|
417
|
+
});
|
|
418
|
+
|
|
419
|
+
if (resultDialog) {
|
|
420
|
+
setNewDialog(resultDialog);
|
|
421
|
+
|
|
422
|
+
return Promise.resolve(resultDialog);
|
|
423
|
+
}
|
|
424
|
+
|
|
425
|
+
return Promise.reject(resultDialog);
|
|
426
|
+
};
|
|
427
|
+
|
|
379
428
|
const updateDialog = async (
|
|
380
429
|
// eslint-disable-next-line @typescript-eslint/no-shadow,@typescript-eslint/no-unused-vars
|
|
381
430
|
dialog: GroupDialogEntity,
|
|
@@ -478,6 +527,83 @@ export default function useDialogListViewModel(
|
|
|
478
527
|
return Promise.reject(leaveResult);
|
|
479
528
|
};
|
|
480
529
|
|
|
530
|
+
const unJoinDialog = async (
|
|
531
|
+
// eslint-disable-next-line @typescript-eslint/no-shadow,@typescript-eslint/no-unused-vars
|
|
532
|
+
dialogToDelete: GroupDialogEntity,
|
|
533
|
+
): Promise<boolean> => {
|
|
534
|
+
let unJoinResult = false;
|
|
535
|
+
|
|
536
|
+
if (dialogToDelete.type === DialogType.group) {
|
|
537
|
+
|
|
538
|
+
const usersForDeleteFromDialog: Array<number> = new Array<number>();
|
|
539
|
+
|
|
540
|
+
const userToDeleteId: number =
|
|
541
|
+
remoteDataSourceMock?.authInformation?.userId || 0;
|
|
542
|
+
|
|
543
|
+
usersForDeleteFromDialog.push(userToDeleteId);
|
|
544
|
+
const unjoinFromDialog: UnJoinFromTheDialogUseCase =
|
|
545
|
+
new UnJoinFromTheDialogUseCase(
|
|
546
|
+
eventMessageRepository,
|
|
547
|
+
new DialogsRepository(
|
|
548
|
+
currentContext.storage.LOCAL_DATA_SOURCE,
|
|
549
|
+
remoteDataSourceMock,
|
|
550
|
+
),
|
|
551
|
+
dialogToDelete,
|
|
552
|
+
);
|
|
553
|
+
|
|
554
|
+
unJoinResult = await unjoinFromDialog.execute().catch((e) => {
|
|
555
|
+
console.log(
|
|
556
|
+
'Error delete users from UnJoinFromTheDialogUseCase: ',
|
|
557
|
+
stringifyError(e),
|
|
558
|
+
);
|
|
559
|
+
throw new Error(stringifyError(e));
|
|
560
|
+
});
|
|
561
|
+
}
|
|
562
|
+
|
|
563
|
+
if (unJoinResult) {
|
|
564
|
+
return Promise.resolve(unJoinResult);
|
|
565
|
+
}
|
|
566
|
+
|
|
567
|
+
return Promise.reject(unJoinResult);
|
|
568
|
+
};
|
|
569
|
+
|
|
570
|
+
// нужно вызвать из разметки в режиме редактирования
|
|
571
|
+
const joinToDialog = async (
|
|
572
|
+
// eslint-disable-next-line @typescript-eslint/no-shadow,@typescript-eslint/no-unused-vars
|
|
573
|
+
dialogToDelete: GroupDialogEntity,
|
|
574
|
+
): Promise<boolean> => {
|
|
575
|
+
let joinResult = false;
|
|
576
|
+
|
|
577
|
+
if (dialogToDelete.type === DialogType.group) {
|
|
578
|
+
|
|
579
|
+
|
|
580
|
+
const unjoinFromDialog: UnJoinFromTheDialogUseCase =
|
|
581
|
+
new UnJoinFromTheDialogUseCase(
|
|
582
|
+
eventMessageRepository,
|
|
583
|
+
new DialogsRepository(
|
|
584
|
+
currentContext.storage.LOCAL_DATA_SOURCE,
|
|
585
|
+
remoteDataSourceMock,
|
|
586
|
+
),
|
|
587
|
+
dialogToDelete,
|
|
588
|
+
);
|
|
589
|
+
|
|
590
|
+
joinResult = await unjoinFromDialog.execute().catch((e) => {
|
|
591
|
+
console.log(
|
|
592
|
+
'Error delete users from UnJoinFromTheDialogUseCase: ',
|
|
593
|
+
stringifyError(e),
|
|
594
|
+
);
|
|
595
|
+
throw new Error(stringifyError(e));
|
|
596
|
+
});
|
|
597
|
+
}
|
|
598
|
+
|
|
599
|
+
if (joinResult) {
|
|
600
|
+
return Promise.resolve(joinResult);
|
|
601
|
+
}
|
|
602
|
+
|
|
603
|
+
return Promise.reject(joinResult);
|
|
604
|
+
};
|
|
605
|
+
|
|
606
|
+
|
|
481
607
|
const removeMembers = async (dialog: GroupDialogEntity): Promise<boolean> => {
|
|
482
608
|
let leaveResult = false;
|
|
483
609
|
|
|
@@ -575,8 +701,11 @@ export default function useDialogListViewModel(
|
|
|
575
701
|
getDialogs,
|
|
576
702
|
release,
|
|
577
703
|
createDialog,
|
|
704
|
+
createDialogForAutoJoin,
|
|
578
705
|
updateDialog,
|
|
579
706
|
deleteDialog,
|
|
707
|
+
unJoinDialog,
|
|
708
|
+
joinToDialog,
|
|
580
709
|
uploadFile,
|
|
581
710
|
removeMembers,
|
|
582
711
|
setWaitLoadingStatus,
|
|
@@ -131,6 +131,24 @@ $create-dialog-container-height: 180px;
|
|
|
131
131
|
color: var(--main-text);
|
|
132
132
|
}
|
|
133
133
|
|
|
134
|
+
&__auto-join {
|
|
135
|
+
min-height: 20px;
|
|
136
|
+
font-style: normal;
|
|
137
|
+
font-weight: 400;
|
|
138
|
+
font-size: 14px;
|
|
139
|
+
line-height: 20px;
|
|
140
|
+
letter-spacing: 0.25px;
|
|
141
|
+
margin-top: 5px;
|
|
142
|
+
color: var(--error);
|
|
143
|
+
display: flex;
|
|
144
|
+
flex-flow: row;
|
|
145
|
+
|
|
146
|
+
svg {
|
|
147
|
+
margin: 2px 2px 0 0;
|
|
148
|
+
fill: var(--error);
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
|
|
134
152
|
&__text-field {
|
|
135
153
|
width: 100%;
|
|
136
154
|
}
|
|
@@ -13,9 +13,10 @@ import { DialogType } from '../../../Domain/entity/DialogTypes';
|
|
|
13
13
|
import GroupChat from '../../components/UI/svgs/Icons/Contents/GroupChat';
|
|
14
14
|
import PublicChannel from '../../components/UI/svgs/Icons/Contents/PublicChannel';
|
|
15
15
|
import useQbInitializedDataContext from '../../providers/QuickBloxUIKitProvider/useQbInitializedDataContext';
|
|
16
|
-
import { Button, TextField } from '../../ui-components';
|
|
16
|
+
import { Button, CheckBox, TextField } from '../../ui-components';
|
|
17
17
|
import { formatFileSize } from '../../../utils/formatFileSize';
|
|
18
18
|
import './EditDialog.scss';
|
|
19
|
+
import { SettingsFilledSvg } from '../../icons';
|
|
19
20
|
|
|
20
21
|
export const TypeOpenDialog = {
|
|
21
22
|
edit: 'edit',
|
|
@@ -60,6 +61,7 @@ const EditDialog = ({
|
|
|
60
61
|
nameDialog.length > maxLengthNameDialog,
|
|
61
62
|
);
|
|
62
63
|
const [errorMessageUpload, setErrorMessageUpload] = useState('');
|
|
64
|
+
const [disableAutoJoin, setDisableAutoJoin] = useState(false)
|
|
63
65
|
|
|
64
66
|
const handleUploadAvatar = (event: React.ChangeEvent<HTMLInputElement>) => {
|
|
65
67
|
const allowedExtensions = ['jpg', 'jpeg', 'gif', 'png'];
|
|
@@ -162,6 +164,7 @@ const EditDialog = ({
|
|
|
162
164
|
dialogTitle: dialogName,
|
|
163
165
|
// dialogAvatar: urlAvatar.length ? fileUploadAvatar : '',
|
|
164
166
|
dialogAvatar: urlAvatar === 'null' ? 'null' : fileUploadAvatar,
|
|
167
|
+
disableAutoJoin: disableAutoJoin,
|
|
165
168
|
};
|
|
166
169
|
|
|
167
170
|
clickUpdatedHandler(params);
|
|
@@ -233,6 +236,12 @@ const EditDialog = ({
|
|
|
233
236
|
placeholder="Enter name"
|
|
234
237
|
className="edit-dialog-container--wrapper__text-field"
|
|
235
238
|
/>
|
|
239
|
+
<div className="edit-dialog-container--wrapper__auto-join">
|
|
240
|
+
<CheckBox disabled={false} checked={disableAutoJoin}
|
|
241
|
+
onChange={() => setDisableAutoJoin(!disableAutoJoin)} />
|
|
242
|
+
<SettingsFilledSvg />
|
|
243
|
+
Disable AutoJoin
|
|
244
|
+
</div>
|
|
236
245
|
</div>
|
|
237
246
|
</div>
|
|
238
247
|
<div className="edit-btn-container">
|
|
@@ -39,6 +39,7 @@ const CreateNewDialogFlow = ({
|
|
|
39
39
|
const [uidAvatar, setUidAvatar] = React.useState<string | undefined>(
|
|
40
40
|
undefined,
|
|
41
41
|
);
|
|
42
|
+
const [disableAutoJoin, setDisableAutoJoin] = useState(false);
|
|
42
43
|
const { allowPublicDialogCreation } =
|
|
43
44
|
currentContext.InitParams.qbConfig.appConfig;
|
|
44
45
|
|
|
@@ -56,6 +57,7 @@ const CreateNewDialogFlow = ({
|
|
|
56
57
|
const getDialogNameHandler = (params: EditDialogParams) => {
|
|
57
58
|
console.log(params.dialogTitle);
|
|
58
59
|
setDialogName(params.dialogTitle);
|
|
60
|
+
setDisableAutoJoin(params.disableAutoJoin)
|
|
59
61
|
|
|
60
62
|
let newUidAvatar: string | undefined = '';
|
|
61
63
|
|
|
@@ -105,17 +107,30 @@ const CreateNewDialogFlow = ({
|
|
|
105
107
|
dialog.photo = uidAvatar || '';
|
|
106
108
|
dialog.participantIds = participants;
|
|
107
109
|
dialog.type = selectedDialogType;
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
.createDialog(dialog)
|
|
110
|
+
|
|
111
|
+
if (disableAutoJoin) {
|
|
111
112
|
// eslint-disable-next-line promise/always-return
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
113
|
+
await dialogsViewModel
|
|
114
|
+
.createDialog(dialog)
|
|
115
|
+
// eslint-disable-next-line promise/always-return
|
|
116
|
+
.then((newEntity) => {
|
|
117
|
+
onFinished(newEntity);
|
|
118
|
+
})
|
|
119
|
+
.catch((e) => {
|
|
120
|
+
console.log('Have exception: ', stringifyError(e));
|
|
121
|
+
});
|
|
122
|
+
// }
|
|
123
|
+
} else {
|
|
124
|
+
await dialogsViewModel.createDialogForAutoJoin(dialog, disableAutoJoin)
|
|
125
|
+
// eslint-disable-next-line promise/always-return
|
|
126
|
+
.then((newEntity) => {
|
|
127
|
+
onFinished(newEntity);
|
|
128
|
+
})
|
|
129
|
+
.catch((e) => {
|
|
130
|
+
console.log('Have exception: ', stringifyError(e));
|
|
131
|
+
});
|
|
132
|
+
}
|
|
133
|
+
|
|
119
134
|
}
|
|
120
135
|
};
|
|
121
136
|
|
package/src/QBconfig.ts
CHANGED
|
@@ -129,6 +129,8 @@ export const QBConfig: QBUIKitConfig = {
|
|
|
129
129
|
},
|
|
130
130
|
pingLocalhostTimeInterval: 5,
|
|
131
131
|
chatReconnectionTimeInterval: 3,
|
|
132
|
+
showPublicDialogsInList: false,
|
|
133
|
+
allowPublicDialogCreation: false,
|
|
132
134
|
debug: true,
|
|
133
135
|
enableForwarding: true,
|
|
134
136
|
enableReplying: true,
|
|
@@ -468,6 +468,90 @@ export function QBCreateGroupDialog(
|
|
|
468
468
|
});
|
|
469
469
|
}
|
|
470
470
|
|
|
471
|
+
// START
|
|
472
|
+
|
|
473
|
+
export function QBCreatePrivateDialogWithAutojoinFalse(
|
|
474
|
+
userId: QBUser['id'],
|
|
475
|
+
dialogName?: string,
|
|
476
|
+
data?: Dictionary<unknown>,
|
|
477
|
+
) {
|
|
478
|
+
console.log(
|
|
479
|
+
`call QBCreatePrivateDialog with userid: ${userId} dialog name: ${
|
|
480
|
+
dialogName || '-'
|
|
481
|
+
}`,
|
|
482
|
+
);
|
|
483
|
+
|
|
484
|
+
return new Promise<QBUIKitChatDialog>((resolve, reject) => {
|
|
485
|
+
// eslint-disable-next-line @typescript-eslint/no-shadow
|
|
486
|
+
const QB = getQB();
|
|
487
|
+
|
|
488
|
+
QB.chat.dialog.create(
|
|
489
|
+
{ name: dialogName || '-', occupants_ids: [userId], type: 3, data, is_join_required: 0 },
|
|
490
|
+
(error, chat) => {
|
|
491
|
+
if (error) {
|
|
492
|
+
reject(stringifyError(error));
|
|
493
|
+
} else {
|
|
494
|
+
resolve(chat!);
|
|
495
|
+
}
|
|
496
|
+
},
|
|
497
|
+
);
|
|
498
|
+
});
|
|
499
|
+
}
|
|
500
|
+
export function QBCreateGroupDialogWithAutojoinFalse(
|
|
501
|
+
userIds: Array<QBUser['id']>,
|
|
502
|
+
dialogName?: string,
|
|
503
|
+
data?: Dictionary<unknown>,
|
|
504
|
+
) {
|
|
505
|
+
console.log(
|
|
506
|
+
`call QBCreateGroupDialog with ids: ${JSON.stringify(userIds)} name: ${
|
|
507
|
+
dialogName || ''
|
|
508
|
+
}`,
|
|
509
|
+
);
|
|
510
|
+
|
|
511
|
+
let params = {};
|
|
512
|
+
|
|
513
|
+
if (data && data?.photo) {
|
|
514
|
+
params = {
|
|
515
|
+
name: dialogName || '-',
|
|
516
|
+
occupants_ids: [userIds],
|
|
517
|
+
type: 2,
|
|
518
|
+
photo: data?.photo,
|
|
519
|
+
is_join_required: 0,
|
|
520
|
+
};
|
|
521
|
+
} else {
|
|
522
|
+
params = {
|
|
523
|
+
name: dialogName || '-',
|
|
524
|
+
occupants_ids: [userIds],
|
|
525
|
+
type: 2,
|
|
526
|
+
is_join_required: 0
|
|
527
|
+
};
|
|
528
|
+
}
|
|
529
|
+
|
|
530
|
+
return new Promise<QBUIKitChatDialog>((resolve, reject) => {
|
|
531
|
+
// eslint-disable-next-line @typescript-eslint/no-shadow
|
|
532
|
+
const QB = getQB();
|
|
533
|
+
|
|
534
|
+
QB.chat.dialog.create(
|
|
535
|
+
// {
|
|
536
|
+
// name: dialogName || '-',
|
|
537
|
+
// occupants_ids: [userIds],
|
|
538
|
+
// type: 2,
|
|
539
|
+
// photo: data?.photo,
|
|
540
|
+
// },
|
|
541
|
+
params,
|
|
542
|
+
(error, chat) => {
|
|
543
|
+
if (error) {
|
|
544
|
+
reject(stringifyError(error));
|
|
545
|
+
} else {
|
|
546
|
+
resolve(chat!);
|
|
547
|
+
}
|
|
548
|
+
},
|
|
549
|
+
);
|
|
550
|
+
});
|
|
551
|
+
}
|
|
552
|
+
|
|
553
|
+
// END
|
|
554
|
+
|
|
471
555
|
export function QBUpdateDialog(
|
|
472
556
|
dialogId: QBUIKitChatDialog['_id'],
|
|
473
557
|
data: Dictionary<unknown>,
|
|
@@ -491,16 +575,9 @@ export function QBJoinGroupDialog(dialogId: QBUIKitChatDialog['_id']) {
|
|
|
491
575
|
// eslint-disable-next-line @typescript-eslint/no-shadow
|
|
492
576
|
const QB = getQB();
|
|
493
577
|
const dialogJid = QB.chat.helpers.getRoomJidFromDialogId(dialogId);
|
|
494
|
-
|
|
495
|
-
//
|
|
496
|
-
//
|
|
497
|
-
// console.log('ERROR in QBJoinGroupDialog with join group dialog:', error);
|
|
498
|
-
// reject(stringifyError(error));
|
|
499
|
-
// } else {
|
|
500
|
-
// console.log('QBJoinGroupDialog: join group dialog:', res);
|
|
501
|
-
// resolve(res);
|
|
502
|
-
// }
|
|
503
|
-
// });
|
|
578
|
+
// для ВЕРСИИ ТЕСТОВОГО ПРИМЕРА СПИСОК ДИАЛГОВ БЕЗ АВТОДЖОИНА нужно просто закомментировать
|
|
579
|
+
// содержимое этого
|
|
580
|
+
// метода
|
|
504
581
|
QB.chat.muc.join(dialogJid, (error, res) => {
|
|
505
582
|
if (error) {
|
|
506
583
|
console.log('ERROR in QBJoinGroupDialog with join group dialog:', error);
|
|
@@ -555,7 +632,7 @@ export function QBLeaveDialog(dialogId: QBUIKitChatDialog['_id']) {
|
|
|
555
632
|
// eslint-disable-next-line @typescript-eslint/no-shadow
|
|
556
633
|
const QB = getQB();
|
|
557
634
|
const dialogJid = QB.chat.helpers.getRoomJidFromDialogId(dialogId);
|
|
558
|
-
|
|
635
|
+
// unjoin
|
|
559
636
|
QB.chat.muc.leave(dialogJid, (error, res) => {
|
|
560
637
|
if (error) {
|
|
561
638
|
reject(stringifyError(error));
|
|
@@ -613,34 +690,6 @@ export function QBCreateAndUploadContent(
|
|
|
613
690
|
});
|
|
614
691
|
}
|
|
615
692
|
|
|
616
|
-
// export function QBChatGetMessages(
|
|
617
|
-
// dialogId: QBChatDialog['_id'],
|
|
618
|
-
// skip = 0,
|
|
619
|
-
// limit = 100,
|
|
620
|
-
// ) {
|
|
621
|
-
// return new Promise<GetMessagesResult & { dialogId: QBChatDialog['_id'] }>(
|
|
622
|
-
// (resolve, reject) => {
|
|
623
|
-
// QB.chat.message.list(
|
|
624
|
-
// {
|
|
625
|
-
// chat_dialog_id: dialogId,
|
|
626
|
-
// sort_desc: 'date_sent',
|
|
627
|
-
// limit,
|
|
628
|
-
// skip,
|
|
629
|
-
// mark_as_read: 0,
|
|
630
|
-
// },
|
|
631
|
-
// (error, messages) => {
|
|
632
|
-
// if (error) {
|
|
633
|
-
// reject(stringifyError(error));
|
|
634
|
-
// } else {
|
|
635
|
-
// resolve({ ...messages, dialogId });
|
|
636
|
-
// }
|
|
637
|
-
// },
|
|
638
|
-
// );
|
|
639
|
-
// },
|
|
640
|
-
// );
|
|
641
|
-
// }
|
|
642
|
-
// //
|
|
643
|
-
|
|
644
693
|
export function qbChatGetMessagesExtended(
|
|
645
694
|
dialogId: QBUIKitChatDialog['_id'],
|
|
646
695
|
params: Partial<{
|
|
@@ -773,9 +822,6 @@ export function QBWebRTCSessionGetUserMedia(
|
|
|
773
822
|
});
|
|
774
823
|
});
|
|
775
824
|
}
|
|
776
|
-
// export interface AIAnswerResponse {
|
|
777
|
-
// answer: string;
|
|
778
|
-
// } // artim 19.05.2024
|
|
779
825
|
|
|
780
826
|
export function QBAnswerAssist(
|
|
781
827
|
smartChatAssistantId: string,
|