quickblox-react-ui-kit 0.3.0 → 0.3.1-beta.2

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.
Files changed (115) hide show
  1. package/dist/CommonTypes/CommonTypes.d.ts +142 -0
  2. package/dist/CommonTypes/FunctionResult.d.ts +0 -54
  3. package/dist/Data/DefaultConfigurations.d.ts +2 -2
  4. package/dist/Data/Stubs.d.ts +6 -5
  5. package/dist/Data/dto/dialog/LocalDialogDTO.d.ts +1 -1
  6. package/dist/Data/dto/dialog/RemoteDialogDTO.d.ts +2 -2
  7. package/dist/Data/dto/user/LocalUserDTO.d.ts +1 -1
  8. package/dist/Data/dto/user/RemoteUserDTO.d.ts +1 -1
  9. package/dist/Data/source/remote/Mapper/MessageDTOMapper.d.ts +1 -0
  10. package/dist/Data/source/remote/RemoteDataSource.d.ts +1 -1
  11. package/dist/Domain/entity/LastMessageEntity.d.ts +1 -1
  12. package/dist/Domain/entity/UserEntity.d.ts +1 -1
  13. package/dist/Presentation/providers/QuickBloxUIKitProvider/QuickBloxUIKitProvider.d.ts +3 -1
  14. package/dist/Presentation/ui-components/TextField/TextField.d.ts +2 -2
  15. package/dist/QBconfig.d.ts +2 -76
  16. package/dist/index-ui.js +767 -787
  17. package/dist/index-ui.js.map +1 -1
  18. package/dist/qb-api-calls/index.d.ts +14 -12
  19. package/dist/utils/formatFileSize.d.ts +1 -0
  20. package/dist/utils/parse.d.ts +1 -0
  21. package/global.d.ts +158 -2835
  22. package/package.json +3 -1
  23. package/src/App.tsx +3 -2
  24. package/src/CommonTypes/CommonTypes.ts +229 -0
  25. package/src/CommonTypes/FunctionResult.ts +0 -59
  26. package/src/Data/Creator.ts +1 -0
  27. package/src/Data/DefaultConfigurations.ts +6 -2
  28. package/src/Data/Stubs.ts +47 -47
  29. package/src/Data/dto/dialog/LocalDialogDTO.ts +2 -2
  30. package/src/Data/dto/dialog/RemoteDialogDTO.ts +4 -4
  31. package/src/Data/dto/user/LocalUserDTO.ts +2 -2
  32. package/src/Data/dto/user/RemoteUserDTO.ts +2 -2
  33. package/src/Data/mapper/DialogLocalDTOMapper.ts +4 -10
  34. package/src/Data/mapper/DialogRemoteDTOMapper.ts +11 -22
  35. package/src/Data/mapper/UserLocalDTOMapper.ts +2 -2
  36. package/src/Data/mapper/UserRemoteDTOMapper.ts +2 -2
  37. package/src/Data/repository/ConnectionRepository.ts +1 -0
  38. package/src/Data/repository/UsersRepository.ts +1 -1
  39. package/src/Data/source/local/ChatLocalStorageDataSource.ts +14 -14
  40. package/src/Data/source/remote/Mapper/DialogDTOMapper.ts +70 -52
  41. package/src/Data/source/remote/Mapper/FileDTOMapper.ts +4 -0
  42. package/src/Data/source/remote/Mapper/MessageDTOMapper.ts +1 -0
  43. package/src/Data/source/remote/Mapper/UserDTOMapper.ts +1 -0
  44. package/src/Data/source/remote/RemoteDataSource.ts +76 -12
  45. package/src/Domain/entity/LastMessageEntity.ts +1 -1
  46. package/src/Domain/entity/UserEntity.ts +1 -1
  47. package/src/Presentation/Views/Dialog/MessageItem/MessageItem.tsx +2 -2
  48. package/src/Presentation/Views/Dialog/useDialogViewModel.ts +44 -150
  49. package/src/Presentation/Views/DialogInfo/DialogInfo.tsx +2 -1
  50. package/src/Presentation/Views/DialogList/DialogList.tsx +65 -2
  51. package/src/Presentation/Views/DialogList/useDialogListViewModel.ts +3 -0
  52. package/src/Presentation/Views/EditDialog/EditDialog.tsx +4 -3
  53. package/src/Presentation/Views/InviteMembers/InviteMembers.tsx +9 -1
  54. package/src/Presentation/Views/InviteMembers/useInviteMembersViewModel.ts +11 -1
  55. package/src/Presentation/Views/PreviewDialog/PreviewDialog.tsx +1 -0
  56. package/src/Presentation/layouts/Desktop/QuickBloxUIKitDesktopLayout.tsx +9 -41
  57. package/src/Presentation/layouts/TestStage/LoginView/Login.tsx +7 -11
  58. package/src/Presentation/providers/QuickBloxUIKitProvider/QuickBloxUIKitProvider.tsx +30 -2
  59. package/src/Presentation/ui-components/SettingsItem/SettingsItem.stories.tsx +1 -0
  60. package/src/Presentation/ui-components/TextField/TextField.tsx +58 -48
  61. package/src/QBconfig.ts +13 -11
  62. package/src/qb-api-calls/index.ts +44 -14
  63. package/src/utils/formatFileSize.ts +8 -0
  64. package/src/utils/parse.ts +2 -0
  65. package/storybook-static/703.2cbec951.iframe.bundle.js +33 -0
  66. package/storybook-static/703.2cbec951.iframe.bundle.js.map +1 -0
  67. package/storybook-static/{758.53b4954a.iframe.bundle.js → 938.56e9d83c.iframe.bundle.js} +1 -14
  68. package/storybook-static/Presentation-ui-components-Avatar-avatar-stories.1b74ae55.iframe.bundle.js +14 -0
  69. package/storybook-static/Presentation-ui-components-Avatar-avatar-stories.1b74ae55.iframe.bundle.js.map +1 -0
  70. package/storybook-static/Presentation-ui-components-Button-Button-stories.84103f20.iframe.bundle.js +14 -0
  71. package/storybook-static/Presentation-ui-components-Button-Button-stories.84103f20.iframe.bundle.js.map +1 -0
  72. package/storybook-static/Presentation-ui-components-DialogItemPreview-DialogItemPreview-stories.bf9005d3.iframe.bundle.js +14 -0
  73. package/storybook-static/Presentation-ui-components-DialogItemPreview-DialogItemPreview-stories.bf9005d3.iframe.bundle.js.map +1 -0
  74. package/storybook-static/Presentation-ui-components-DialogWindow-DialogWindow-stories.f81a8e38.iframe.bundle.js +14 -0
  75. package/storybook-static/Presentation-ui-components-DialogWindow-DialogWindow-stories.f81a8e38.iframe.bundle.js.map +1 -0
  76. package/storybook-static/Presentation-ui-components-Dropdown-Dropdown-stories.141a3ae7.iframe.bundle.js +14 -0
  77. package/storybook-static/Presentation-ui-components-Dropdown-Dropdown-stories.141a3ae7.iframe.bundle.js.map +1 -0
  78. package/storybook-static/Presentation-ui-components-Header-Header-stories.9f45c30e.iframe.bundle.js +14 -0
  79. package/storybook-static/Presentation-ui-components-Header-Header-stories.9f45c30e.iframe.bundle.js.map +1 -0
  80. package/storybook-static/Presentation-ui-components-Loader-Loader-stories.af01e15d.iframe.bundle.js +14 -0
  81. package/storybook-static/Presentation-ui-components-Loader-Loader-stories.af01e15d.iframe.bundle.js.map +1 -0
  82. package/storybook-static/Presentation-ui-components-Message-Message-stories.264d251d.iframe.bundle.js +14 -0
  83. package/storybook-static/Presentation-ui-components-Message-Message-stories.264d251d.iframe.bundle.js.map +1 -0
  84. package/storybook-static/Presentation-ui-components-MessageInput-MessageInput-stories.bf8a24d1.iframe.bundle.js +1 -0
  85. package/storybook-static/{Presentation-ui-components-Placeholder-Placeholder-stories.871f508c.iframe.bundle.js → Presentation-ui-components-Placeholder-Placeholder-stories.97287936.iframe.bundle.js} +14 -1
  86. package/storybook-static/Presentation-ui-components-Placeholder-Placeholder-stories.97287936.iframe.bundle.js.map +1 -0
  87. package/storybook-static/Presentation-ui-components-PreviewFileMessage-PreviewFileMessage-stories.a9f5cd67.iframe.bundle.js +14 -0
  88. package/storybook-static/Presentation-ui-components-PreviewFileMessage-PreviewFileMessage-stories.a9f5cd67.iframe.bundle.js.map +1 -0
  89. package/storybook-static/Presentation-ui-components-SettingsItem-SettingsItem-stories.429a72d5.iframe.bundle.js +14 -0
  90. package/storybook-static/Presentation-ui-components-SettingsItem-SettingsItem-stories.429a72d5.iframe.bundle.js.map +1 -0
  91. package/storybook-static/Presentation-ui-components-TextField-TextField-stories.fd8caf6c.iframe.bundle.js +14 -0
  92. package/storybook-static/Presentation-ui-components-TextField-TextField-stories.fd8caf6c.iframe.bundle.js.map +1 -0
  93. package/storybook-static/{Presentation-ui-components-Toast-Toast-stories.55e63162.iframe.bundle.js → Presentation-ui-components-Toast-Toast-stories.b903385b.iframe.bundle.js} +14 -1
  94. package/storybook-static/Presentation-ui-components-Toast-Toast-stories.b903385b.iframe.bundle.js.map +1 -0
  95. package/storybook-static/{Presentation-ui-components-UserListItem-UserListItem-stories.04d3eefe.iframe.bundle.js → Presentation-ui-components-UserListItem-UserListItem-stories.8781472b.iframe.bundle.js} +14 -1
  96. package/storybook-static/Presentation-ui-components-UserListItem-UserListItem-stories.8781472b.iframe.bundle.js.map +1 -0
  97. package/storybook-static/iframe.html +2 -2
  98. package/storybook-static/{main.597d432b.iframe.bundle.js → main.2f6d7582.iframe.bundle.js} +1 -1
  99. package/storybook-static/project.json +1 -1
  100. package/storybook-static/runtime~main.af13ca55.iframe.bundle.js +1 -0
  101. package/webpack.config.js +2 -1
  102. package/storybook-static/758.53b4954a.iframe.bundle.js.map +0 -1
  103. package/storybook-static/Presentation-ui-components-Avatar-avatar-stories.cf806856.iframe.bundle.js +0 -1
  104. package/storybook-static/Presentation-ui-components-Button-Button-stories.4fac7996.iframe.bundle.js +0 -1
  105. package/storybook-static/Presentation-ui-components-DialogItemPreview-DialogItemPreview-stories.6665bbfb.iframe.bundle.js +0 -1
  106. package/storybook-static/Presentation-ui-components-DialogWindow-DialogWindow-stories.cf340397.iframe.bundle.js +0 -1
  107. package/storybook-static/Presentation-ui-components-Dropdown-Dropdown-stories.b32a1e17.iframe.bundle.js +0 -1
  108. package/storybook-static/Presentation-ui-components-Header-Header-stories.073c4507.iframe.bundle.js +0 -1
  109. package/storybook-static/Presentation-ui-components-Loader-Loader-stories.9bf3fb63.iframe.bundle.js +0 -1
  110. package/storybook-static/Presentation-ui-components-Message-Message-stories.343dfae0.iframe.bundle.js +0 -1
  111. package/storybook-static/Presentation-ui-components-MessageInput-MessageInput-stories.c2ead6a5.iframe.bundle.js +0 -1
  112. package/storybook-static/Presentation-ui-components-PreviewFileMessage-PreviewFileMessage-stories.527e000e.iframe.bundle.js +0 -1
  113. package/storybook-static/Presentation-ui-components-SettingsItem-SettingsItem-stories.2ff75703.iframe.bundle.js +0 -1
  114. package/storybook-static/Presentation-ui-components-TextField-TextField-stories.4a2eef3e.iframe.bundle.js +0 -1
  115. package/storybook-static/runtime~main.7ee2126e.iframe.bundle.js +0 -1
@@ -1,3 +1,20 @@
1
+ import QB, {
2
+ ChatMessageAttachment,
3
+ GetMessagesResult,
4
+ GetUserParams,
5
+ ListUserResponse,
6
+ QBBlobCreate,
7
+ QBBlobCreateUploadParams,
8
+ QBChatDialog,
9
+ QBChatMessage,
10
+ QBChatXMPPMessage,
11
+ QBGetDialogResult,
12
+ QBLoginParams,
13
+ QBSession,
14
+ QBSystemMessage,
15
+ QBUser,
16
+ QBMessageStatusParams,
17
+ } from 'quickblox/quickblox';
1
18
  import { RemoteDialogDTO } from '../../dto/dialog/RemoteDialogDTO';
2
19
  import {
3
20
  INCORRECT_REMOTE_DATASOURCE_DATA_EXCEPTION_CODE,
@@ -20,6 +37,7 @@ import {
20
37
  QBChatConnect,
21
38
  QBChatDisconnect,
22
39
  qbChatGetMessagesExtended,
40
+ QBChatMarkMessageDelivered,
23
41
  QBChatMarkMessageRead,
24
42
  // eslint-disable-next-line @typescript-eslint/no-unused-vars
25
43
  // QBChatMarkMessageRead,
@@ -59,6 +77,11 @@ import { FileDTOMapper } from './Mapper/FileDTOMapper';
59
77
  import { DialogEventInfo } from '../../../Domain/entity/DialogEventInfo';
60
78
  import { IRemoteDataSource } from './IRemoteDataSource';
61
79
  import { QBConfig } from '../../../QBconfig';
80
+ import {
81
+ QBUIKitChatDialog,
82
+ QBUIKitChatNewMessage,
83
+ QBUIKitSystemMessage,
84
+ } from '../../../CommonTypes/CommonTypes';
62
85
 
63
86
  export type PaginatedDTOResult = {
64
87
  PaginationResult: Pagination;
@@ -156,8 +179,40 @@ export class RemoteDataSource implements IRemoteDataSource {
156
179
  new SubscriptionPerformer<RemoteMessageDTO>();
157
180
  }
158
181
 
159
- updateCurrentDialog(dto: RemoteDialogDTO): void {
182
+ async updateCurrentDialog(dto: RemoteDialogDTO): Promise<void> {
160
183
  this.currentDialog = dto;
184
+ //
185
+ //
186
+ const dialogsDTOtoEntityMapper: IMapper = new DialogRemoteDTOMapper();
187
+
188
+ const dialogEntity: DialogEntity = await dialogsDTOtoEntityMapper.toEntity(
189
+ this.currentDialog,
190
+ );
191
+ const userId = this._authInformation?.userId || -1;
192
+ const dialogId = this.currentDialog.id;
193
+ const messageId = this.currentDialog.lastMessageId;
194
+ //
195
+ //
196
+ const resultMessage: DialogEventInfo = {
197
+ eventMessageType: EventMessageType.LocalMessage,
198
+ dialogInfo: dialogEntity,
199
+ messageInfo: undefined,
200
+ messageStatus: {
201
+ isTyping: false,
202
+ userId,
203
+ dialogId,
204
+ messageId,
205
+ deliveryStatus: 'delivered',
206
+ },
207
+ notificationTypes: undefined,
208
+ };
209
+
210
+ this.subscriptionOnMessageStatus.informSubscribers(
211
+ resultMessage,
212
+ EventMessageType.LocalMessage,
213
+ );
214
+ //
215
+ //
161
216
  }
162
217
 
163
218
  public async setUpMockStorage(): Promise<void> {
@@ -335,18 +390,18 @@ export class RemoteDataSource implements IRemoteDataSource {
335
390
 
336
391
  public initEventsHandlers() {
337
392
  console.log('CALL--initEventsHandlers--CALL');
338
- QB.chat.onSystemMessageListener = (message) => {
393
+ QB.chat.onSystemMessageListener = (message: QBUIKitSystemMessage) => {
339
394
  console.log(`EVENT: receive system message: ${JSON.stringify(message)}`);
340
395
  const resultMessage = new RemoteMessageDTO();
341
396
 
342
397
  resultMessage.sender_id = message.userId;
343
398
  resultMessage.message = message.body || 'system message';
344
399
  resultMessage.notification_type =
345
- message.extension.notification_type || NotificationTypes.UPDATE_DIALOG;
400
+ message.extension?.notification_type || NotificationTypes.UPDATE_DIALOG;
346
401
  resultMessage.dialogId = message?.extension?.dialog_id || '';
347
402
 
348
403
  this.subscriptionOnSystemMessages[
349
- resultMessage.notification_type
404
+ resultMessage.notification_type!
350
405
  ].informSubscribers(resultMessage, EventMessageType.SystemMessage);
351
406
  };
352
407
 
@@ -447,7 +502,7 @@ export class RemoteDataSource implements IRemoteDataSource {
447
502
  .then(async (result) => {
448
503
  //
449
504
  // eslint-disable-next-line @typescript-eslint/no-unused-vars
450
- const currentUserId = this._authInformation?.userId;
505
+
451
506
  const dialogs: QBChatDialog[] | undefined = result?.items.filter(
452
507
  (v) => v._id === dialogId,
453
508
  );
@@ -769,6 +824,15 @@ export class RemoteDataSource implements IRemoteDataSource {
769
824
  }
770
825
 
771
826
  //
827
+ const currentUserId = this._authInformation?.userId || 0;
828
+ const statusMessageParams: QBMessageStatusParams = {
829
+ userId: newDTO.lastMessageUserId || currentUserId,
830
+ dialogId: newDTO.id,
831
+ messageId: newDTO.lastMessageId,
832
+ };
833
+
834
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-call
835
+ QBChatMarkMessageDelivered(statusMessageParams);
772
836
 
773
837
  dialogsDTO.push(newDTO);
774
838
  }
@@ -821,7 +885,7 @@ export class RemoteDataSource implements IRemoteDataSource {
821
885
  }
822
886
 
823
887
  async updateDialog(dto: RemoteDialogDTO): Promise<RemoteDialogDTO> {
824
- const qbEntity: QBChatDialog =
888
+ const qbEntity: QBUIKitChatDialog =
825
889
  await this.getCurrentDialogDTOMapper().fromDTO(dto);
826
890
 
827
891
  let data = {};
@@ -847,7 +911,10 @@ export class RemoteDataSource implements IRemoteDataSource {
847
911
  };
848
912
  }
849
913
 
850
- const qbDialogs: QBChatDialog = await QBUpdateDialog(qbEntity._id, data);
914
+ const qbDialogs: QBUIKitChatDialog = await QBUpdateDialog(
915
+ qbEntity._id,
916
+ data,
917
+ );
851
918
 
852
919
  if (qbDialogs === null || qbDialogs === undefined) {
853
920
  return Promise.reject(
@@ -1185,7 +1252,7 @@ export class RemoteDataSource implements IRemoteDataSource {
1185
1252
  //
1186
1253
  const messageText = dto.message;
1187
1254
 
1188
- const qbEntity: QBChatNewMessage = {
1255
+ const qbEntity: QBUIKitChatNewMessage = {
1189
1256
  type: dto.dialog_type === DialogType.private ? 'chat' : 'groupchat',
1190
1257
  body: messageText || '',
1191
1258
  notification_type: dto.notification_type,
@@ -1259,10 +1326,7 @@ export class RemoteDataSource implements IRemoteDataSource {
1259
1326
  let qbMessages: QBSystemMessage | QBChatMessage['_id'] | undefined;
1260
1327
 
1261
1328
  if (dto.notification_type && dto.notification_type.length > 0) {
1262
- const systemMessage: QBSystemMessage = {
1263
- body: null,
1264
- id: '',
1265
- userId: this.authInformation?.userId || 0,
1329
+ const systemMessage: { extension: QBSystemMessage['extension'] } = {
1266
1330
  extension: {
1267
1331
  notification_type: dto.notification_type,
1268
1332
  dialog_id: dto.dialogId,
@@ -1,5 +1,5 @@
1
1
  export interface LastMessageEntity {
2
2
  text: string;
3
- dateSent: string;
3
+ dateSent: number;
4
4
  userId: number;
5
5
  }
@@ -5,7 +5,7 @@ export interface UserEntity {
5
5
  login: string;
6
6
  created_at: string;
7
7
  updated_at: string;
8
- last_request_at: number;
8
+ last_request_at: string;
9
9
  blob_id: string | null;
10
10
  photo: string | null;
11
11
  custom_data: string | null;
@@ -150,8 +150,8 @@ export default function MessageItem({
150
150
  <div className="message-item-additional-part__actions">
151
151
  <MessageContextMenu
152
152
  message={message}
153
- onReply={onReply}
154
- onForward={onForward}
153
+ onReply={() => onReply(item)}
154
+ onForward={() => onForward(item)}
155
155
  enableReplying={enableReplying}
156
156
  enableForwarding={enableForwarding}
157
157
  disableActions={disableAction}
@@ -35,6 +35,8 @@ import { ReplyMessagesUseCase } from '../../../Domain/use_cases/ReplyMessagesUse
35
35
  import { Creator, MessageEntityParams } from '../../../Data/Creator';
36
36
  import { DefaultConfigurations } from '../../../Data/DefaultConfigurations';
37
37
  import { MessageDTOMapper } from '../../../Data/source/remote/Mapper/MessageDTOMapper';
38
+ import { UpdateCurrentDialogInDataSourceUseCase } from '../../../Domain/use_cases/UpdateCurrentDialogInDataSourceUseCase';
39
+ import { RemoteDataSource } from '../../../Data/source/remote/RemoteDataSource';
38
40
 
39
41
  export default function useDialogViewModel(
40
42
  dialogType: DialogType,
@@ -51,6 +53,8 @@ export default function useDialogViewModel(
51
53
  // const [dialogsParticipants, setDialogsParticipants] = useState<number[]>([]);
52
54
 
53
55
  const currentContext = useQbInitializedDataContext();
56
+ const remoteDataSourceMock: RemoteDataSource =
57
+ currentContext.storage.REMOTE_DATA_SOURCE;
54
58
  const QBConfig =
55
59
  currentContext.InitParams.qbConfig ||
56
60
  DefaultConfigurations.getDefaultQBConfig();
@@ -239,14 +243,14 @@ export default function useDialogViewModel(
239
243
  newState = newState.map((elem) => {
240
244
  const v: MessageEntity = {
241
245
  ...elem,
242
- read_ids: [
243
- ...elem.read_ids,
244
- dialogInfo.messageStatus!.userId,
245
- ],
246
- delivered_ids: [
247
- ...elem.delivered_ids,
248
- dialogInfo.messageStatus!.userId,
249
- ],
246
+ read_ids:
247
+ dialogInfo.messageStatus?.deliveryStatus === 'read'
248
+ ? [...elem.read_ids, dialogInfo.messageStatus.userId]
249
+ : [...elem.read_ids],
250
+ delivered_ids:
251
+ dialogInfo.messageStatus?.deliveryStatus === 'delivered'
252
+ ? [...elem.delivered_ids, dialogInfo.messageStatus.userId]
253
+ : [...elem.delivered_ids],
250
254
  };
251
255
 
252
256
  return v;
@@ -381,6 +385,26 @@ export default function useDialogViewModel(
381
385
  return Promise.resolve(resultEnity);
382
386
  };
383
387
 
388
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars,@typescript-eslint/no-empty-function
389
+ function informDataSources(item: DialogEntity) {
390
+ const updateCurrentDialogInDataSourceUseCase: UpdateCurrentDialogInDataSourceUseCase =
391
+ new UpdateCurrentDialogInDataSourceUseCase(
392
+ new DialogsRepository(
393
+ currentContext.storage.LOCAL_DATA_SOURCE,
394
+ remoteDataSourceMock,
395
+ ),
396
+ item as GroupDialogEntity,
397
+ );
398
+
399
+ updateCurrentDialogInDataSourceUseCase.execute().catch((e) => {
400
+ console.log(
401
+ 'useDialogViewModel Error updateCurrentDialogInDataSourceUseCase: ',
402
+ stringifyError(e),
403
+ );
404
+ throw new Error(stringifyError(e));
405
+ });
406
+ }
407
+
384
408
  const sendMessage = (messageToSend: MessageEntity) => {
385
409
  const sendTextMessageUseCase: SendTextMessageUseCase =
386
410
  new SendTextMessageUseCase(
@@ -407,6 +431,18 @@ export default function useDialogViewModel(
407
431
 
408
432
  return newState;
409
433
  });
434
+ if (dialog?.type === DialogType.private) {
435
+ const updDialog = { ...dialog };
436
+
437
+ updDialog.lastMessage.dateSent = messageEntity.date_sent;
438
+ updDialog.lastMessage.text = messageEntity.message;
439
+ updDialog.lastMessage.userId = messageEntity.sender_id;
440
+ updDialog.unreadMessageCount = 0;
441
+ setDialog(updDialog);
442
+ //
443
+ informDataSources(updDialog);
444
+ //
445
+ }
410
446
  });
411
447
  //
412
448
  })
@@ -515,73 +551,6 @@ export default function useDialogViewModel(
515
551
  return true;
516
552
  };
517
553
 
518
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
519
- // const sendAttachmentMessage = async (newMessage: File): Promise<boolean> => {
520
- // console.log('call sendTextMessage');
521
- // setLoading(true);
522
- // const currentUserId = REMOTE_DATA_SOURCE.authInformation?.userId || 0;
523
- //
524
- // try {
525
- // await uploadFile(newMessage)
526
- // // eslint-disable-next-line promise/always-return
527
- // .then((fileMessage: FileEntity) => {
528
- // console.log(JSON.stringify(fileMessage));
529
- //
530
- // const recipientId =
531
- // dialog.type === DialogType.private
532
- // ? (dialog as PrivateDialogEntity).participantId
533
- // : currentUserId;
534
- //
535
- // // eslint-disable-next-line promise/always-return
536
- // const messageBody = fileMessage.name || '[attachment]';
537
- // //
538
- // const messageEntityParams: MessageEntityParams = {
539
- // dialogId: dialog.id,
540
- // message: messageBody,
541
- // sender_id: currentUserId,
542
- // recipient_id: recipientId,
543
- // dialog_type: DialogType.group,
544
- // };
545
- // const messageToSend: MessageEntity =
546
- // Creator.createMessageEntity(messageEntityParams);
547
- // //
548
- //
549
- // messageToSend.dialogType = dialog.type;
550
- // const attachments: ChatMessageAttachmentEntity[] = [
551
- // {
552
- // id: fileMessage.id as string,
553
- // uid: fileMessage.uid,
554
- // type: fileMessage.type!,
555
- // file: fileMessage,
556
- // name: fileMessage.name,
557
- // size: fileMessage.size,
558
- // url: fileMessage.url,
559
- // },
560
- // ];
561
- //
562
- // messageToSend.attachments = attachments;
563
- //
564
- // messageToSend.message = `MediaContentEntity|${messageBody}|${
565
- // fileMessage.uid
566
- // }|${fileMessage.type!.toString()}`;
567
- // sendMessage(messageToSend);
568
- // //
569
- // })
570
- // .catch((reason) => {
571
- // setLoading(false);
572
- // const errorMessage = stringifyError(reason);
573
- //
574
- // console.log('EXCEPTION in sendAttachmentMessage', errorMessage);
575
- //
576
- // throw new Error(errorMessage);
577
- // });
578
- // } catch (e) {
579
- // return false;
580
- // }
581
- //
582
- // return true;
583
- // };
584
-
585
554
  const forwardMessage = async (
586
555
  targetDialogs: DialogEntity[],
587
556
  messagesToForward: MessageEntity[],
@@ -770,81 +739,6 @@ export default function useDialogViewModel(
770
739
 
771
740
  return isOperationSuccessful;
772
741
  };
773
- // const sendReplyMessages = async (
774
- // replyData: ReplyMessagesParams,
775
- // // eslint-disable-next-line @typescript-eslint/require-await
776
- // ): Promise<boolean> => {
777
- // setLoading(true);
778
- // const currentUserId = REMOTE_DATA_SOURCE.authInformation?.userId || 0;
779
- // const messageEntityParams: MessageEntityParams = {
780
- // dialogId: dialog.id,
781
- // message: replyData.relatedTextMessage || '',
782
- // sender_id: currentUserId,
783
- // recipient_id:
784
- // // eslint-disable-next-line promise/always-return
785
- // dialog.type === DialogType.private
786
- // ? (dialog as PrivateDialogEntity).participantId
787
- // : currentUserId,
788
- // dialog_type: DialogType.group,
789
- // };
790
- // const relatedMessage: MessageEntity =
791
- // Creator.createMessageEntity(messageEntityParams);
792
- //
793
- // relatedMessage.dialogType = dialog.type;
794
- //
795
- // let resultOperation = true;
796
- //
797
- // if (replyData.relatedFileMessage) {
798
- // try {
799
- // await uploadFile(replyData.relatedFileMessage)
800
- // .then(async (fileMessage: FileEntity) => {
801
- // const attachments: ChatMessageAttachmentEntity[] = [
802
- // {
803
- // id: fileMessage.id as string,
804
- // uid: fileMessage.uid,
805
- // type: fileMessage.type!,
806
- // file: fileMessage,
807
- // name: fileMessage.name,
808
- // size: fileMessage.size,
809
- // url: fileMessage.url,
810
- // },
811
- // ];
812
- //
813
- // relatedMessage.attachments = attachments;
814
- //
815
- // await replyMessage(replyData.messagesToReply, relatedMessage);
816
- // resultOperation = true;
817
- //
818
- // return resultOperation;
819
- // //
820
- // })
821
- // .catch((reason) => {
822
- // setLoading(false);
823
- // const errorMessage = stringifyError(reason);
824
- //
825
- // console.log('EXCEPTION in sendAttachmentMessage', errorMessage);
826
- // resultOperation = false;
827
- // throw new Error(errorMessage);
828
- // });
829
- // } catch (e) {
830
- // resultOperation = false;
831
- //
832
- // return resultOperation;
833
- // }
834
- // } else {
835
- // await replyMessage(replyData.messagesToReply, relatedMessage).catch(
836
- // () => {
837
- // resultOperation = false;
838
- //
839
- // return resultOperation;
840
- // },
841
- // );
842
- // }
843
- //
844
- // return resultOperation;
845
- // };
846
-
847
- //
848
742
 
849
743
  return {
850
744
  get entity(): DialogEntity {
@@ -85,6 +85,7 @@ const DialogInfo: React.FC<HeaderDialogsProps> = ({
85
85
  if (!result) {
86
86
  toast('Dialog have not been left');
87
87
  }
88
+ leaveModal.toggleModal();
88
89
  })
89
90
  .catch((e) => {
90
91
  console.log(e);
@@ -430,7 +431,7 @@ const DialogInfo: React.FC<HeaderDialogsProps> = ({
430
431
  className="dialog-info-action-wrapper-button"
431
432
  onClick={() => onShowAllMemberClick(true)}
432
433
  variant="outlined"
433
- disabled={dialog.ownerId !== currentUserId}
434
+ disabled={disableAction}
434
435
  >
435
436
  See all members
436
437
  </Button>
@@ -81,6 +81,8 @@ const DialogList: React.FC<DialogsProps> = ({
81
81
  const [showSearchDialogs, setShowSearchDialogs] = React.useState(false);
82
82
  const [nameDialogForSearch, setNameDialogForSearch] = React.useState('');
83
83
  const [isMobile] = useMobileLayout();
84
+ const [pointerEventsValue, setPointerEventsValue] =
85
+ React.useState<string>('auto');
84
86
 
85
87
  useEffect(() => {
86
88
  dialogs.slice(0);
@@ -115,6 +117,27 @@ const DialogList: React.FC<DialogsProps> = ({
115
117
 
116
118
  setDialogsToView(dialogs);
117
119
  }, [dialogListViewModel?.dialogs, selectedDialog]);
120
+ let timeout: NodeJS.Timeout | number | undefined;
121
+
122
+ useEffect(() => {
123
+ return () => {
124
+ if (timeout) {
125
+ clearTimeout(timeout);
126
+ }
127
+ };
128
+ }, []);
129
+ useEffect(() => {
130
+ // let timeout: NodeJS.Timeout | number | undefined;
131
+
132
+ if (dialogListViewModel && dialogListViewModel.loading) {
133
+ setPointerEventsValue('none');
134
+ timeout = setTimeout(() => {
135
+ setPointerEventsValue('auto');
136
+ }, 12000); // блокировать нажатие на 12 секунд
137
+ } else {
138
+ setPointerEventsValue('auto');
139
+ }
140
+ }, [dialogListViewModel.loading]);
118
141
 
119
142
  // eslint-disable-next-line @typescript-eslint/no-unused-vars
120
143
  const fetchMoreData = () => {
@@ -185,7 +208,7 @@ const DialogList: React.FC<DialogsProps> = ({
185
208
  let formattedValue = '';
186
209
 
187
210
  if (item.entity.lastMessage.dateSent) {
188
- dateInt = parseInt(item.entity.lastMessage.dateSent, 10);
211
+ dateInt = item.entity.lastMessage.dateSent;
189
212
  if (Number.isNaN(dateInt)) {
190
213
  return formattedValue;
191
214
  }
@@ -219,6 +242,43 @@ const DialogList: React.FC<DialogsProps> = ({
219
242
  return AvatarComponent;
220
243
  };
221
244
 
245
+ /*
246
+ import React, {useState, useEffect} from 'react';
247
+
248
+ // предполагая, что dialogListViewModel определен в родительском компоненте и передан в этот компонент как проп
249
+ const YourComponent = ({ dialogListViewModel }) => {
250
+ const [pointerEventsValue, setPointerEvents] = useState('auto');
251
+
252
+ // поведение на 12 секунд
253
+ useEffect(() => {
254
+ let timeout;
255
+ if (dialogListViewModel && dialogListViewModel.loading) {
256
+ setPointerEvents('none');
257
+ timeout = setTimeout(() => {
258
+ setPointerEvents('auto');
259
+ }, 12000); // блокировать нажатие на 12 секунд
260
+ }
261
+
262
+ // поведение на отмену эффекта
263
+ return () => {
264
+ if (timeout) {
265
+ clearTimeout(timeout);
266
+ }
267
+ }
268
+ }, [dialogListViewModel]);
269
+
270
+ return (
271
+ <div
272
+ style={{
273
+ pointerEventsValue: pointerEventsValue
274
+ }}
275
+ >
276
+ ...
277
+ </div>
278
+ );
279
+ }
280
+ */
281
+
222
282
  return (
223
283
  <div
224
284
  key={index}
@@ -243,7 +303,10 @@ const DialogList: React.FC<DialogsProps> = ({
243
303
  });
244
304
  }}
245
305
  style={{
246
- pointerEvents: !dialogListViewModel?.loading ? 'auto' : 'none',
306
+ // pointerEvents: !dialogListViewModel?.loading ? 'auto' : 'none',
307
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
308
+ // @ts-ignore
309
+ pointerEvents: pointerEventsValue || 'auto',
247
310
  }}
248
311
  >
249
312
  <PreviewDialog
@@ -417,6 +417,9 @@ export default function useDialogListViewModel(
417
417
  console.log('Error leaveDialogUseCase: ', stringifyError(e));
418
418
  throw new Error(stringifyError(e));
419
419
  });
420
+ if (leaveResult) {
421
+ setNewDialog(undefined);
422
+ }
420
423
  } else {
421
424
  const usersForDeleteFromDialog: Array<number> = new Array<number>();
422
425
 
@@ -14,6 +14,7 @@ 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
16
  import { Button, TextField } from '../../ui-components';
17
+ import { formatFileSize } from '../../../utils/formatFileSize';
17
18
  import './EditDialog.scss';
18
19
 
19
20
  export const TypeOpenDialog = {
@@ -47,9 +48,9 @@ const EditDialog: React.FC<EditDialogProps> = ({
47
48
  const maxUploadFileSize = currentContext.InitParams.maxFileSize;
48
49
  const minLengthNameDialog = 3;
49
50
  const maxLengthNameDialog = 60;
50
- const errorMessageUploadMaxSize = `file size must be less than ${
51
- maxUploadFileSize / 1024 / 1024
52
- } Mb`;
51
+ const errorMessageUploadMaxSize = `The file should not exceed this size: ${formatFileSize(
52
+ maxUploadFileSize,
53
+ )}`;
53
54
 
54
55
  const [dialogName, setDialogName] = useState(nameDialog);
55
56
  const [fileUploadAvatar, setFileUploadAvatar] = useState<File | null>(null);
@@ -1,4 +1,4 @@
1
- import React, { useEffect, useState } from 'react';
1
+ import React, { useEffect, useRef, useState } from 'react';
2
2
  import './InviteMembers.scss';
3
3
  import ColumnContainer from '../../components/containers/ColumnContainer/ColumnContainer';
4
4
  import RowRightContainer from '../../components/containers/RowRightContainer/RowRightContainer';
@@ -143,6 +143,7 @@ const InviteMembers: React.FC<InviteMembersProps> = ({
143
143
  };
144
144
 
145
145
  const [userNameForFilter, setUserNameForFilter] = useState<string>('');
146
+ const inputRef = useRef<HTMLInputElement>(null);
146
147
 
147
148
  useEffect(() => {
148
149
  if (userNameForFilter.length > 2) {
@@ -150,6 +151,9 @@ const InviteMembers: React.FC<InviteMembersProps> = ({
150
151
 
151
152
  userViewModel.updateFilter(newFilter);
152
153
  }
154
+
155
+ setTimeout(() => inputRef.current?.focus(), 500);
156
+
153
157
  if (userNameForFilter.length === 0) {
154
158
  userViewModel.updateFilter('');
155
159
  }
@@ -159,6 +163,9 @@ const InviteMembers: React.FC<InviteMembersProps> = ({
159
163
  if (userNameForFilter.length > 2) {
160
164
  userViewModel.getUsers(new Pagination(0, userPerPage));
161
165
  }
166
+
167
+ setTimeout(() => inputRef.current?.focus(), 500);
168
+
162
169
  if (userNameForFilter.length === 0) {
163
170
  userViewModel.getUsers(new Pagination(0, userPerPage));
164
171
  }
@@ -170,6 +177,7 @@ const InviteMembers: React.FC<InviteMembersProps> = ({
170
177
  <div className="container-invite-members--add-members-container">
171
178
  <div className="container-invite-members--add-members-container--wrapper">
172
179
  <TextField
180
+ ref={inputRef}
173
181
  className="filtered-text-field"
174
182
  disabled={userViewModel.loading}
175
183
  placeholder="Search"
@@ -116,7 +116,17 @@ export default function useInviteMembersViewModel(): InviteMembersViewModel {
116
116
 
117
117
  return {
118
118
  get entity(): UserEntity {
119
- return Stubs.createUserEntityWithParams(0, '', '', '', '', '', 0, '', '');
119
+ return Stubs.createUserEntityWithParams(
120
+ 0,
121
+ '',
122
+ '',
123
+ '',
124
+ '',
125
+ '',
126
+ '',
127
+ '',
128
+ '',
129
+ );
120
130
  },
121
131
  // id: Date.now(),
122
132
  // name: '',
@@ -1,5 +1,6 @@
1
1
  /* eslint-disable @typescript-eslint/no-unsafe-call */
2
2
  import React, { useEffect } from 'react';
3
+ import QB from 'quickblox/quickblox';
3
4
  import './PreviewDialog.scss';
4
5
  import { DialogType } from '../../../Domain/entity/DialogTypes';
5
6
  import PreviewDialogViewModel from './PreviewDialogViewModel';