quickblox-react-ui-kit 0.5.0-beta.9 → 0.5.0
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/App.d.ts.map +1 -1
- package/dist/CommonTypes/CommonTypes.d.ts +12 -0
- package/dist/CommonTypes/CommonTypes.d.ts.map +1 -1
- package/dist/Data/Creator.d.ts.map +1 -1
- package/dist/Data/DefaultConfigurations.d.ts.map +1 -1
- package/dist/Data/source/remote/Mapper/DialogDTOMapper.d.ts.map +1 -1
- package/dist/Data/source/remote/Mapper/MessageDTOMapper.d.ts.map +1 -1
- package/dist/Data/source/remote/RemoteDataSource.d.ts +8 -2
- package/dist/Data/source/remote/RemoteDataSource.d.ts.map +1 -1
- package/dist/Domain/use_cases/CreateDialogUseCase.d.ts.map +1 -1
- package/dist/Domain/use_cases/ForwardMessagesUseCase.d.ts.map +1 -1
- package/dist/Domain/use_cases/GetAllDialogsUseCase.d.ts.map +1 -1
- package/dist/Domain/use_cases/GetAllDialogsUseCaseWithMock.d.ts.map +1 -1
- package/dist/Domain/use_cases/GetAllMessagesForDialog.d.ts.map +1 -1
- package/dist/Domain/use_cases/GetAllUsersUseCase.d.ts.map +1 -1
- package/dist/Domain/use_cases/GetDialogByIdUseCase.d.ts.map +1 -1
- package/dist/Domain/use_cases/GetUsersByIdsUseCase.d.ts.map +1 -1
- package/dist/Domain/use_cases/LeaveDialogUseCase.d.ts.map +1 -1
- package/dist/Domain/use_cases/RemoveUsersFromTheDialogUseCase.d.ts.map +1 -1
- package/dist/Domain/use_cases/ReplyMessagesUseCase.d.ts.map +1 -1
- package/dist/Domain/use_cases/SendTextMessageUseCase.d.ts.map +1 -1
- package/dist/Domain/use_cases/SubscribeToDialogEventsUseCase.d.ts.map +1 -1
- package/dist/Domain/use_cases/SubscribeToDialogsUpdatesUseCase.d.ts.map +1 -1
- package/dist/Domain/use_cases/SyncDialogsUseCase.d.ts.map +1 -1
- package/dist/Domain/use_cases/UpdateCurrentDialogInDataSourceUseCase.d.ts.map +1 -1
- package/dist/Domain/use_cases/UpdateDialogUseCase.d.ts.map +1 -1
- package/dist/Domain/use_cases/UploadFileUseCase.d.ts.map +1 -1
- package/dist/Domain/use_cases/UserTypingMessageUseCase.d.ts.map +1 -1
- package/dist/Domain/use_cases/ai/AIAnswerAssistUseCase.d.ts.map +1 -1
- package/dist/Domain/use_cases/ai/AIAnswerAssistWithProxyUseCase.d.ts.map +1 -1
- package/dist/Domain/use_cases/ai/AIAnswerAssistWithSDKUseCase.d.ts.map +1 -1
- package/dist/Domain/use_cases/ai/AIRephraseUseCase.d.ts.map +1 -1
- package/dist/Domain/use_cases/ai/AIRephraseWithProxyUseCase.d.ts.map +1 -1
- package/dist/Domain/use_cases/ai/AITranslateUseCase.d.ts.map +1 -1
- package/dist/Domain/use_cases/ai/AITranslateWithProxyUseCase.d.ts.map +1 -1
- package/dist/Domain/use_cases/ai/AITranslateWithSDKUseCase.d.ts.map +1 -1
- package/dist/Domain/use_cases/base/Subscribable/SubscriptionPerformer.d.ts.map +1 -1
- package/dist/Presentation/Views/Dialog/MessageItem/MessageItem.d.ts +3 -2
- package/dist/Presentation/Views/Dialog/MessageItem/MessageItem.d.ts.map +1 -1
- package/dist/Presentation/Views/Dialog/useDialogViewModel.d.ts.map +1 -1
- package/dist/Presentation/Views/DialogInfo/UsersList/useUsersListViewModel.d.ts.map +1 -1
- package/dist/Presentation/Views/DialogList/useDialogListViewModel.d.ts.map +1 -1
- package/dist/Presentation/Views/Flow/CreateDialog/CreateDialog.d.ts +2 -1
- package/dist/Presentation/Views/Flow/CreateDialog/CreateDialog.d.ts.map +1 -1
- package/dist/Presentation/Views/Flow/CreateDialogFlow/CreateNewDialogFlow.d.ts.map +1 -1
- package/dist/Presentation/layouts/Desktop/QuickBloxUIKitDesktopLayout.d.ts.map +1 -1
- package/dist/Presentation/providers/QuickBloxUIKitProvider/QuickBloxUIKitProvider.d.ts.map +1 -1
- package/dist/Presentation/ui-components/Badge/Badge.d.ts.map +1 -1
- package/dist/QBconfig.d.ts.map +1 -1
- package/dist/index-ui.d.ts +58 -5
- package/dist/index-ui.d.ts.map +1 -1
- package/dist/index-ui.js +3634 -194
- package/dist/qb-api-calls/index.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/App.tsx +5 -0
- package/src/CommonTypes/CommonTypes.ts +13 -0
- package/src/Data/Creator.ts +4 -2
- package/src/Data/DefaultConfigurations.ts +4 -0
- package/src/Data/source/remote/Mapper/DialogDTOMapper.ts +0 -2
- package/src/Data/source/remote/Mapper/MessageDTOMapper.ts +9 -1
- package/src/Data/source/remote/RemoteDataSource.ts +344 -104
- package/src/Domain/use_cases/CreateDialogUseCase.ts +0 -1
- package/src/Domain/use_cases/ForwardMessagesUseCase.ts +0 -1
- package/src/Domain/use_cases/GetAllDialogsUseCase.ts +0 -1
- package/src/Domain/use_cases/GetAllDialogsUseCaseWithMock.ts +0 -2
- package/src/Domain/use_cases/GetAllMessagesForDialog.ts +10 -6
- package/src/Domain/use_cases/GetAllUsersUseCase.ts +0 -1
- package/src/Domain/use_cases/GetDialogByIdUseCase.ts +0 -2
- package/src/Domain/use_cases/GetUsersByIdsUseCase.ts +6 -4
- package/src/Domain/use_cases/LeaveDialogUseCase.ts +0 -1
- package/src/Domain/use_cases/RemoveUsersFromTheDialogUseCase.ts +0 -1
- package/src/Domain/use_cases/ReplyMessagesUseCase.ts +0 -2
- package/src/Domain/use_cases/SendTextMessageUseCase.ts +0 -3
- package/src/Domain/use_cases/SubscribeToDialogEventsUseCase.ts +0 -26
- package/src/Domain/use_cases/SubscribeToDialogsUpdatesUseCase.ts +0 -1
- package/src/Domain/use_cases/SyncDialogsUseCase.ts +0 -1
- package/src/Domain/use_cases/UpdateCurrentDialogInDataSourceUseCase.ts +0 -2
- package/src/Domain/use_cases/UpdateDialogUseCase.ts +0 -2
- package/src/Domain/use_cases/UploadFileUseCase.ts +0 -2
- package/src/Domain/use_cases/UserTypingMessageUseCase.ts +0 -2
- package/src/Domain/use_cases/ai/AIAnswerAssistUseCase.ts +0 -2
- package/src/Domain/use_cases/ai/AIAnswerAssistWithProxyUseCase.ts +0 -3
- package/src/Domain/use_cases/ai/AIAnswerAssistWithSDKUseCase.ts +0 -2
- package/src/Domain/use_cases/ai/AIRephraseUseCase.ts +0 -2
- package/src/Domain/use_cases/ai/AIRephraseWithProxyUseCase.ts +0 -3
- package/src/Domain/use_cases/ai/AITranslateUseCase.ts +0 -2
- package/src/Domain/use_cases/ai/AITranslateWithProxyUseCase.ts +0 -3
- package/src/Domain/use_cases/ai/AITranslateWithSDKUseCase.ts +0 -3
- package/src/Domain/use_cases/base/Subscribable/SubscriptionPerformer.ts +0 -1
- package/src/Presentation/Views/Dialog/MessageItem/MessageItem.tsx +6 -3
- package/src/Presentation/Views/Dialog/useDialogViewModel.ts +2 -7
- package/src/Presentation/Views/DialogInfo/UsersList/useUsersListViewModel.ts +1 -4
- package/src/Presentation/Views/DialogList/useDialogListViewModel.ts +0 -1
- package/src/Presentation/Views/Flow/CreateDialog/CreateDialog.tsx +4 -0
- package/src/Presentation/Views/Flow/CreateDialogFlow/CreateNewDialogFlow.tsx +3 -0
- package/src/Presentation/components/UI/Placeholders/LoaderComponent/LoaderComponent.scss +1 -1
- package/src/Presentation/components/UI/Placeholders/LoaderComponent/LoaderComponent.tsx +3 -3
- package/src/Presentation/layouts/Desktop/QuickBloxUIKitDesktopLayout.tsx +6 -1
- package/src/Presentation/providers/QuickBloxUIKitProvider/QuickBloxUIKitProvider.tsx +3 -35
- package/src/Presentation/ui-components/Avatar/Avatar.scss +1 -1
- package/src/Presentation/ui-components/Avatar/Avatar.tsx +3 -3
- package/src/Presentation/ui-components/Badge/Badge.scss +1 -1
- package/src/Presentation/ui-components/Badge/Badge.tsx +2 -1
- package/src/Presentation/ui-components/Button/Button.scss +5 -5
- package/src/Presentation/ui-components/Button/Button.tsx +4 -4
- package/src/Presentation/ui-components/CheckBox/CheckBox.scss +1 -6
- package/src/Presentation/ui-components/Dropdown/Dropdown.scss +1 -1
- package/src/Presentation/ui-components/Dropdown/Dropdown.tsx +4 -4
- package/src/Presentation/ui-components/Dropdown/DropdownOption.tsx +3 -3
- package/src/Presentation/ui-components/Loader/Loader.scss +1 -1
- package/src/Presentation/ui-components/Loader/Loader.tsx +1 -1
- package/src/Presentation/ui-components/TextField/TextField.scss +1 -1
- package/src/Presentation/ui-components/TextField/TextField.tsx +8 -8
- package/src/Presentation/ui-components/Toast/Toast.scss +2 -2
- package/src/Presentation/ui-components/Toast/ToastProvider.tsx +3 -3
- package/src/QBconfig.ts +2 -0
- package/src/hooks/useQuickBloxUIKit.ts +1 -1
- package/src/index-ui.ts +135 -15
- package/src/qb-api-calls/index.ts +34 -1
- package/storybook-static/161.53da4e03.iframe.bundle.js +2 -0
- package/storybook-static/{756.92971caf.iframe.bundle.js.LICENSE.txt → 161.53da4e03.iframe.bundle.js.LICENSE.txt} +0 -10
- package/storybook-static/217.07d5c7a3.iframe.bundle.js +405 -0
- package/storybook-static/217.07d5c7a3.iframe.bundle.js.LICENSE.txt +9 -0
- package/storybook-static/{756.92971caf.iframe.bundle.js.map → 217.07d5c7a3.iframe.bundle.js.map} +1 -1
- package/storybook-static/735.6ee62079.iframe.bundle.js +2 -0
- package/storybook-static/844.e8bfd664.iframe.bundle.js +95 -0
- package/storybook-static/844.e8bfd664.iframe.bundle.js.map +1 -0
- package/storybook-static/{961.c94da456.iframe.bundle.js → 961.d47fc2bc.iframe.bundle.js} +2 -2
- package/storybook-static/Presentation-ui-components-Avatar-avatar-stories.a5ba7608.iframe.bundle.js +2 -0
- package/storybook-static/Presentation-ui-components-Badge-Badge-stories.c8824861.iframe.bundle.js +2 -0
- package/storybook-static/Presentation-ui-components-Button-Button-stories.fa2aa72c.iframe.bundle.js +2 -0
- package/storybook-static/Presentation-ui-components-DialogItemPreview-DialogItemPreview-stories.b6998344.iframe.bundle.js +2 -0
- package/storybook-static/Presentation-ui-components-DialogWindow-DialogWindow-stories.a724643f.iframe.bundle.js +2 -0
- package/storybook-static/Presentation-ui-components-Dropdown-Dropdown-stories.a03feb06.iframe.bundle.js +2 -0
- package/storybook-static/Presentation-ui-components-Header-Header-stories.978f0af5.iframe.bundle.js +2 -0
- package/storybook-static/Presentation-ui-components-Loader-Loader-stories.4e80520d.iframe.bundle.js +2 -0
- package/storybook-static/Presentation-ui-components-Message-Message-stories.213a90f6.iframe.bundle.js +2 -0
- package/storybook-static/Presentation-ui-components-MessageInput-MessageInput-stories.729e41fc.iframe.bundle.js +1 -0
- package/storybook-static/Presentation-ui-components-SettingsItem-SettingsItem-stories.e7f5a274.iframe.bundle.js +2 -0
- package/storybook-static/Presentation-ui-components-TextField-TextField-stories.969cfe2e.iframe.bundle.js +2 -0
- package/storybook-static/Presentation-ui-components-Toast-Toast-stories.4f00432b.iframe.bundle.js +1 -0
- package/storybook-static/Presentation-ui-components-UserListItem-UserListItem-stories.1713eab7.iframe.bundle.js +2 -0
- package/storybook-static/iframe.html +3 -3
- package/storybook-static/{main.c2fb2ab0.iframe.bundle.js → main.59f682e8.iframe.bundle.js} +1 -1
- package/storybook-static/project.json +1 -1
- package/storybook-static/runtime~main.7d4dacf8.iframe.bundle.js +1 -0
- package/storybook-static/sb-addons/chromatic-com-storybook-10/manager-bundle.js +24 -24
- 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 +5 -5
- 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 +20 -20
- package/storybook-static/sb-addons/onboarding-1/manager-bundle.js +1 -1
- package/storybook-static/sb-manager/globals-module-info.js +5 -0
- package/storybook-static/sb-manager/globals-runtime.js +11936 -11584
- package/storybook-static/sb-manager/runtime.js +144 -144
- package/storybook-static/sb-preview/runtime.js +3 -5
- package/.env +0 -1
- package/storybook-static/735.82f96f8a.iframe.bundle.js +0 -2
- package/storybook-static/756.92971caf.iframe.bundle.js +0 -405
- package/storybook-static/844.642791cb.iframe.bundle.js +0 -95
- package/storybook-static/844.642791cb.iframe.bundle.js.map +0 -1
- package/storybook-static/Presentation-ui-components-Avatar-avatar-stories.b363e9a1.iframe.bundle.js +0 -2
- package/storybook-static/Presentation-ui-components-Badge-Badge-stories.85dd97b0.iframe.bundle.js +0 -2
- package/storybook-static/Presentation-ui-components-Button-Button-stories.1e4ae2b4.iframe.bundle.js +0 -2
- package/storybook-static/Presentation-ui-components-DialogItemPreview-DialogItemPreview-stories.4e25a94d.iframe.bundle.js +0 -2
- package/storybook-static/Presentation-ui-components-DialogWindow-DialogWindow-stories.e22e8be5.iframe.bundle.js +0 -2
- package/storybook-static/Presentation-ui-components-Dropdown-Dropdown-stories.8321872b.iframe.bundle.js +0 -2
- package/storybook-static/Presentation-ui-components-Header-Header-stories.1cff200a.iframe.bundle.js +0 -2
- package/storybook-static/Presentation-ui-components-Loader-Loader-stories.7391dde4.iframe.bundle.js +0 -2
- package/storybook-static/Presentation-ui-components-Message-Message-stories.49f0dbbf.iframe.bundle.js +0 -2
- package/storybook-static/Presentation-ui-components-MessageInput-MessageInput-stories.de6fb2f3.iframe.bundle.js +0 -1
- package/storybook-static/Presentation-ui-components-SettingsItem-SettingsItem-stories.d74853ab.iframe.bundle.js +0 -2
- package/storybook-static/Presentation-ui-components-TextField-TextField-stories.19812f7d.iframe.bundle.js +0 -2
- package/storybook-static/Presentation-ui-components-Toast-Toast-stories.5e19f10e.iframe.bundle.js +0 -1
- package/storybook-static/Presentation-ui-components-UserListItem-UserListItem-stories.d2f60e13.iframe.bundle.js +0 -2
- package/storybook-static/runtime~main.2530bea6.iframe.bundle.js +0 -1
- /package/storybook-static/{735.82f96f8a.iframe.bundle.js.LICENSE.txt → 735.6ee62079.iframe.bundle.js.LICENSE.txt} +0 -0
- /package/storybook-static/{844.642791cb.iframe.bundle.js.LICENSE.txt → 844.e8bfd664.iframe.bundle.js.LICENSE.txt} +0 -0
- /package/storybook-static/{961.c94da456.iframe.bundle.js.LICENSE.txt → 961.d47fc2bc.iframe.bundle.js.LICENSE.txt} +0 -0
- /package/storybook-static/{Presentation-ui-components-Avatar-avatar-stories.b363e9a1.iframe.bundle.js.LICENSE.txt → Presentation-ui-components-Avatar-avatar-stories.a5ba7608.iframe.bundle.js.LICENSE.txt} +0 -0
- /package/storybook-static/{Presentation-ui-components-Badge-Badge-stories.85dd97b0.iframe.bundle.js.LICENSE.txt → Presentation-ui-components-Badge-Badge-stories.c8824861.iframe.bundle.js.LICENSE.txt} +0 -0
- /package/storybook-static/{Presentation-ui-components-Button-Button-stories.1e4ae2b4.iframe.bundle.js.LICENSE.txt → Presentation-ui-components-Button-Button-stories.fa2aa72c.iframe.bundle.js.LICENSE.txt} +0 -0
- /package/storybook-static/{Presentation-ui-components-DialogItemPreview-DialogItemPreview-stories.4e25a94d.iframe.bundle.js.LICENSE.txt → Presentation-ui-components-DialogItemPreview-DialogItemPreview-stories.b6998344.iframe.bundle.js.LICENSE.txt} +0 -0
- /package/storybook-static/{Presentation-ui-components-DialogWindow-DialogWindow-stories.e22e8be5.iframe.bundle.js.LICENSE.txt → Presentation-ui-components-DialogWindow-DialogWindow-stories.a724643f.iframe.bundle.js.LICENSE.txt} +0 -0
- /package/storybook-static/{Presentation-ui-components-Dropdown-Dropdown-stories.8321872b.iframe.bundle.js.LICENSE.txt → Presentation-ui-components-Dropdown-Dropdown-stories.a03feb06.iframe.bundle.js.LICENSE.txt} +0 -0
- /package/storybook-static/{Presentation-ui-components-Header-Header-stories.1cff200a.iframe.bundle.js.LICENSE.txt → Presentation-ui-components-Header-Header-stories.978f0af5.iframe.bundle.js.LICENSE.txt} +0 -0
- /package/storybook-static/{Presentation-ui-components-Loader-Loader-stories.7391dde4.iframe.bundle.js.LICENSE.txt → Presentation-ui-components-Loader-Loader-stories.4e80520d.iframe.bundle.js.LICENSE.txt} +0 -0
- /package/storybook-static/{Presentation-ui-components-Message-Message-stories.49f0dbbf.iframe.bundle.js.LICENSE.txt → Presentation-ui-components-Message-Message-stories.213a90f6.iframe.bundle.js.LICENSE.txt} +0 -0
- /package/storybook-static/{Presentation-ui-components-SettingsItem-SettingsItem-stories.d74853ab.iframe.bundle.js.LICENSE.txt → Presentation-ui-components-SettingsItem-SettingsItem-stories.e7f5a274.iframe.bundle.js.LICENSE.txt} +0 -0
- /package/storybook-static/{Presentation-ui-components-TextField-TextField-stories.19812f7d.iframe.bundle.js.LICENSE.txt → Presentation-ui-components-TextField-TextField-stories.969cfe2e.iframe.bundle.js.LICENSE.txt} +0 -0
- /package/storybook-static/{Presentation-ui-components-UserListItem-UserListItem-stories.d2f60e13.iframe.bundle.js.LICENSE.txt → Presentation-ui-components-UserListItem-UserListItem-stories.1713eab7.iframe.bundle.js.LICENSE.txt} +0 -0
|
@@ -13,7 +13,6 @@ import {
|
|
|
13
13
|
QBSession,
|
|
14
14
|
QBSystemMessage,
|
|
15
15
|
QBUser,
|
|
16
|
-
QBMessageStatusParams,
|
|
17
16
|
AIChatHistory,
|
|
18
17
|
AIAnswerResponse,
|
|
19
18
|
} from 'quickblox/quickblox';
|
|
@@ -107,7 +106,11 @@ export type AuthorizationData = {
|
|
|
107
106
|
};
|
|
108
107
|
|
|
109
108
|
export class RemoteDataSource implements IRemoteDataSource {
|
|
109
|
+
private joinStatusMap: Map<string, boolean> = new Map();
|
|
110
|
+
private joinCheckInterval: NodeJS.Timeout | null = null;
|
|
110
111
|
private processedDialogs = new Set<string>();
|
|
112
|
+
private userCache: Map<string, RemoteUserDTO> = new Map();
|
|
113
|
+
private userCachePreloadInterval: NodeJS.Timeout | null = null;
|
|
111
114
|
|
|
112
115
|
private userDTOMapper: IDTOMapper;
|
|
113
116
|
|
|
@@ -171,10 +174,43 @@ export class RemoteDataSource implements IRemoteDataSource {
|
|
|
171
174
|
|
|
172
175
|
return dialogDTOMapper;
|
|
173
176
|
}
|
|
177
|
+
//
|
|
178
|
+
private startUserCachePreload(): void {
|
|
179
|
+
if (this.userCachePreloadInterval) return; // Избегаем повторного запуска
|
|
180
|
+
|
|
181
|
+
this.userCachePreloadInterval = setInterval(async () => {
|
|
182
|
+
try {
|
|
183
|
+
const pagination = new Pagination(1, 100); // Пагинация по 100 пользователей
|
|
184
|
+
let hasMoreUsers = true;
|
|
185
|
+
|
|
186
|
+
while (hasMoreUsers) {
|
|
187
|
+
const { ResultData, PaginationResult } = await this.getAllUsers(pagination);
|
|
188
|
+
|
|
189
|
+
for (const user of ResultData) {
|
|
190
|
+
if (!this.userCache.has(user.id)) {
|
|
191
|
+
this.userCache.set(user.id, user);
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
if (PaginationResult.getCurrentPage() >= PaginationResult.totalPages) {
|
|
196
|
+
hasMoreUsers = false;
|
|
197
|
+
} else {
|
|
198
|
+
pagination.setCurrentPage(pagination.getCurrentPage() + 1);
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
console.log(`User cache preload complete. Loaded ${this.userCache.size} users.`);
|
|
203
|
+
|
|
204
|
+
clearInterval(this.userCachePreloadInterval!);
|
|
205
|
+
this.userCachePreloadInterval = null;
|
|
206
|
+
} catch (error) {
|
|
207
|
+
console.error('Error during user cache preload:', error);
|
|
208
|
+
}
|
|
209
|
+
}, 4500); // Интервал 10 секунд
|
|
210
|
+
}
|
|
174
211
|
|
|
175
212
|
//
|
|
176
213
|
constructor() {
|
|
177
|
-
console.log('CONSTRUCTOR RemoteDataSourceMock');
|
|
178
214
|
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
179
215
|
// @ts-ignore
|
|
180
216
|
console.log('QB inside RemoteDataSource:', window.QB);
|
|
@@ -199,6 +235,8 @@ export class RemoteDataSource implements IRemoteDataSource {
|
|
|
199
235
|
new SubscriptionPerformer<RemoteMessageDTO>();
|
|
200
236
|
this.subscriptionOnSystemMessages[NotificationTypes.NEW_DIALOG] =
|
|
201
237
|
new SubscriptionPerformer<RemoteMessageDTO>();
|
|
238
|
+
|
|
239
|
+
// this.startUserCachePreload(); //TODO: uncomment this line after test [CSAMPLES-4065] is done
|
|
202
240
|
}
|
|
203
241
|
|
|
204
242
|
// eslint-disable-next-line class-methods-use-this
|
|
@@ -750,10 +788,6 @@ export class RemoteDataSource implements IRemoteDataSource {
|
|
|
750
788
|
error,
|
|
751
789
|
)}, current auth status is: ${this.authProcessed ? 'true' : 'false'}`,
|
|
752
790
|
);
|
|
753
|
-
this.subscriptionOnSessionExpiredListener.informSubscribers(
|
|
754
|
-
true,
|
|
755
|
-
EventMessageType.LocalMessage,
|
|
756
|
-
);
|
|
757
791
|
};
|
|
758
792
|
|
|
759
793
|
QB.chat.onReadStatusListener = (messageId, dialogId, userId) => {
|
|
@@ -823,21 +857,12 @@ export class RemoteDataSource implements IRemoteDataSource {
|
|
|
823
857
|
//
|
|
824
858
|
//
|
|
825
859
|
this.initEventsHandlers();
|
|
826
|
-
//
|
|
827
|
-
//
|
|
828
|
-
console.log('USER DATA : ', userRequiredParams);
|
|
829
|
-
console.log('USER SESSION DATA : ', sessionResult);
|
|
830
|
-
console.log('Session token : ', sessionResult.token);
|
|
831
860
|
|
|
832
861
|
const session = sessionResult;
|
|
833
862
|
const sessionDataTmp = JSON.stringify(session);
|
|
834
863
|
|
|
835
864
|
const sessionData = JSON.parse(sessionDataTmp);
|
|
836
865
|
|
|
837
|
-
// eslint-disable-next-line @typescript-eslint/restrict-template-expressions
|
|
838
|
-
console.log(`user_id = ${sessionData.user_id}`);
|
|
839
|
-
// eslint-disable-next-line @typescript-eslint/restrict-template-expressions
|
|
840
|
-
console.log(`session token to chat init = ${sessionData.token}`);
|
|
841
866
|
const authInformation = {
|
|
842
867
|
userName: authParams.login,
|
|
843
868
|
userId: sessionData.user_id,
|
|
@@ -850,28 +875,55 @@ export class RemoteDataSource implements IRemoteDataSource {
|
|
|
850
875
|
password: authInformation.password,
|
|
851
876
|
};
|
|
852
877
|
|
|
853
|
-
console.log(paramsConnect);
|
|
854
|
-
//
|
|
855
878
|
const connectResult = await QBChatConnect(paramsConnect);
|
|
856
879
|
|
|
857
880
|
if (connectResult) {
|
|
858
881
|
//
|
|
859
882
|
this._authInformation = authInformation;
|
|
860
883
|
this.setAuthProcessedSuccessed();
|
|
861
|
-
console.log('CHAT CONNECTED. CAN WORK!');
|
|
862
|
-
console.log('CONNECTION DATA: ', JSON.stringify(authInformation));
|
|
863
|
-
// //
|
|
864
|
-
// this.initEventsHandlers();
|
|
865
|
-
// //
|
|
866
884
|
} else {
|
|
867
885
|
console.log('could not connect to chat');
|
|
868
886
|
}
|
|
869
887
|
|
|
870
888
|
//
|
|
871
889
|
}
|
|
890
|
+
//get dialogs flow
|
|
872
891
|
|
|
873
|
-
private async
|
|
874
|
-
|
|
892
|
+
private async joinGroupDialog(dialogId: string): Promise<void> {
|
|
893
|
+
try {
|
|
894
|
+
await QBJoinGroupDialog(dialogId).catch(() => {
|
|
895
|
+
this.joinStatusMap.set(dialogId, false);
|
|
896
|
+
throw new RemoteDataSourceException(
|
|
897
|
+
INCORRECT_REMOTE_DATASOURCE_DATA_EXCEPTION_MESSAGE,
|
|
898
|
+
INCORRECT_REMOTE_DATASOURCE_DATA_EXCEPTION_CODE,
|
|
899
|
+
);
|
|
900
|
+
});
|
|
901
|
+
this.joinStatusMap.set(dialogId, true);
|
|
902
|
+
} catch (reason) {
|
|
903
|
+
console.log(`QBJoinGroupDialog error for dialog ${dialogId}:`, reason);
|
|
904
|
+
this.joinStatusMap.set(dialogId, false);
|
|
905
|
+
}
|
|
906
|
+
}
|
|
907
|
+
|
|
908
|
+
//version 0.5.0-beta.11,12,14
|
|
909
|
+
private startJoinRetryProcess(): void {
|
|
910
|
+
if (this.joinCheckInterval) return;
|
|
911
|
+
|
|
912
|
+
this.joinCheckInterval = setInterval(async () => {
|
|
913
|
+
const dialogsToRetry = Array.from(this.joinStatusMap.entries())
|
|
914
|
+
.filter(([_, isJoined]) => !isJoined)
|
|
915
|
+
.map(([id]) => id);
|
|
916
|
+
|
|
917
|
+
if (dialogsToRetry.length === 0) {
|
|
918
|
+
clearInterval(this.joinCheckInterval!);
|
|
919
|
+
this.joinCheckInterval = null;
|
|
920
|
+
console.log('All dialogs successfully joined. Stopping retry process.');
|
|
921
|
+
return;
|
|
922
|
+
}
|
|
923
|
+
|
|
924
|
+
console.log(`Retrying join for ${dialogsToRetry.length} dialogs...`);
|
|
925
|
+
await this.processDialogs(dialogsToRetry);
|
|
926
|
+
}, 7000);
|
|
875
927
|
}
|
|
876
928
|
|
|
877
929
|
private async processDialogsInBackground(dialogIds: string[]): Promise<void> {
|
|
@@ -893,58 +945,36 @@ export class RemoteDataSource implements IRemoteDataSource {
|
|
|
893
945
|
console.log('Background processing complete.');
|
|
894
946
|
}
|
|
895
947
|
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
try {
|
|
899
|
-
await QBJoinGroupDialog(dialogId);
|
|
900
|
-
} catch (reason) {
|
|
901
|
-
console.log(`QBJoinGroupDialog error for dialog ${dialogId}:`, reason);
|
|
902
|
-
}
|
|
948
|
+
private async processDialogs(dialogIds: string[]): Promise<void> {
|
|
949
|
+
await Promise.all(dialogIds.map((id) => this.joinGroupDialog(id)));
|
|
903
950
|
}
|
|
904
951
|
|
|
905
952
|
async getDialogs(pagination?: Pagination): Promise<RemoteDialogsDTO> {
|
|
906
953
|
let currentPagination: Pagination = pagination || new Pagination();
|
|
907
954
|
|
|
908
|
-
console.log(
|
|
909
|
-
'call getDialogs in RemoteDataSourceMock param pagination: ',
|
|
910
|
-
JSON.stringify(pagination)
|
|
911
|
-
);
|
|
912
|
-
console.log(
|
|
913
|
-
'call getDialogs in RemoteDataSourceMock with result pagination: ',
|
|
914
|
-
JSON.stringify(currentPagination)
|
|
915
|
-
);
|
|
916
|
-
|
|
917
955
|
const pageNumber = currentPagination.getCurrentPage() || 1;
|
|
918
|
-
console.log('pageNumber: ', pageNumber);
|
|
919
956
|
const perPage = currentPagination.perPage || 100;
|
|
920
|
-
console.log('perPage: ', perPage);
|
|
921
957
|
|
|
922
|
-
const params =
|
|
958
|
+
const params: Dictionary<any> = {
|
|
923
959
|
created_at: { lt: Date.now() / 1000 },
|
|
924
960
|
sort_desc: 'updated_at',
|
|
925
961
|
page: pageNumber,
|
|
926
962
|
limit: perPage,
|
|
927
|
-
type: { in: [2, 3] },
|
|
963
|
+
// type: { in: [2, 3] },
|
|
928
964
|
};
|
|
929
965
|
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
966
|
+
// Conditionally filter dialog types unless public dialogs should be shown
|
|
967
|
+
if (!QBConfig.appConfig?.showPublicDialogsInList) {
|
|
968
|
+
params.type = {
|
|
969
|
+
in: [2, 3], // Only group and private dialogs
|
|
970
|
+
};
|
|
971
|
+
}
|
|
934
972
|
|
|
935
973
|
const dialogsDTO: Array<RemoteDialogDTO> = [];
|
|
936
974
|
const joinDialogIds: string[] = [];
|
|
937
975
|
const qbDialogs: QBGetDialogResult | undefined = await QBGetDialogs(params);
|
|
938
976
|
|
|
939
977
|
if (qbDialogs) {
|
|
940
|
-
console.log(
|
|
941
|
-
`request completed. have: total_entries ${
|
|
942
|
-
qbDialogs.total_entries
|
|
943
|
-
}, limit: ${qbDialogs.limit}, skip: ${
|
|
944
|
-
qbDialogs.skip
|
|
945
|
-
} items: ${JSON.stringify(qbDialogs.items)}`
|
|
946
|
-
);
|
|
947
|
-
|
|
948
978
|
currentPagination = new Pagination(0, perPage);
|
|
949
979
|
currentPagination.totalPages = qbDialogs.total_entries / perPage;
|
|
950
980
|
currentPagination.setCurrentPage(pageNumber);
|
|
@@ -957,25 +987,135 @@ export class RemoteDataSource implements IRemoteDataSource {
|
|
|
957
987
|
|
|
958
988
|
if (newDTO.type === DialogType.group && !this.processedDialogs.has(newDTO.id)) {
|
|
959
989
|
this.processedDialogs.add(newDTO.id);
|
|
960
|
-
|
|
990
|
+
|
|
991
|
+
if (!this.joinStatusMap.has(newDTO.id)) {
|
|
992
|
+
this.joinStatusMap.set(newDTO.id, false);
|
|
993
|
+
joinDialogIds.push(newDTO.id);
|
|
994
|
+
}
|
|
961
995
|
}
|
|
962
996
|
|
|
963
997
|
dialogsDTO.push(newDTO);
|
|
964
998
|
}
|
|
965
999
|
|
|
966
|
-
const firstBatch = joinDialogIds.slice(0,
|
|
1000
|
+
const firstBatch = joinDialogIds.slice(0, 24);
|
|
967
1001
|
await this.processDialogs(firstBatch);
|
|
968
1002
|
|
|
969
|
-
const remainingDialogs = joinDialogIds.slice(
|
|
1003
|
+
const remainingDialogs = joinDialogIds.slice(24);
|
|
970
1004
|
if (remainingDialogs.length) {
|
|
971
|
-
this.processDialogsInBackground(remainingDialogs)
|
|
1005
|
+
await this.processDialogsInBackground(remainingDialogs);
|
|
1006
|
+
this.startJoinRetryProcess();
|
|
972
1007
|
}
|
|
973
1008
|
}
|
|
974
1009
|
|
|
975
1010
|
return Promise.resolve(new RemoteDialogsDTO(dialogsDTO, currentPagination));
|
|
976
1011
|
}
|
|
977
1012
|
|
|
1013
|
+
//tested in 0.5.0-beta.10
|
|
1014
|
+
// private async processDialogs(dialogIds: string[]): Promise<void> {
|
|
1015
|
+
// await Promise.all(dialogIds.map((id) => this.joinGroupDialog(id)));
|
|
1016
|
+
// }
|
|
1017
|
+
//
|
|
1018
|
+
// private async processDialogsInBackground(dialogIds: string[]): Promise<void> {
|
|
1019
|
+
// const BATCH_SIZE = 12;
|
|
1020
|
+
//
|
|
1021
|
+
// console.log(`Starting background processing for ${dialogIds.length} dialogs`);
|
|
1022
|
+
//
|
|
1023
|
+
// for (let i = 0; i < dialogIds.length; i += BATCH_SIZE) {
|
|
1024
|
+
// const batch = dialogIds.slice(i, i + BATCH_SIZE);
|
|
1025
|
+
//
|
|
1026
|
+
// console.log(`Processing batch ${i / BATCH_SIZE + 1}:`, batch);
|
|
1027
|
+
//
|
|
1028
|
+
// await Promise.all(batch.map((id) => this.joinGroupDialog(id)));
|
|
1029
|
+
// console.log(`Batch ${i / BATCH_SIZE + 1} completed.`);
|
|
1030
|
+
//
|
|
1031
|
+
// await new Promise((resolve) => setTimeout(resolve, 1500));
|
|
1032
|
+
// }
|
|
1033
|
+
//
|
|
1034
|
+
// console.log('Background processing complete.');
|
|
1035
|
+
// }
|
|
1036
|
+
//
|
|
1037
|
+
// private async joinGroupDialog(dialogId: string): Promise<void> {
|
|
1038
|
+
// try {
|
|
1039
|
+
// await QBJoinGroupDialog(dialogId);
|
|
1040
|
+
// } catch (reason) {
|
|
1041
|
+
// console.log(`QBJoinGroupDialog error for dialog ${dialogId}:`, reason);
|
|
1042
|
+
// }
|
|
1043
|
+
// }
|
|
1044
|
+
//
|
|
1045
|
+
// async getDialogs(pagination?: Pagination): Promise<RemoteDialogsDTO> {
|
|
1046
|
+
// let currentPagination: Pagination = pagination || new Pagination();
|
|
1047
|
+
//
|
|
1048
|
+
// console.log(
|
|
1049
|
+
// 'call getDialogs in RemoteDataSourceMock param pagination: ',
|
|
1050
|
+
// JSON.stringify(pagination)
|
|
1051
|
+
// );
|
|
1052
|
+
// console.log(
|
|
1053
|
+
// 'call getDialogs in RemoteDataSourceMock with result pagination: ',
|
|
1054
|
+
// JSON.stringify(currentPagination)
|
|
1055
|
+
// );
|
|
1056
|
+
//
|
|
1057
|
+
// const pageNumber = currentPagination.getCurrentPage() || 1;
|
|
1058
|
+
// console.log('pageNumber: ', pageNumber);
|
|
1059
|
+
// const perPage = currentPagination.perPage || 100;
|
|
1060
|
+
// console.log('perPage: ', perPage);
|
|
1061
|
+
//
|
|
1062
|
+
// const params = {
|
|
1063
|
+
// created_at: { lt: Date.now() / 1000 },
|
|
1064
|
+
// sort_desc: 'updated_at',
|
|
1065
|
+
// page: pageNumber,
|
|
1066
|
+
// limit: perPage,
|
|
1067
|
+
// type: { in: [2, 3] },
|
|
1068
|
+
// };
|
|
1069
|
+
//
|
|
1070
|
+
// console.log(
|
|
1071
|
+
// 'call getDialogs in RemoteDataSourceMock with params: ',
|
|
1072
|
+
// JSON.stringify(params)
|
|
1073
|
+
// );
|
|
1074
|
+
//
|
|
1075
|
+
// const dialogsDTO: Array<RemoteDialogDTO> = [];
|
|
1076
|
+
// const joinDialogIds: string[] = [];
|
|
1077
|
+
// const qbDialogs: QBGetDialogResult | undefined = await QBGetDialogs(params);
|
|
1078
|
+
//
|
|
1079
|
+
// if (qbDialogs) {
|
|
1080
|
+
// console.log(
|
|
1081
|
+
// `request completed. have: total_entries ${
|
|
1082
|
+
// qbDialogs.total_entries
|
|
1083
|
+
// }, limit: ${qbDialogs.limit}, skip: ${
|
|
1084
|
+
// qbDialogs.skip
|
|
1085
|
+
// } items: ${JSON.stringify(qbDialogs.items)}`
|
|
1086
|
+
// );
|
|
1087
|
+
//
|
|
1088
|
+
// currentPagination = new Pagination(0, perPage);
|
|
1089
|
+
// currentPagination.totalPages = qbDialogs.total_entries / perPage;
|
|
1090
|
+
// currentPagination.setCurrentPage(pageNumber);
|
|
1091
|
+
//
|
|
1092
|
+
// for (const item of qbDialogs.items) {
|
|
1093
|
+
// const qbEntity: QBChatDialog = item;
|
|
1094
|
+
// if (!qbEntity) continue;
|
|
1095
|
+
//
|
|
1096
|
+
// const newDTO: RemoteDialogDTO = await this.getCurrentDialogDTOMapper().toTDO(qbEntity);
|
|
1097
|
+
//
|
|
1098
|
+
// if (newDTO.type === DialogType.group && !this.processedDialogs.has(newDTO.id)) {
|
|
1099
|
+
// this.processedDialogs.add(newDTO.id);
|
|
1100
|
+
// joinDialogIds.push(newDTO.id);
|
|
1101
|
+
// }
|
|
1102
|
+
//
|
|
1103
|
+
// dialogsDTO.push(newDTO);
|
|
1104
|
+
// }
|
|
1105
|
+
//
|
|
1106
|
+
// const firstBatch = joinDialogIds.slice(0, 12);
|
|
1107
|
+
// await this.processDialogs(firstBatch);
|
|
1108
|
+
//
|
|
1109
|
+
// const remainingDialogs = joinDialogIds.slice(12);
|
|
1110
|
+
// if (remainingDialogs.length) {
|
|
1111
|
+
// this.processDialogsInBackground(remainingDialogs).then();
|
|
1112
|
+
// }
|
|
1113
|
+
// }
|
|
1114
|
+
//
|
|
1115
|
+
// return Promise.resolve(new RemoteDialogsDTO(dialogsDTO, currentPagination));
|
|
1116
|
+
// }
|
|
978
1117
|
|
|
1118
|
+
// original version 0.4.5
|
|
979
1119
|
// async getDialogs(pagination?: Pagination): Promise<RemoteDialogsDTO> {
|
|
980
1120
|
// let currentPagination: Pagination = pagination || new Pagination();
|
|
981
1121
|
//
|
|
@@ -1230,8 +1370,53 @@ export class RemoteDataSource implements IRemoteDataSource {
|
|
|
1230
1370
|
return Promise.resolve();
|
|
1231
1371
|
}
|
|
1232
1372
|
|
|
1373
|
+
// async getUser(dto: RemoteUserDTO): Promise<RemoteUserDTO> {
|
|
1374
|
+
// const currentItem: QBUser | undefined = await QBUsersGetById(
|
|
1375
|
+
// parseInt(dto.id, 10),
|
|
1376
|
+
// );
|
|
1377
|
+
//
|
|
1378
|
+
// if (currentItem === null || currentItem === undefined) {
|
|
1379
|
+
// return Promise.reject(
|
|
1380
|
+
// new RemoteDataSourceException(
|
|
1381
|
+
// INCORRECT_REMOTE_DATASOURCE_DATA_EXCEPTION_MESSAGE,
|
|
1382
|
+
// INCORRECT_REMOTE_DATASOURCE_DATA_EXCEPTION_CODE,
|
|
1383
|
+
// ),
|
|
1384
|
+
// );
|
|
1385
|
+
// }
|
|
1386
|
+
// let dtoUser: RemoteUserDTO | undefined;
|
|
1387
|
+
//
|
|
1388
|
+
// try {
|
|
1389
|
+
// dtoUser = await this.userDTOMapper.toTDO<QBUser, RemoteUserDTO>(
|
|
1390
|
+
// currentItem,
|
|
1391
|
+
// );
|
|
1392
|
+
// } catch (e) {
|
|
1393
|
+
// console.log('problem with:');
|
|
1394
|
+
// console.log(JSON.stringify(currentItem));
|
|
1395
|
+
// console.log((e as MapperDTOException).message);
|
|
1396
|
+
// console.log((e as MapperDTOException)._description);
|
|
1397
|
+
// }
|
|
1398
|
+
//
|
|
1399
|
+
// if (dtoUser !== null || dtoUser !== undefined) {
|
|
1400
|
+
// return Promise.resolve(dtoUser as RemoteUserDTO);
|
|
1401
|
+
// }
|
|
1402
|
+
//
|
|
1403
|
+
// return Promise.reject(
|
|
1404
|
+
// new RemoteDataSourceException(
|
|
1405
|
+
// NOT_FOUND_REMOTE_DATASOURCE_EXCEPTION_MESSAGE,
|
|
1406
|
+
// NOT_FOUND_REMOTE_DATASOURCE_EXCEPTION_CODE,
|
|
1407
|
+
// `not found user with id: ${dto.id} (${dto.full_name})`,
|
|
1408
|
+
// ),
|
|
1409
|
+
// );
|
|
1410
|
+
// }
|
|
1411
|
+
|
|
1233
1412
|
// eslint-disable-next-line @typescript-eslint/require-await,class-methods-use-this,@typescript-eslint/no-unused-vars
|
|
1234
1413
|
async getUser(dto: RemoteUserDTO): Promise<RemoteUserDTO> {
|
|
1414
|
+
// Проверяем кэш перед запросом на сервер
|
|
1415
|
+
if (this.userCache.has(dto.id)) {
|
|
1416
|
+
console.log(`User ${dto.id} found in cache.`);
|
|
1417
|
+
return Promise.resolve(this.userCache.get(dto.id)!);
|
|
1418
|
+
}
|
|
1419
|
+
|
|
1235
1420
|
const currentItem: QBUser | undefined = await QBUsersGetById(
|
|
1236
1421
|
parseInt(dto.id, 10),
|
|
1237
1422
|
);
|
|
@@ -1244,6 +1429,7 @@ export class RemoteDataSource implements IRemoteDataSource {
|
|
|
1244
1429
|
),
|
|
1245
1430
|
);
|
|
1246
1431
|
}
|
|
1432
|
+
|
|
1247
1433
|
let dtoUser: RemoteUserDTO | undefined;
|
|
1248
1434
|
|
|
1249
1435
|
try {
|
|
@@ -1257,7 +1443,10 @@ export class RemoteDataSource implements IRemoteDataSource {
|
|
|
1257
1443
|
console.log((e as MapperDTOException)._description);
|
|
1258
1444
|
}
|
|
1259
1445
|
|
|
1260
|
-
if (dtoUser !== null
|
|
1446
|
+
if (dtoUser !== null && dtoUser !== undefined) {
|
|
1447
|
+
// Сохраняем пользователя в кэше
|
|
1448
|
+
this.userCache.set(dto.id, dtoUser);
|
|
1449
|
+
console.log(`User ${dto.id} added to cache.`);
|
|
1261
1450
|
return Promise.resolve(dtoUser as RemoteUserDTO);
|
|
1262
1451
|
}
|
|
1263
1452
|
|
|
@@ -1285,7 +1474,6 @@ export class RemoteDataSource implements IRemoteDataSource {
|
|
|
1285
1474
|
return Promise.resolve(new RemoteUsersDTO(usersDTO, new Pagination()));
|
|
1286
1475
|
}
|
|
1287
1476
|
|
|
1288
|
-
//
|
|
1289
1477
|
// eslint-disable-next-line class-methods-use-this
|
|
1290
1478
|
public async getAllUsers(
|
|
1291
1479
|
pagination: Pagination,
|
|
@@ -1371,8 +1559,6 @@ export class RemoteDataSource implements IRemoteDataSource {
|
|
|
1371
1559
|
|
|
1372
1560
|
return { ResultData: users, PaginationResult: resultPagination };
|
|
1373
1561
|
}
|
|
1374
|
-
//
|
|
1375
|
-
//
|
|
1376
1562
|
|
|
1377
1563
|
// eslint-disable-next-line @typescript-eslint/require-await,class-methods-use-this,@typescript-eslint/no-unused-vars,@typescript-eslint/ban-ts-comment
|
|
1378
1564
|
// @ts-ignore
|
|
@@ -1397,9 +1583,7 @@ export class RemoteDataSource implements IRemoteDataSource {
|
|
|
1397
1583
|
);
|
|
1398
1584
|
}
|
|
1399
1585
|
console.log(
|
|
1400
|
-
`GET MESSAGES ${qbMessages.items.length} FROM SERVER
|
|
1401
|
-
qbMessages,
|
|
1402
|
-
)} `,
|
|
1586
|
+
`GET MESSAGES ${qbMessages.items.length} FROM SERVER.`,
|
|
1403
1587
|
);
|
|
1404
1588
|
const currentUserId = this._authInformation?.userId;
|
|
1405
1589
|
|
|
@@ -1444,12 +1628,15 @@ export class RemoteDataSource implements IRemoteDataSource {
|
|
|
1444
1628
|
await this.getCurrentDialogDTOMapper().fromDTO(dialogDTO);
|
|
1445
1629
|
|
|
1446
1630
|
if (dialogDTO.type === DialogType.group) {
|
|
1447
|
-
|
|
1448
|
-
|
|
1449
|
-
|
|
1450
|
-
|
|
1451
|
-
|
|
1452
|
-
|
|
1631
|
+
if (!this.joinStatusMap.has(dialogDTO.id)) {
|
|
1632
|
+
await this.joinGroupDialog(dialogDTO.id);
|
|
1633
|
+
}
|
|
1634
|
+
// await QBJoinGroupDialog(dialogDTO.id).catch(() => {
|
|
1635
|
+
// throw new RemoteDataSourceException(
|
|
1636
|
+
// INCORRECT_REMOTE_DATASOURCE_DATA_EXCEPTION_MESSAGE,
|
|
1637
|
+
// INCORRECT_REMOTE_DATASOURCE_DATA_EXCEPTION_CODE,
|
|
1638
|
+
// );
|
|
1639
|
+
// });
|
|
1453
1640
|
}
|
|
1454
1641
|
|
|
1455
1642
|
QBSendIsTypingStatus(qbEntity, senderId);
|
|
@@ -1478,27 +1665,66 @@ export class RemoteDataSource implements IRemoteDataSource {
|
|
|
1478
1665
|
//
|
|
1479
1666
|
const messageText = dto.message;
|
|
1480
1667
|
|
|
1481
|
-
|
|
1482
|
-
|
|
1483
|
-
|
|
1484
|
-
|
|
1485
|
-
|
|
1486
|
-
|
|
1487
|
-
|
|
1488
|
-
|
|
1489
|
-
|
|
1490
|
-
|
|
1491
|
-
|
|
1492
|
-
|
|
1493
|
-
|
|
1494
|
-
|
|
1495
|
-
|
|
1496
|
-
|
|
1497
|
-
|
|
1498
|
-
|
|
1499
|
-
|
|
1500
|
-
|
|
1501
|
-
|
|
1668
|
+
const extension: Partial<QBUIKitChatNewMessage['extension']> = {
|
|
1669
|
+
save_to_history: 1,
|
|
1670
|
+
dialog_id: dto.dialogId,
|
|
1671
|
+
};
|
|
1672
|
+
|
|
1673
|
+
if (dto.notification_type) {
|
|
1674
|
+
extension.notification_type = dto.notification_type;
|
|
1675
|
+
}
|
|
1676
|
+
|
|
1677
|
+
if (dto.sender_id || dto.recipient_id) {
|
|
1678
|
+
extension.sender_id = dto.sender_id || dto.recipient_id;
|
|
1679
|
+
}
|
|
1680
|
+
|
|
1681
|
+
if (dto.qb_message_action) {
|
|
1682
|
+
extension.qb_message_action = dto.qb_message_action;
|
|
1683
|
+
}
|
|
1684
|
+
|
|
1685
|
+
if (dto.origin_sender_name) {
|
|
1686
|
+
extension.origin_sender_name = dto.origin_sender_name;
|
|
1687
|
+
}
|
|
1688
|
+
|
|
1689
|
+
const originalMessages = MessageDTOMapper.translateOriginalDataToJSON(
|
|
1690
|
+
MessageDTOMapper.convertToQBChatNewMessage(dto.qb_original_messages || []) || [],
|
|
1691
|
+
);
|
|
1692
|
+
|
|
1693
|
+
if (originalMessages && originalMessages.length > 0) {
|
|
1694
|
+
extension.qb_original_messages = originalMessages;
|
|
1695
|
+
}
|
|
1696
|
+
|
|
1697
|
+
|
|
1698
|
+
const qbEntity: QBUIKitChatNewMessage = {
|
|
1699
|
+
type: dto.dialog_type === DialogType.private ? 'chat' : 'groupchat',
|
|
1700
|
+
body: messageText || '',
|
|
1701
|
+
dialog_id: dto.dialogId,
|
|
1702
|
+
extension: extension as QBUIKitChatNewMessage['extension'],
|
|
1703
|
+
markable: 1,
|
|
1704
|
+
};
|
|
1705
|
+
|
|
1706
|
+
|
|
1707
|
+
// const qbEntity: QBUIKitChatNewMessage = {
|
|
1708
|
+
// type: dto.dialog_type === DialogType.private ? 'chat' : 'groupchat',
|
|
1709
|
+
// body: messageText || '',
|
|
1710
|
+
// notification_type: dto.notification_type,
|
|
1711
|
+
// dialog_id: dto.dialogId,
|
|
1712
|
+
// extension: {
|
|
1713
|
+
// save_to_history: 1,
|
|
1714
|
+
// dialog_id: dto.dialogId,
|
|
1715
|
+
// notification_type: dto.notification_type,
|
|
1716
|
+
// sender_id: dto.sender_id || dto.recipient_id,
|
|
1717
|
+
// qb_message_action: dto.qb_message_action, // 'forward' 'reply'
|
|
1718
|
+
// origin_sender_name: dto.origin_sender_name,
|
|
1719
|
+
// qb_original_messages: MessageDTOMapper.translateOriginalDataToJSON(
|
|
1720
|
+
// MessageDTOMapper.convertToQBChatNewMessage(
|
|
1721
|
+
// dto.qb_original_messages || [],
|
|
1722
|
+
// ) || [],
|
|
1723
|
+
// ),
|
|
1724
|
+
// },
|
|
1725
|
+
// markable: 1,
|
|
1726
|
+
// // markable: 0, // mark_as_read ??
|
|
1727
|
+
// };
|
|
1502
1728
|
|
|
1503
1729
|
if (dto.attachments?.length > 0) {
|
|
1504
1730
|
qbEntity.extension.attachments = [];
|
|
@@ -1514,20 +1740,34 @@ export class RemoteDataSource implements IRemoteDataSource {
|
|
|
1514
1740
|
qbEntity.extension.attachments?.push(chatMessageAttachment);
|
|
1515
1741
|
});
|
|
1516
1742
|
}
|
|
1517
|
-
let qbMessageId: QBChatMessage['_id'];
|
|
1743
|
+
let qbMessageId: QBChatMessage['_id'] | undefined | null;
|
|
1518
1744
|
|
|
1519
1745
|
if (dto.dialog_type === DialogType.private) {
|
|
1520
1746
|
qbMessageId = await QBChatSendMessage(dto.recipient_id, qbEntity);
|
|
1521
1747
|
} else {
|
|
1522
|
-
|
|
1523
|
-
|
|
1524
|
-
|
|
1525
|
-
|
|
1526
|
-
|
|
1527
|
-
|
|
1748
|
+
//original version
|
|
1749
|
+
// await QBJoinGroupDialog(dto.dialogId).catch(() => {
|
|
1750
|
+
// throw new RemoteDataSourceException(
|
|
1751
|
+
// INCORRECT_REMOTE_DATASOURCE_DATA_EXCEPTION_MESSAGE,
|
|
1752
|
+
// INCORRECT_REMOTE_DATASOURCE_DATA_EXCEPTION_CODE,
|
|
1753
|
+
// );
|
|
1754
|
+
// });
|
|
1755
|
+
//beta version: 13-15
|
|
1756
|
+
// if (!this.joinStatusMap.has(dto.dialogId)) {
|
|
1757
|
+
// await this.joinGroupDialog(dto.dialogId);
|
|
1758
|
+
// }
|
|
1759
|
+
await this.joinGroupDialog(dto.dialogId);
|
|
1528
1760
|
const dialogJid = QB.chat.helpers.getRoomJidFromDialogId(dto.dialogId);
|
|
1529
|
-
|
|
1530
|
-
|
|
1761
|
+
try {
|
|
1762
|
+
qbMessageId = await QBChatSendMessage(dialogJid, qbEntity);
|
|
1763
|
+
console.log(`Dialog joined status is ${this.joinStatusMap.has(dto.dialogId)} and message was sent with Id: ${qbMessageId}`);
|
|
1764
|
+
}catch (e) {
|
|
1765
|
+
qbMessageId = undefined;
|
|
1766
|
+
const errorMessage = `Error in DataSource: send message throw: ${stringifyError(e)}`;
|
|
1767
|
+
console.log('Error in DataSource: send message throw: ', errorMessage);
|
|
1768
|
+
console.warn('Error in DataSource: send message throw: ', errorMessage);
|
|
1769
|
+
console.error('Error in DataSource: send message throw: ', errorMessage);
|
|
1770
|
+
}
|
|
1531
1771
|
}
|
|
1532
1772
|
|
|
1533
1773
|
if (qbMessageId === null || qbMessageId === undefined) {
|
|
@@ -1538,7 +1778,7 @@ export class RemoteDataSource implements IRemoteDataSource {
|
|
|
1538
1778
|
),
|
|
1539
1779
|
);
|
|
1540
1780
|
}
|
|
1541
|
-
console.log(
|
|
1781
|
+
console.log(`DataSource: regular message was sent, id: ${qbMessageId}`);
|
|
1542
1782
|
// eslint-disable-next-line no-param-reassign
|
|
1543
1783
|
dto.id = qbMessageId;
|
|
1544
1784
|
|
|
@@ -23,7 +23,6 @@ export class CreateDialogUseCase implements IUseCase<void, DialogEntity> {
|
|
|
23
23
|
newDialog: GroupDialogEntity,
|
|
24
24
|
textInformationMessage: string,
|
|
25
25
|
) {
|
|
26
|
-
console.log('CONSTRUCTOR CreateDialogUseCase');
|
|
27
26
|
this.dialogRepository = dialogRepository;
|
|
28
27
|
this.newDialog = newDialog;
|
|
29
28
|
this.eventMessagesRepository = eventMessagesRepository;
|
|
@@ -23,7 +23,6 @@ export class ForwardMessagesUseCase implements IUseCase<void, boolean> {
|
|
|
23
23
|
relatedMessage: MessageEntity,
|
|
24
24
|
userName: string,
|
|
25
25
|
) {
|
|
26
|
-
console.log('CONSTRUCTOR ForwardMessagesUseCase');
|
|
27
26
|
this.messagesRepository = messagesRepository;
|
|
28
27
|
this.relatedMessage = relatedMessage;
|
|
29
28
|
this.targetDialogs = targetDialogs;
|
|
@@ -11,13 +11,11 @@ export class GetAllDialogsUseCaseWithMock
|
|
|
11
11
|
private readonly pagination: Pagination;
|
|
12
12
|
|
|
13
13
|
constructor(dialogRepository: DialogsRepository, pagination?: Pagination) {
|
|
14
|
-
console.log('CONSTRUCTOR GetAllDialogsUseCaseWithMock');
|
|
15
14
|
this.dialogRepository = dialogRepository;
|
|
16
15
|
this.pagination = pagination || new Pagination();
|
|
17
16
|
}
|
|
18
17
|
|
|
19
18
|
async execute(): Promise<PaginatedResult<DialogEntity>> {
|
|
20
|
-
console.log('execute GetAllDialogsUseCaseWithMock');
|
|
21
19
|
const fromRemote: PaginatedResult<DialogEntity> =
|
|
22
20
|
await this.dialogRepository.getDialogsFromRemote(this.pagination);
|
|
23
21
|
|