quickblox-react-ui-kit 0.1.0 → 0.1.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/README.md +258 -255
- package/dist/App.d.ts +1 -2
- package/dist/Presentation/Views/Dialogs/Dialogs.d.ts +3 -0
- package/dist/Presentation/Views/Dialogs/useDialogsViewModel.d.ts +3 -1
- package/dist/Presentation/{components/UI → assets}/ DefaultThemes/DefaultTheme.d.ts +2 -2
- package/dist/Presentation/assets/DarkTheme.d.ts +2 -2
- package/dist/Presentation/assets/LightTheme.d.ts +2 -2
- package/dist/Presentation/assets/{Theme.d.ts → UiKitTheme.d.ts} +1 -1
- package/dist/Presentation/components/Button.d.ts +1 -1
- package/dist/Presentation/components/Navbar.d.ts +1 -2
- package/dist/Presentation/components/TextInput.d.ts +1 -1
- package/dist/Presentation/components/UI/Dialogs/HeaderDialogs/HeaderDialogs.d.ts +2 -2
- package/dist/Presentation/components/UI/Dialogs/MessagesView/HeaderMessages/HeaderMessages.d.ts +2 -0
- package/dist/Presentation/components/UI/Dialogs/MessagesView/MessagesView.d.ts +2 -0
- package/dist/Presentation/components/UI/Dialogs/MessagesView/{useMessagesViewModelWithMockUseCase.d.ts → useMessagesViewModel.d.ts} +1 -1
- package/dist/Presentation/components/UI/Dialogs/PreviewDialog/PreviewDialog.d.ts +2 -2
- package/dist/Presentation/components/UI/Placeholders/LoaderComponent/LoaderComponent.d.ts +1 -2
- package/dist/Presentation/components/UI/svgs/Icons/Actions/Add/index.d.ts +1 -2
- package/dist/Presentation/components/UI/svgs/Icons/Actions/AddContact/index.d.ts +1 -2
- package/dist/Presentation/components/UI/svgs/Icons/Actions/Archive/index.d.ts +1 -2
- package/dist/Presentation/components/UI/svgs/Icons/Actions/Copy/index.d.ts +1 -2
- package/dist/Presentation/components/UI/svgs/Icons/Actions/Delete/index.d.ts +1 -2
- package/dist/Presentation/components/UI/svgs/Icons/Actions/Download/index.d.ts +1 -2
- package/dist/Presentation/components/UI/svgs/Icons/Actions/Edit/index.d.ts +1 -2
- package/dist/Presentation/components/UI/svgs/Icons/Actions/EditDots/index.d.ts +1 -2
- package/dist/Presentation/components/UI/svgs/Icons/Actions/Emoji/index.d.ts +1 -2
- package/dist/Presentation/components/UI/svgs/Icons/Actions/ForwardFilled/index.d.ts +1 -2
- package/dist/Presentation/components/UI/svgs/Icons/Actions/Hungup/index.d.ts +1 -2
- package/dist/Presentation/components/UI/svgs/Icons/Actions/IncomeCall/index.d.ts +1 -2
- package/dist/Presentation/components/UI/svgs/Icons/Actions/Like/index.d.ts +1 -2
- package/dist/Presentation/components/UI/svgs/Icons/Actions/NewChat/index.d.ts +1 -2
- package/dist/Presentation/components/UI/svgs/Icons/Actions/OutcomeCall/index.d.ts +1 -2
- package/dist/Presentation/components/UI/svgs/Icons/Actions/Phone/index.d.ts +1 -2
- package/dist/Presentation/components/UI/svgs/Icons/Actions/PhoneFilled/index.d.ts +1 -2
- package/dist/Presentation/components/UI/svgs/Icons/Actions/Remove/index.d.ts +1 -2
- package/dist/Presentation/components/UI/svgs/Icons/Actions/Remove2/index.d.ts +1 -2
- package/dist/Presentation/components/UI/svgs/Icons/Actions/ReplyFilled/index.d.ts +1 -2
- package/dist/Presentation/components/UI/svgs/Icons/Actions/Send/index.d.ts +1 -2
- package/dist/Presentation/components/UI/svgs/Icons/Actions/Share/index.d.ts +1 -2
- package/dist/Presentation/components/UI/svgs/Icons/Actions/SwapCamera/index.d.ts +1 -2
- package/dist/Presentation/components/UI/svgs/Icons/Actions/Unarchive/index.d.ts +1 -2
- package/dist/Presentation/components/UI/svgs/Icons/Actions/VideoIcon/index.d.ts +1 -2
- package/dist/Presentation/components/UI/svgs/Icons/Actions/Voice/index.d.ts +1 -2
- package/dist/Presentation/components/UI/svgs/Icons/Contents/Brodcast/index.d.ts +1 -2
- package/dist/Presentation/components/UI/svgs/Icons/Contents/Chat/index.d.ts +1 -2
- package/dist/Presentation/components/UI/svgs/Icons/Contents/ChatFilled/index.d.ts +1 -2
- package/dist/Presentation/components/UI/svgs/Icons/Contents/Conference/index.d.ts +1 -2
- package/dist/Presentation/components/UI/svgs/Icons/Contents/Contact/index.d.ts +1 -2
- package/dist/Presentation/components/UI/svgs/Icons/Contents/ContactFilled/index.d.ts +1 -2
- package/dist/Presentation/components/UI/svgs/Icons/Contents/GroupChat/index.d.ts +1 -2
- package/dist/Presentation/components/UI/svgs/Icons/Contents/Notifications/index.d.ts +1 -2
- package/dist/Presentation/components/UI/svgs/Icons/Contents/PrivateChat/index.d.ts +1 -2
- package/dist/Presentation/components/UI/svgs/Icons/Contents/PublicChannel/index.d.ts +1 -2
- package/dist/Presentation/components/UI/svgs/Icons/Contents/Stream/index.d.ts +1 -2
- package/dist/Presentation/components/UI/svgs/Icons/Contents/StreamFilled/index.d.ts +1 -2
- package/dist/Presentation/components/UI/svgs/Icons/Contents/User/index.d.ts +1 -2
- package/dist/Presentation/components/UI/svgs/Icons/Media/Attachment/index.d.ts +1 -2
- package/dist/Presentation/components/UI/svgs/Icons/Media/AudioFile/index.d.ts +1 -2
- package/dist/Presentation/components/UI/svgs/Icons/Media/BrokenFile/index.d.ts +1 -2
- package/dist/Presentation/components/UI/svgs/Icons/Media/Camera/index.d.ts +1 -2
- package/dist/Presentation/components/UI/svgs/Icons/Media/GifFile/index.d.ts +1 -2
- package/dist/Presentation/components/UI/svgs/Icons/Media/ImageEmpty/index.d.ts +1 -2
- package/dist/Presentation/components/UI/svgs/Icons/Media/ImageFile/index.d.ts +1 -2
- package/dist/Presentation/components/UI/svgs/Icons/Media/ImageFilled/index.d.ts +1 -2
- package/dist/Presentation/components/UI/svgs/Icons/Media/LinkWeb/index.d.ts +1 -2
- package/dist/Presentation/components/UI/svgs/Icons/Media/Location/index.d.ts +1 -2
- package/dist/Presentation/components/UI/svgs/Icons/Media/TextDocument/index.d.ts +1 -2
- package/dist/Presentation/components/UI/svgs/Icons/Media/VideoFile/index.d.ts +1 -2
- package/dist/Presentation/components/UI/svgs/Icons/Moderation/Admin/index.d.ts +1 -2
- package/dist/Presentation/components/UI/svgs/Icons/Moderation/Banned/index.d.ts +1 -2
- package/dist/Presentation/components/UI/svgs/Icons/Moderation/Freeze/index.d.ts +1 -2
- package/dist/Presentation/components/UI/svgs/Icons/Moderation/Moderations/index.d.ts +1 -2
- package/dist/Presentation/components/UI/svgs/Icons/Moderation/Muted/index.d.ts +1 -2
- package/dist/Presentation/components/UI/svgs/Icons/Navigation/ArrowLeft/index.d.ts +1 -2
- package/dist/Presentation/components/UI/svgs/Icons/Navigation/ArrowRight/index.d.ts +1 -2
- package/dist/Presentation/components/UI/svgs/Icons/Navigation/Back/index.d.ts +1 -2
- package/dist/Presentation/components/UI/svgs/Icons/Navigation/Close/index.d.ts +1 -2
- package/dist/Presentation/components/UI/svgs/Icons/Navigation/Down/index.d.ts +1 -2
- package/dist/Presentation/components/UI/svgs/Icons/Navigation/Leave/index.d.ts +1 -2
- package/dist/Presentation/components/UI/svgs/Icons/Navigation/More/index.d.ts +1 -2
- package/dist/Presentation/components/UI/svgs/Icons/Navigation/Next/index.d.ts +1 -2
- package/dist/Presentation/components/UI/svgs/Icons/Navigation/Plus/index.d.ts +1 -2
- package/dist/Presentation/components/UI/svgs/Icons/Navigation/Refresh/index.d.ts +1 -2
- package/dist/Presentation/components/UI/svgs/Icons/Navigation/Search/index.d.ts +1 -2
- package/dist/Presentation/components/UI/svgs/Icons/Navigation/Settings/index.d.ts +1 -2
- package/dist/Presentation/components/UI/svgs/Icons/Navigation/SettingsField/index.d.ts +1 -2
- package/dist/Presentation/components/UI/svgs/Icons/Status/Error/index.d.ts +1 -2
- package/dist/Presentation/components/UI/svgs/Icons/Status/Help/index.d.ts +1 -2
- package/dist/Presentation/components/UI/svgs/Icons/Status/Information/index.d.ts +1 -2
- package/dist/Presentation/components/UI/svgs/Icons/Status/InformationFill/index.d.ts +1 -2
- package/dist/Presentation/components/UI/svgs/Icons/Status/Loader/index.d.ts +1 -2
- package/dist/Presentation/components/UI/svgs/Icons/Status/Mention/index.d.ts +1 -2
- package/dist/Presentation/components/UI/svgs/Icons/Status/Sent/index.d.ts +1 -2
- package/dist/Presentation/components/UI/svgs/Icons/Status/ViewedDelivered/index.d.ts +1 -2
- package/dist/Presentation/components/UI/svgs/Icons/Toggle/CameraOff/index.d.ts +1 -2
- package/dist/Presentation/components/UI/svgs/Icons/Toggle/CameraOn/index.d.ts +1 -2
- package/dist/Presentation/components/UI/svgs/Icons/Toggle/CheckOff/index.d.ts +1 -2
- package/dist/Presentation/components/UI/svgs/Icons/Toggle/CheckOn/index.d.ts +1 -2
- package/dist/Presentation/components/UI/svgs/Icons/Toggle/Favourite/index.d.ts +1 -2
- package/dist/Presentation/components/UI/svgs/Icons/Toggle/FavouriteFilled/index.d.ts +1 -2
- package/dist/Presentation/components/UI/svgs/Icons/Toggle/FullScreen/inex.d.ts +1 -2
- package/dist/Presentation/components/UI/svgs/Icons/Toggle/Hide/index.d.ts +1 -2
- package/dist/Presentation/components/UI/svgs/Icons/Toggle/ImagePlay/index.d.ts +1 -2
- package/dist/Presentation/components/UI/svgs/Icons/Toggle/Louder/index.d.ts +1 -2
- package/dist/Presentation/components/UI/svgs/Icons/Toggle/MicOff/index.d.ts +1 -2
- package/dist/Presentation/components/UI/svgs/Icons/Toggle/MicOn/index.d.ts +1 -2
- package/dist/Presentation/components/UI/svgs/Icons/Toggle/Minimize/index.d.ts +1 -2
- package/dist/Presentation/components/UI/svgs/Icons/Toggle/NotifyOff/index.d.ts +1 -2
- package/dist/Presentation/components/UI/svgs/Icons/Toggle/NotifyOn/index.d.ts +1 -2
- package/dist/Presentation/components/UI/svgs/Icons/Toggle/Pause/index.d.ts +1 -2
- package/dist/Presentation/components/UI/svgs/Icons/Toggle/Quite/index.d.ts +1 -2
- package/dist/Presentation/components/UI/svgs/Icons/Toggle/Record/index.d.ts +1 -2
- package/dist/Presentation/components/UI/svgs/Icons/Toggle/Screenshare/index.d.ts +1 -2
- package/dist/Presentation/components/UI/svgs/Icons/Toggle/Show/index.d.ts +1 -2
- package/dist/Presentation/components/UI/svgs/Icons/Toggle/Speaker/index.d.ts +1 -2
- package/dist/Presentation/components/UI/svgs/Icons/Toggle/SpeakerOff/index.d.ts +1 -2
- package/dist/Presentation/components/UI/svgs/Icons/Toggle/StopRecord/index.d.ts +1 -2
- package/dist/Presentation/components/UI/svgs/Icons/Toggle/StopShare/index.d.ts +1 -2
- package/dist/Presentation/components/containers/ScrollableContainer/ScrollableContainer.d.ts +1 -1
- package/dist/Presentation/components/layouts/Desktop/{DesktopLayoutForMockModels.d.ts → DesktopLayout.d.ts} +2 -2
- package/dist/Presentation/components/layouts/Desktop/QuickBloxUIKitDesktopLayout.d.ts +7 -0
- package/dist/Presentation/components/layouts/TestStage/TestStageMarkup.d.ts +1 -2
- package/dist/Presentation/components/providers/ModalContextProvider/Modal.d.ts +1 -1
- package/dist/Presentation/components/providers/ModalContextProvider/ModalContextProvider.d.ts +1 -2
- package/dist/Presentation/components/providers/QuickBloxUIKitProvider/QuickBloxUIKitProvider.d.ts +1 -1
- package/dist/index-ui.d.ts +4 -5
- package/dist/index-ui.js +343 -398
- package/package.json +1 -1
- package/src/App.tsx +14 -7
- package/src/Presentation/Views/Dialogs/Dialogs.tsx +3 -0
- package/src/Presentation/Views/Dialogs/useDialogsViewModel.ts +254 -50
- package/src/Presentation/{components/UI → assets}/ DefaultThemes/DefaultTheme.ts +2 -2
- package/src/Presentation/assets/DarkTheme.ts +2 -2
- package/src/Presentation/assets/LightTheme.ts +2 -2
- package/src/Presentation/assets/{Theme.ts → UiKitTheme.ts} +2 -2
- package/src/Presentation/components/UI/Buttons/MainButton/MainButton.scss +8 -8
- package/src/Presentation/components/UI/Dialogs/DialogInformation/DialogInformation.tsx +1 -1
- package/src/Presentation/components/UI/Dialogs/HeaderDialogs/HeaderDialogs.tsx +2 -2
- package/src/Presentation/components/UI/Dialogs/MessagesView/HeaderMessages/HeaderMessages.tsx +4 -0
- package/src/Presentation/components/UI/Dialogs/MessagesView/MessagesView.tsx +9 -3
- package/src/Presentation/components/UI/Dialogs/MessagesView/{useMessagesViewModelWithMockUseCase.ts → useMessagesViewModel.ts} +4 -6
- package/src/Presentation/components/UI/Dialogs/PreviewDialog/PreviewDialog.tsx +2 -2
- package/src/Presentation/components/layouts/Desktop/{DesktopLayoutForMockModels.tsx → DesktopLayout.tsx} +2 -2
- package/src/Presentation/components/layouts/{TestStage/TestStageWithMockData/TestStageWithMockData.tsx → Desktop/QuickBloxUIKitDesktopLayout.tsx} +37 -29
- package/src/Presentation/components/layouts/TestStage/TestStageMarkup.tsx +1 -1
- package/src/QBconfig.ts +0 -8
- package/src/index-ui.ts +6 -8
- package/dist/MyButton/MyButton.d.ts +0 -9
- package/dist/MyInput/MyInput.d.ts +0 -10
- package/dist/Presentation/Views/Dialogs/useDialogsViewModelWithMockUseCase.d.ts +0 -4
- package/dist/Presentation/components/layouts/Desktop/Desktop.d.ts +0 -4
- package/dist/Presentation/components/layouts/TestStage/TestStageWithMockData/TestStageWithMockData.d.ts +0 -3
- package/src/MyButton/MyButton.scss +0 -11
- package/src/MyButton/MyButton.tsx +0 -25
- package/src/MyInput/MyInput.scss +0 -9
- package/src/MyInput/MyInput.tsx +0 -36
- package/src/Presentation/Views/Dialogs/useDialogsViewModelWithMockUseCase.ts +0 -345
- package/src/Presentation/components/layouts/Desktop/Desktop.tsx +0 -103
- /package/dist/Presentation/{components/UI → assets}/ DefaultThemes/CustomTheme.d.ts +0 -0
- /package/src/Presentation/{components/UI → assets}/ DefaultThemes/CustomTheme.ts +0 -0
|
@@ -1,345 +0,0 @@
|
|
|
1
|
-
import { useState } from 'react';
|
|
2
|
-
import { QBDataContextType } from '../../components/providers/QuickBloxUIKitProvider/QuickBloxUIKitProvider';
|
|
3
|
-
import { Pagination } from '../../../Domain/repository/Pagination';
|
|
4
|
-
import { DialogsViewModel } from './DialogViewModel';
|
|
5
|
-
import { PublicDialogEntity } from '../../../Domain/entity/PublicDialogEntity';
|
|
6
|
-
import { DialogEntity } from '../../../Domain/entity/DialogEntity';
|
|
7
|
-
import { SubscribeToDialogsUpdatesUseCaseWithMock } from '../../../Domain/use_cases/SubscribeToDialogsUpdatesUseCaseWithMock';
|
|
8
|
-
import DialogsRepository from '../../../Data/repository/DialogsRepository';
|
|
9
|
-
import { GetAllDialogsUseCaseWithMock } from '../../../Domain/use_cases/GetAllDialogsUseCaseWithMock';
|
|
10
|
-
import { CreateDialogUseCase } from '../../../Domain/use_cases/CreateDialogUseCase';
|
|
11
|
-
import EventMessagesRepository from '../../../Data/repository/EventMessagesRepository';
|
|
12
|
-
import { stringifyError } from '../../../utils/parse';
|
|
13
|
-
import { GroupDialogEntity } from '../../../Domain/entity/GroupDialogEntity';
|
|
14
|
-
import { UpdateDialogUseCase } from '../../../Domain/use_cases/UpdateDialogUseCase';
|
|
15
|
-
import {
|
|
16
|
-
DialogLeaveType,
|
|
17
|
-
LeaveDialogUseCase,
|
|
18
|
-
} from '../../../Domain/use_cases/LeaveDialogUseCase';
|
|
19
|
-
import { FileEntity } from '../../../Domain/entity/FileEntity';
|
|
20
|
-
import { UploadFileUseCase } from '../../../Domain/use_cases/UploadFileUseCase';
|
|
21
|
-
import { FileRepository } from '../../../Data/repository/FileRepository';
|
|
22
|
-
import { Stubs } from '../../../Data/Stubs';
|
|
23
|
-
import { SubscribeToDialogEventsUseCase } from '../../../Domain/use_cases/SubscribeToDialogEventsUseCase';
|
|
24
|
-
import EventMessageType from '../../../Domain/entity/EventMessageType';
|
|
25
|
-
import { NotificationTypes } from '../../../Domain/entity/NotificationTypes';
|
|
26
|
-
import { GetDialogByIdUseCase } from '../../../Domain/use_cases/GetDialogByIdUseCase';
|
|
27
|
-
import { DialogType } from '../../../Domain/entity/DialogTypes';
|
|
28
|
-
import { RemoveUsersFromTheDialogUseCase } from '../../../Domain/use_cases/RemoveUsersFromTheDialogUseCase';
|
|
29
|
-
import { DialogEventInfo } from '../../../Domain/entity/DialogEventInfo';
|
|
30
|
-
import { RemoteDataSource } from '../../../Data/source/remote/RemoteDataSource';
|
|
31
|
-
|
|
32
|
-
export default function useDialogsViewModelWithMockUseCase(
|
|
33
|
-
currentContext: QBDataContextType,
|
|
34
|
-
initPagination?: Pagination,
|
|
35
|
-
): DialogsViewModel {
|
|
36
|
-
console.log('3.1. useDialogsViewModelWithMockUseCase');
|
|
37
|
-
const startPagination: Pagination = initPagination || new Pagination();
|
|
38
|
-
const [loading, setLoading] = useState(false);
|
|
39
|
-
const [error, setError] = useState('');
|
|
40
|
-
const [pagination, setPagination] = useState<Pagination>(startPagination);
|
|
41
|
-
const [dialogs, setDialogs] = useState<PublicDialogEntity[]>([]);
|
|
42
|
-
const [newDialog, setNewDialog] = useState<DialogEntity>();
|
|
43
|
-
|
|
44
|
-
// const currentContext = useQbDataContext();
|
|
45
|
-
const remoteDataSourceMock: RemoteDataSource =
|
|
46
|
-
currentContext.storage.REMOTE_DATA_SOURCE;
|
|
47
|
-
|
|
48
|
-
const eventMessageRepository: EventMessagesRepository =
|
|
49
|
-
currentContext.storage.EVENT_MESSAGE_REPOSITORY;
|
|
50
|
-
|
|
51
|
-
const useCaseSubscribeToDialogsUpdates: SubscribeToDialogsUpdatesUseCaseWithMock =
|
|
52
|
-
new SubscribeToDialogsUpdatesUseCaseWithMock(
|
|
53
|
-
new DialogsRepository(
|
|
54
|
-
currentContext.storage.LOCAL_DATA_SOURCE,
|
|
55
|
-
remoteDataSourceMock,
|
|
56
|
-
),
|
|
57
|
-
);
|
|
58
|
-
|
|
59
|
-
const subscribeToDialogEventsUseCase: SubscribeToDialogEventsUseCase =
|
|
60
|
-
new SubscribeToDialogEventsUseCase(
|
|
61
|
-
eventMessageRepository,
|
|
62
|
-
'DialogsViewModel',
|
|
63
|
-
);
|
|
64
|
-
|
|
65
|
-
const dialogUpdateHandler = (dialogInfo: DialogEventInfo) => {
|
|
66
|
-
console.log(
|
|
67
|
-
'call dialogUpdateHandler in useDialogsViewModelWithMockUseCase',
|
|
68
|
-
);
|
|
69
|
-
if (dialogInfo.eventMessageType === EventMessageType.SystemMessage) {
|
|
70
|
-
if (dialogInfo.notificationTypes === NotificationTypes.UPDATE_DIALOG) {
|
|
71
|
-
if (dialogInfo.messageInfo) {
|
|
72
|
-
const { dialogId } = dialogInfo.messageInfo;
|
|
73
|
-
|
|
74
|
-
const getDialogByIdUseCase: GetDialogByIdUseCase =
|
|
75
|
-
new GetDialogByIdUseCase(
|
|
76
|
-
new DialogsRepository(
|
|
77
|
-
currentContext.storage.LOCAL_DATA_SOURCE,
|
|
78
|
-
currentContext.storage.REMOTE_DATA_SOURCE,
|
|
79
|
-
),
|
|
80
|
-
dialogId,
|
|
81
|
-
);
|
|
82
|
-
|
|
83
|
-
// eslint-disable-next-line promise/catch-or-return,promise/always-return
|
|
84
|
-
getDialogByIdUseCase.execute().then((updatedDialog) => {
|
|
85
|
-
setNewDialog(updatedDialog);
|
|
86
|
-
});
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
};
|
|
91
|
-
|
|
92
|
-
subscribeToDialogEventsUseCase
|
|
93
|
-
.execute(dialogUpdateHandler)
|
|
94
|
-
.catch((reason) => {
|
|
95
|
-
console.log(stringifyError(reason));
|
|
96
|
-
});
|
|
97
|
-
|
|
98
|
-
// eslint-disable-next-line @typescript-eslint/require-await
|
|
99
|
-
async function getDialogs(currentPagination: Pagination) {
|
|
100
|
-
console.log('getDialogs in useDialogsViewModelWithMockUseCase');
|
|
101
|
-
console.log(
|
|
102
|
-
'EXECUTE USE CASES GET DIALOG WITH PAGINATION: ',
|
|
103
|
-
JSON.stringify(currentPagination),
|
|
104
|
-
);
|
|
105
|
-
setLoading(true);
|
|
106
|
-
const useCaseGetAllDialogs: GetAllDialogsUseCaseWithMock =
|
|
107
|
-
new GetAllDialogsUseCaseWithMock(
|
|
108
|
-
new DialogsRepository(
|
|
109
|
-
currentContext.storage.LOCAL_DATA_SOURCE,
|
|
110
|
-
remoteDataSourceMock,
|
|
111
|
-
),
|
|
112
|
-
currentPagination,
|
|
113
|
-
);
|
|
114
|
-
|
|
115
|
-
await useCaseGetAllDialogs
|
|
116
|
-
?.execute()
|
|
117
|
-
// eslint-disable-next-line promise/always-return
|
|
118
|
-
.then((result) => {
|
|
119
|
-
console.log('EXECUTE COMPLETED: ', JSON.stringify(currentPagination));
|
|
120
|
-
setDialogs([...(result.ResultData as PublicDialogEntity[])]);
|
|
121
|
-
setLoading(false);
|
|
122
|
-
setPagination(result.CurrentPagination);
|
|
123
|
-
})
|
|
124
|
-
.catch((e) => {
|
|
125
|
-
console.log('call catch....', JSON.stringify(e));
|
|
126
|
-
setError(`${(e as unknown as Error).message}`);
|
|
127
|
-
setLoading(false);
|
|
128
|
-
});
|
|
129
|
-
await useCaseSubscribeToDialogsUpdates?.execute((data) => {
|
|
130
|
-
try {
|
|
131
|
-
console.log(
|
|
132
|
-
'3.SUBSCRIBE EXECUTE in useDialogsViewModelWithMockUseCase:',
|
|
133
|
-
data,
|
|
134
|
-
);
|
|
135
|
-
setDialogs([...(data as PublicDialogEntity[])]);
|
|
136
|
-
setLoading(false);
|
|
137
|
-
setError('');
|
|
138
|
-
} catch (e) {
|
|
139
|
-
console.log('catch error2');
|
|
140
|
-
setError('ERROR2!!!');
|
|
141
|
-
}
|
|
142
|
-
});
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
const release = () => {
|
|
146
|
-
useCaseSubscribeToDialogsUpdates.release();
|
|
147
|
-
};
|
|
148
|
-
|
|
149
|
-
const createDialog = async (
|
|
150
|
-
dialogInfo: GroupDialogEntity,
|
|
151
|
-
): Promise<DialogEntity> => {
|
|
152
|
-
console.log(
|
|
153
|
-
'call createDialog in use case with params: ',
|
|
154
|
-
JSON.stringify(dialogInfo),
|
|
155
|
-
);
|
|
156
|
-
/*
|
|
157
|
-
currentContext.storage.LOCAL_DATA_SOURCE,
|
|
158
|
-
remoteDataSourceMock,
|
|
159
|
-
currentContext.storage.CONNECTION_REPOSITORY
|
|
160
|
-
*/
|
|
161
|
-
const createDialogUseCase: CreateDialogUseCase = new CreateDialogUseCase(
|
|
162
|
-
eventMessageRepository,
|
|
163
|
-
new DialogsRepository(
|
|
164
|
-
currentContext.storage.LOCAL_DATA_SOURCE,
|
|
165
|
-
remoteDataSourceMock,
|
|
166
|
-
),
|
|
167
|
-
dialogInfo,
|
|
168
|
-
);
|
|
169
|
-
const resultDialog: DialogEntity = await createDialogUseCase
|
|
170
|
-
.execute()
|
|
171
|
-
.catch((e) => {
|
|
172
|
-
console.log('EXCEPTION IN CREATE NEW DIALOG: ', stringifyError(e));
|
|
173
|
-
setNewDialog(undefined);
|
|
174
|
-
|
|
175
|
-
throw new Error(stringifyError(e));
|
|
176
|
-
});
|
|
177
|
-
|
|
178
|
-
if (resultDialog) {
|
|
179
|
-
setNewDialog(resultDialog);
|
|
180
|
-
|
|
181
|
-
return Promise.resolve(resultDialog);
|
|
182
|
-
}
|
|
183
|
-
|
|
184
|
-
return Promise.reject(resultDialog);
|
|
185
|
-
};
|
|
186
|
-
|
|
187
|
-
const updateDialog = async (
|
|
188
|
-
// eslint-disable-next-line @typescript-eslint/no-shadow,@typescript-eslint/no-unused-vars
|
|
189
|
-
dialogToUpdate: GroupDialogEntity,
|
|
190
|
-
): Promise<DialogEntity> => {
|
|
191
|
-
const updateDialogUseCase: UpdateDialogUseCase = new UpdateDialogUseCase(
|
|
192
|
-
eventMessageRepository,
|
|
193
|
-
new DialogsRepository(
|
|
194
|
-
currentContext.storage.LOCAL_DATA_SOURCE,
|
|
195
|
-
remoteDataSourceMock,
|
|
196
|
-
),
|
|
197
|
-
dialogToUpdate,
|
|
198
|
-
);
|
|
199
|
-
|
|
200
|
-
const resultDialog: DialogEntity = await updateDialogUseCase
|
|
201
|
-
.execute()
|
|
202
|
-
.catch((e) => {
|
|
203
|
-
console.log('Error updateDialogUseCase: ', stringifyError(e));
|
|
204
|
-
throw new Error(stringifyError(e));
|
|
205
|
-
});
|
|
206
|
-
|
|
207
|
-
return Promise.resolve(resultDialog);
|
|
208
|
-
};
|
|
209
|
-
|
|
210
|
-
const deleteDialog = async (
|
|
211
|
-
// eslint-disable-next-line @typescript-eslint/no-shadow,@typescript-eslint/no-unused-vars
|
|
212
|
-
dialogToDelete: GroupDialogEntity,
|
|
213
|
-
): Promise<boolean> => {
|
|
214
|
-
let leaveResult = false;
|
|
215
|
-
|
|
216
|
-
if (dialogToDelete.type === DialogType.private) {
|
|
217
|
-
const leaveDialogUseCase: LeaveDialogUseCase = new LeaveDialogUseCase(
|
|
218
|
-
eventMessageRepository,
|
|
219
|
-
new DialogsRepository(
|
|
220
|
-
currentContext.storage.LOCAL_DATA_SOURCE,
|
|
221
|
-
remoteDataSourceMock,
|
|
222
|
-
),
|
|
223
|
-
dialogToDelete,
|
|
224
|
-
DialogLeaveType.delete,
|
|
225
|
-
);
|
|
226
|
-
|
|
227
|
-
leaveResult = await leaveDialogUseCase.execute().catch((e) => {
|
|
228
|
-
console.log('Error leaveDialogUseCase: ', stringifyError(e));
|
|
229
|
-
throw new Error(stringifyError(e));
|
|
230
|
-
});
|
|
231
|
-
} else {
|
|
232
|
-
const usersForDeleteFromDialog: Array<number> = new Array<number>();
|
|
233
|
-
|
|
234
|
-
const userToDeleteId: number =
|
|
235
|
-
remoteDataSourceMock?.authInformation?.userId || 0;
|
|
236
|
-
|
|
237
|
-
usersForDeleteFromDialog.push(userToDeleteId);
|
|
238
|
-
const deleteUsersFromDialog: RemoveUsersFromTheDialogUseCase =
|
|
239
|
-
new RemoveUsersFromTheDialogUseCase(
|
|
240
|
-
eventMessageRepository,
|
|
241
|
-
new DialogsRepository(
|
|
242
|
-
currentContext.storage.LOCAL_DATA_SOURCE,
|
|
243
|
-
remoteDataSourceMock,
|
|
244
|
-
),
|
|
245
|
-
dialogToDelete,
|
|
246
|
-
usersForDeleteFromDialog,
|
|
247
|
-
);
|
|
248
|
-
|
|
249
|
-
leaveResult = await deleteUsersFromDialog.execute().catch((e) => {
|
|
250
|
-
console.log(
|
|
251
|
-
'Error delete users from RemoveUsersFromDialogUseCase: ',
|
|
252
|
-
stringifyError(e),
|
|
253
|
-
);
|
|
254
|
-
throw new Error(stringifyError(e));
|
|
255
|
-
});
|
|
256
|
-
}
|
|
257
|
-
|
|
258
|
-
if (leaveResult) {
|
|
259
|
-
return Promise.resolve(leaveResult);
|
|
260
|
-
}
|
|
261
|
-
|
|
262
|
-
return Promise.reject(leaveResult);
|
|
263
|
-
};
|
|
264
|
-
|
|
265
|
-
const removeMembers = async (dialog: GroupDialogEntity): Promise<boolean> => {
|
|
266
|
-
let leaveResult = false;
|
|
267
|
-
|
|
268
|
-
if (
|
|
269
|
-
dialog.participantsToRemoveIds &&
|
|
270
|
-
dialog.participantsToRemoveIds.length > 0
|
|
271
|
-
) {
|
|
272
|
-
const deleteUsersFromDialog: RemoveUsersFromTheDialogUseCase =
|
|
273
|
-
new RemoveUsersFromTheDialogUseCase(
|
|
274
|
-
eventMessageRepository,
|
|
275
|
-
new DialogsRepository(
|
|
276
|
-
currentContext.storage.LOCAL_DATA_SOURCE,
|
|
277
|
-
remoteDataSourceMock,
|
|
278
|
-
),
|
|
279
|
-
dialog,
|
|
280
|
-
dialog.participantsToRemoveIds,
|
|
281
|
-
);
|
|
282
|
-
|
|
283
|
-
leaveResult = await deleteUsersFromDialog.execute().catch((e) => {
|
|
284
|
-
console.log(
|
|
285
|
-
'Error delete users from RemoveUsersFromDialogUseCase: ',
|
|
286
|
-
stringifyError(e),
|
|
287
|
-
);
|
|
288
|
-
throw new Error(stringifyError(e));
|
|
289
|
-
});
|
|
290
|
-
}
|
|
291
|
-
|
|
292
|
-
if (leaveResult) {
|
|
293
|
-
return Promise.resolve(leaveResult);
|
|
294
|
-
}
|
|
295
|
-
|
|
296
|
-
return Promise.reject(leaveResult);
|
|
297
|
-
};
|
|
298
|
-
|
|
299
|
-
const uploadFile = async (file: File): Promise<FileEntity> => {
|
|
300
|
-
console.log('call uploadFile(), file: ', file);
|
|
301
|
-
const fileEntity: FileEntity = Stubs.createFileEntityWithDefaultValues();
|
|
302
|
-
|
|
303
|
-
fileEntity.data = file;
|
|
304
|
-
fileEntity.uid = '';
|
|
305
|
-
fileEntity.name = file.name;
|
|
306
|
-
fileEntity.size = file.size;
|
|
307
|
-
const uploadFileUseCase: UploadFileUseCase = new UploadFileUseCase(
|
|
308
|
-
new FileRepository(
|
|
309
|
-
currentContext.storage.LOCAL_DATA_SOURCE,
|
|
310
|
-
remoteDataSourceMock,
|
|
311
|
-
),
|
|
312
|
-
fileEntity,
|
|
313
|
-
);
|
|
314
|
-
|
|
315
|
-
const resultEnity: FileEntity = await uploadFileUseCase
|
|
316
|
-
.execute()
|
|
317
|
-
.catch((e) => {
|
|
318
|
-
console.log('Error UploadFileUseCase: ', stringifyError(e));
|
|
319
|
-
throw new Error(stringifyError(e));
|
|
320
|
-
});
|
|
321
|
-
|
|
322
|
-
return Promise.resolve(resultEnity);
|
|
323
|
-
};
|
|
324
|
-
|
|
325
|
-
return {
|
|
326
|
-
get entity(): DialogEntity {
|
|
327
|
-
return newDialog as DialogEntity;
|
|
328
|
-
},
|
|
329
|
-
set entity(item) {
|
|
330
|
-
setNewDialog(item);
|
|
331
|
-
},
|
|
332
|
-
dialogs,
|
|
333
|
-
loading,
|
|
334
|
-
error,
|
|
335
|
-
pagination,
|
|
336
|
-
// eslint-disable-next-line @typescript-eslint/no-misused-promises
|
|
337
|
-
getDialogs,
|
|
338
|
-
release,
|
|
339
|
-
createDialog,
|
|
340
|
-
updateDialog,
|
|
341
|
-
deleteDialog,
|
|
342
|
-
uploadFile,
|
|
343
|
-
removeMembers,
|
|
344
|
-
};
|
|
345
|
-
}
|
|
@@ -1,103 +0,0 @@
|
|
|
1
|
-
import React, { useEffect } from 'react';
|
|
2
|
-
import './DesktopLayout.scss';
|
|
3
|
-
import ColumnContainer from '../../containers/ColumnContainer/ColumnContainer';
|
|
4
|
-
import BaseViewModel from '../../../Views/Base/BaseViewModel';
|
|
5
|
-
import { ModalContext } from '../../providers/ModalContextProvider/Modal';
|
|
6
|
-
import DialogsComponent from '../../../Views/Dialogs/Dialogs';
|
|
7
|
-
import HeaderDialogs from '../../UI/Dialogs/HeaderDialogs/HeaderDialogs';
|
|
8
|
-
import DialogInformation from '../../UI/Dialogs/DialogInformation/DialogInformation';
|
|
9
|
-
import { DialogsViewModel } from '../../../Views/Dialogs/DialogViewModel';
|
|
10
|
-
import useDialogsViewModel from '../../../Views/Dialogs/useDialogsViewModel';
|
|
11
|
-
import { DialogEntity } from '../../../../Domain/entity/DialogEntity';
|
|
12
|
-
import { Pagination } from '../../../../Domain/repository/Pagination';
|
|
13
|
-
import CreateDialog from '../../UI/Dialogs/CreateDialog/CreateDialog';
|
|
14
|
-
|
|
15
|
-
function Desktop() {
|
|
16
|
-
console.log('create DesktopLayoutDesktopLayout');
|
|
17
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
18
|
-
const { handleModal } = React.useContext(ModalContext);
|
|
19
|
-
const [selectedDialog, setSelectedDialog] =
|
|
20
|
-
React.useState<BaseViewModel<DialogEntity>>();
|
|
21
|
-
|
|
22
|
-
const dialogsViewModel: DialogsViewModel = useDialogsViewModel();
|
|
23
|
-
|
|
24
|
-
useEffect(() => {
|
|
25
|
-
console.log('DESKTOP USE EFFECT in DesktopLayoutDesktopLayout');
|
|
26
|
-
const pagination: Pagination = new Pagination();
|
|
27
|
-
|
|
28
|
-
dialogsViewModel?.getDialogs(pagination);
|
|
29
|
-
|
|
30
|
-
return () => {
|
|
31
|
-
// console.log('call removeListener()');
|
|
32
|
-
// listChatsViewModel?.removeListener();
|
|
33
|
-
};
|
|
34
|
-
}, []);
|
|
35
|
-
|
|
36
|
-
return (
|
|
37
|
-
<div className="desktop-layout-main-container">
|
|
38
|
-
<div className="desktop-layout-main-container__item-left">
|
|
39
|
-
<DialogsComponent
|
|
40
|
-
dialogsViewModel={dialogsViewModel}
|
|
41
|
-
itemSelectHandler={setSelectedDialog}
|
|
42
|
-
header={
|
|
43
|
-
<HeaderDialogs
|
|
44
|
-
title="Dialogs"
|
|
45
|
-
ClickActionHandler={() => {
|
|
46
|
-
handleModal(
|
|
47
|
-
true,
|
|
48
|
-
<CreateDialog
|
|
49
|
-
createPrivateDialogClickHandler={() =>
|
|
50
|
-
console.log('click private')
|
|
51
|
-
}
|
|
52
|
-
createPrivateDialogTouchHandler={() =>
|
|
53
|
-
console.log('touch private')
|
|
54
|
-
}
|
|
55
|
-
createGroupDialogClickHandler={() =>
|
|
56
|
-
console.log('click group')
|
|
57
|
-
}
|
|
58
|
-
createGroupDialogTouchHandler={() =>
|
|
59
|
-
console.log('touch group')
|
|
60
|
-
}
|
|
61
|
-
createPublicDialogClickHandler={() =>
|
|
62
|
-
console.log('click public')
|
|
63
|
-
}
|
|
64
|
-
createPublicDialogTouchHandler={() =>
|
|
65
|
-
console.log('touch public')
|
|
66
|
-
}
|
|
67
|
-
/>,
|
|
68
|
-
'New dialog',
|
|
69
|
-
false,
|
|
70
|
-
false,
|
|
71
|
-
);
|
|
72
|
-
}}
|
|
73
|
-
/>
|
|
74
|
-
}
|
|
75
|
-
/>
|
|
76
|
-
</div>
|
|
77
|
-
<div className="desktop-layout-main-container__item-center">2</div>
|
|
78
|
-
<div className="desktop-layout-main-container__item-right">
|
|
79
|
-
<ColumnContainer>
|
|
80
|
-
{/* selected dialog: */}
|
|
81
|
-
{/* {selectedDialog?.entity.name} */}
|
|
82
|
-
{/* <br /> */}
|
|
83
|
-
{/* id: */}
|
|
84
|
-
{/* {selectedDialog?.entity.id} */}
|
|
85
|
-
{/* <hr /> */}
|
|
86
|
-
{selectedDialog ? (
|
|
87
|
-
<DialogInformation
|
|
88
|
-
dialog={selectedDialog.entity}
|
|
89
|
-
dialogViewModel={dialogsViewModel}
|
|
90
|
-
closeInformationHandler={() => {
|
|
91
|
-
console.log('close dialog');
|
|
92
|
-
}}
|
|
93
|
-
/>
|
|
94
|
-
) : (
|
|
95
|
-
<div>Select dialog to chatting</div>
|
|
96
|
-
)}
|
|
97
|
-
</ColumnContainer>
|
|
98
|
-
</div>
|
|
99
|
-
</div>
|
|
100
|
-
);
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
export default Desktop;
|
|
File without changes
|
|
File without changes
|