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.
- package/dist/CommonTypes/CommonTypes.d.ts +142 -0
- package/dist/CommonTypes/FunctionResult.d.ts +0 -54
- package/dist/Data/DefaultConfigurations.d.ts +2 -2
- package/dist/Data/Stubs.d.ts +6 -5
- package/dist/Data/dto/dialog/LocalDialogDTO.d.ts +1 -1
- package/dist/Data/dto/dialog/RemoteDialogDTO.d.ts +2 -2
- package/dist/Data/dto/user/LocalUserDTO.d.ts +1 -1
- package/dist/Data/dto/user/RemoteUserDTO.d.ts +1 -1
- package/dist/Data/source/remote/Mapper/MessageDTOMapper.d.ts +1 -0
- package/dist/Data/source/remote/RemoteDataSource.d.ts +1 -1
- package/dist/Domain/entity/LastMessageEntity.d.ts +1 -1
- package/dist/Domain/entity/UserEntity.d.ts +1 -1
- package/dist/Presentation/providers/QuickBloxUIKitProvider/QuickBloxUIKitProvider.d.ts +3 -1
- package/dist/Presentation/ui-components/TextField/TextField.d.ts +2 -2
- package/dist/QBconfig.d.ts +2 -76
- package/dist/index-ui.js +767 -787
- package/dist/index-ui.js.map +1 -1
- package/dist/qb-api-calls/index.d.ts +14 -12
- package/dist/utils/formatFileSize.d.ts +1 -0
- package/dist/utils/parse.d.ts +1 -0
- package/global.d.ts +158 -2835
- package/package.json +3 -1
- package/src/App.tsx +3 -2
- package/src/CommonTypes/CommonTypes.ts +229 -0
- package/src/CommonTypes/FunctionResult.ts +0 -59
- package/src/Data/Creator.ts +1 -0
- package/src/Data/DefaultConfigurations.ts +6 -2
- package/src/Data/Stubs.ts +47 -47
- package/src/Data/dto/dialog/LocalDialogDTO.ts +2 -2
- package/src/Data/dto/dialog/RemoteDialogDTO.ts +4 -4
- package/src/Data/dto/user/LocalUserDTO.ts +2 -2
- package/src/Data/dto/user/RemoteUserDTO.ts +2 -2
- package/src/Data/mapper/DialogLocalDTOMapper.ts +4 -10
- package/src/Data/mapper/DialogRemoteDTOMapper.ts +11 -22
- package/src/Data/mapper/UserLocalDTOMapper.ts +2 -2
- package/src/Data/mapper/UserRemoteDTOMapper.ts +2 -2
- package/src/Data/repository/ConnectionRepository.ts +1 -0
- package/src/Data/repository/UsersRepository.ts +1 -1
- package/src/Data/source/local/ChatLocalStorageDataSource.ts +14 -14
- package/src/Data/source/remote/Mapper/DialogDTOMapper.ts +70 -52
- package/src/Data/source/remote/Mapper/FileDTOMapper.ts +4 -0
- package/src/Data/source/remote/Mapper/MessageDTOMapper.ts +1 -0
- package/src/Data/source/remote/Mapper/UserDTOMapper.ts +1 -0
- package/src/Data/source/remote/RemoteDataSource.ts +76 -12
- package/src/Domain/entity/LastMessageEntity.ts +1 -1
- package/src/Domain/entity/UserEntity.ts +1 -1
- package/src/Presentation/Views/Dialog/MessageItem/MessageItem.tsx +2 -2
- package/src/Presentation/Views/Dialog/useDialogViewModel.ts +44 -150
- package/src/Presentation/Views/DialogInfo/DialogInfo.tsx +2 -1
- package/src/Presentation/Views/DialogList/DialogList.tsx +65 -2
- package/src/Presentation/Views/DialogList/useDialogListViewModel.ts +3 -0
- package/src/Presentation/Views/EditDialog/EditDialog.tsx +4 -3
- package/src/Presentation/Views/InviteMembers/InviteMembers.tsx +9 -1
- package/src/Presentation/Views/InviteMembers/useInviteMembersViewModel.ts +11 -1
- package/src/Presentation/Views/PreviewDialog/PreviewDialog.tsx +1 -0
- package/src/Presentation/layouts/Desktop/QuickBloxUIKitDesktopLayout.tsx +9 -41
- package/src/Presentation/layouts/TestStage/LoginView/Login.tsx +7 -11
- package/src/Presentation/providers/QuickBloxUIKitProvider/QuickBloxUIKitProvider.tsx +30 -2
- package/src/Presentation/ui-components/SettingsItem/SettingsItem.stories.tsx +1 -0
- package/src/Presentation/ui-components/TextField/TextField.tsx +58 -48
- package/src/QBconfig.ts +13 -11
- package/src/qb-api-calls/index.ts +44 -14
- package/src/utils/formatFileSize.ts +8 -0
- package/src/utils/parse.ts +2 -0
- package/storybook-static/703.2cbec951.iframe.bundle.js +33 -0
- package/storybook-static/703.2cbec951.iframe.bundle.js.map +1 -0
- package/storybook-static/{758.53b4954a.iframe.bundle.js → 938.56e9d83c.iframe.bundle.js} +1 -14
- package/storybook-static/Presentation-ui-components-Avatar-avatar-stories.1b74ae55.iframe.bundle.js +14 -0
- package/storybook-static/Presentation-ui-components-Avatar-avatar-stories.1b74ae55.iframe.bundle.js.map +1 -0
- package/storybook-static/Presentation-ui-components-Button-Button-stories.84103f20.iframe.bundle.js +14 -0
- package/storybook-static/Presentation-ui-components-Button-Button-stories.84103f20.iframe.bundle.js.map +1 -0
- package/storybook-static/Presentation-ui-components-DialogItemPreview-DialogItemPreview-stories.bf9005d3.iframe.bundle.js +14 -0
- package/storybook-static/Presentation-ui-components-DialogItemPreview-DialogItemPreview-stories.bf9005d3.iframe.bundle.js.map +1 -0
- package/storybook-static/Presentation-ui-components-DialogWindow-DialogWindow-stories.f81a8e38.iframe.bundle.js +14 -0
- package/storybook-static/Presentation-ui-components-DialogWindow-DialogWindow-stories.f81a8e38.iframe.bundle.js.map +1 -0
- package/storybook-static/Presentation-ui-components-Dropdown-Dropdown-stories.141a3ae7.iframe.bundle.js +14 -0
- package/storybook-static/Presentation-ui-components-Dropdown-Dropdown-stories.141a3ae7.iframe.bundle.js.map +1 -0
- package/storybook-static/Presentation-ui-components-Header-Header-stories.9f45c30e.iframe.bundle.js +14 -0
- package/storybook-static/Presentation-ui-components-Header-Header-stories.9f45c30e.iframe.bundle.js.map +1 -0
- package/storybook-static/Presentation-ui-components-Loader-Loader-stories.af01e15d.iframe.bundle.js +14 -0
- package/storybook-static/Presentation-ui-components-Loader-Loader-stories.af01e15d.iframe.bundle.js.map +1 -0
- package/storybook-static/Presentation-ui-components-Message-Message-stories.264d251d.iframe.bundle.js +14 -0
- package/storybook-static/Presentation-ui-components-Message-Message-stories.264d251d.iframe.bundle.js.map +1 -0
- package/storybook-static/Presentation-ui-components-MessageInput-MessageInput-stories.bf8a24d1.iframe.bundle.js +1 -0
- 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
- package/storybook-static/Presentation-ui-components-Placeholder-Placeholder-stories.97287936.iframe.bundle.js.map +1 -0
- package/storybook-static/Presentation-ui-components-PreviewFileMessage-PreviewFileMessage-stories.a9f5cd67.iframe.bundle.js +14 -0
- package/storybook-static/Presentation-ui-components-PreviewFileMessage-PreviewFileMessage-stories.a9f5cd67.iframe.bundle.js.map +1 -0
- package/storybook-static/Presentation-ui-components-SettingsItem-SettingsItem-stories.429a72d5.iframe.bundle.js +14 -0
- package/storybook-static/Presentation-ui-components-SettingsItem-SettingsItem-stories.429a72d5.iframe.bundle.js.map +1 -0
- package/storybook-static/Presentation-ui-components-TextField-TextField-stories.fd8caf6c.iframe.bundle.js +14 -0
- package/storybook-static/Presentation-ui-components-TextField-TextField-stories.fd8caf6c.iframe.bundle.js.map +1 -0
- 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
- package/storybook-static/Presentation-ui-components-Toast-Toast-stories.b903385b.iframe.bundle.js.map +1 -0
- 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
- package/storybook-static/Presentation-ui-components-UserListItem-UserListItem-stories.8781472b.iframe.bundle.js.map +1 -0
- package/storybook-static/iframe.html +2 -2
- package/storybook-static/{main.597d432b.iframe.bundle.js → main.2f6d7582.iframe.bundle.js} +1 -1
- package/storybook-static/project.json +1 -1
- package/storybook-static/runtime~main.af13ca55.iframe.bundle.js +1 -0
- package/webpack.config.js +2 -1
- package/storybook-static/758.53b4954a.iframe.bundle.js.map +0 -1
- package/storybook-static/Presentation-ui-components-Avatar-avatar-stories.cf806856.iframe.bundle.js +0 -1
- package/storybook-static/Presentation-ui-components-Button-Button-stories.4fac7996.iframe.bundle.js +0 -1
- package/storybook-static/Presentation-ui-components-DialogItemPreview-DialogItemPreview-stories.6665bbfb.iframe.bundle.js +0 -1
- package/storybook-static/Presentation-ui-components-DialogWindow-DialogWindow-stories.cf340397.iframe.bundle.js +0 -1
- package/storybook-static/Presentation-ui-components-Dropdown-Dropdown-stories.b32a1e17.iframe.bundle.js +0 -1
- package/storybook-static/Presentation-ui-components-Header-Header-stories.073c4507.iframe.bundle.js +0 -1
- package/storybook-static/Presentation-ui-components-Loader-Loader-stories.9bf3fb63.iframe.bundle.js +0 -1
- package/storybook-static/Presentation-ui-components-Message-Message-stories.343dfae0.iframe.bundle.js +0 -1
- package/storybook-static/Presentation-ui-components-MessageInput-MessageInput-stories.c2ead6a5.iframe.bundle.js +0 -1
- package/storybook-static/Presentation-ui-components-PreviewFileMessage-PreviewFileMessage-stories.527e000e.iframe.bundle.js +0 -1
- package/storybook-static/Presentation-ui-components-SettingsItem-SettingsItem-stories.2ff75703.iframe.bundle.js +0 -1
- package/storybook-static/Presentation-ui-components-TextField-TextField-stories.4a2eef3e.iframe.bundle.js +0 -1
- package/storybook-static/runtime~main.7ee2126e.iframe.bundle.js +0 -1
|
@@ -17,9 +17,9 @@ export class RemoteDialogDTO {
|
|
|
17
17
|
|
|
18
18
|
public lastMessageText: string;
|
|
19
19
|
|
|
20
|
-
public lastMessageUserId:
|
|
20
|
+
public lastMessageUserId: number;
|
|
21
21
|
|
|
22
|
-
public lastMessageDateSent:
|
|
22
|
+
public lastMessageDateSent: number;
|
|
23
23
|
|
|
24
24
|
public lastMessageId: string;
|
|
25
25
|
|
|
@@ -43,9 +43,9 @@ export class RemoteDialogDTO {
|
|
|
43
43
|
|
|
44
44
|
this.lastMessageText = '';
|
|
45
45
|
|
|
46
|
-
this.lastMessageUserId =
|
|
46
|
+
this.lastMessageUserId = 0;
|
|
47
47
|
|
|
48
|
-
this.lastMessageDateSent =
|
|
48
|
+
this.lastMessageDateSent = 0;
|
|
49
49
|
|
|
50
50
|
this.lastMessageId = '';
|
|
51
51
|
|
|
@@ -13,7 +13,7 @@ export class LocalUserDTO {
|
|
|
13
13
|
|
|
14
14
|
public updated_at: string;
|
|
15
15
|
|
|
16
|
-
public last_request_at:
|
|
16
|
+
public last_request_at: string;
|
|
17
17
|
|
|
18
18
|
public custom_data: string | null;
|
|
19
19
|
|
|
@@ -29,7 +29,7 @@ export class LocalUserDTO {
|
|
|
29
29
|
this.login = '';
|
|
30
30
|
this.created_at = '';
|
|
31
31
|
this.updated_at = '';
|
|
32
|
-
this.last_request_at =
|
|
32
|
+
this.last_request_at = '';
|
|
33
33
|
this.custom_data = '';
|
|
34
34
|
this.user_tags = '';
|
|
35
35
|
this.blob_id = '';
|
|
@@ -13,7 +13,7 @@ export class RemoteUserDTO {
|
|
|
13
13
|
|
|
14
14
|
public updated_at: string;
|
|
15
15
|
|
|
16
|
-
public last_request_at:
|
|
16
|
+
public last_request_at: string;
|
|
17
17
|
|
|
18
18
|
public custom_data: string | null;
|
|
19
19
|
|
|
@@ -29,7 +29,7 @@ export class RemoteUserDTO {
|
|
|
29
29
|
this.login = '';
|
|
30
30
|
this.created_at = '';
|
|
31
31
|
this.updated_at = '';
|
|
32
|
-
this.last_request_at =
|
|
32
|
+
this.last_request_at = '';
|
|
33
33
|
this.custom_data = '';
|
|
34
34
|
this.user_tags = '';
|
|
35
35
|
this.blob_id = 0;
|
|
@@ -71,9 +71,7 @@ export class DialogLocalDTOMapper implements IMapper {
|
|
|
71
71
|
dialog.id,
|
|
72
72
|
dialog.name,
|
|
73
73
|
{
|
|
74
|
-
dateSent: dialog.lastMessageDateSent
|
|
75
|
-
? dialog.lastMessageDateSent
|
|
76
|
-
: '',
|
|
74
|
+
dateSent: dialog.lastMessageDateSent,
|
|
77
75
|
text: dialog.lastMessageText ? dialog.lastMessageText : '',
|
|
78
76
|
userId: parseInt(dialog.lastMessageUserId, 10),
|
|
79
77
|
},
|
|
@@ -89,9 +87,7 @@ export class DialogLocalDTOMapper implements IMapper {
|
|
|
89
87
|
{ todo: '' },
|
|
90
88
|
dialog.id,
|
|
91
89
|
{
|
|
92
|
-
dateSent: dialog.lastMessageDateSent
|
|
93
|
-
? dialog.lastMessageDateSent
|
|
94
|
-
: '',
|
|
90
|
+
dateSent: dialog.lastMessageDateSent,
|
|
95
91
|
text: dialog.lastMessageText ? dialog.lastMessageText : '',
|
|
96
92
|
userId: parseInt(dialog.lastMessageUserId, 10),
|
|
97
93
|
},
|
|
@@ -108,9 +104,7 @@ export class DialogLocalDTOMapper implements IMapper {
|
|
|
108
104
|
{ todo: '' },
|
|
109
105
|
dialog.id,
|
|
110
106
|
{
|
|
111
|
-
dateSent: dialog.lastMessageDateSent
|
|
112
|
-
? dialog.lastMessageDateSent
|
|
113
|
-
: '',
|
|
107
|
+
dateSent: dialog.lastMessageDateSent,
|
|
114
108
|
text: dialog.lastMessageText ? dialog.lastMessageText : '',
|
|
115
109
|
userId: parseInt(dialog.lastMessageUserId, 10),
|
|
116
110
|
},
|
|
@@ -730,7 +724,7 @@ export class DialogLocalDTOMapper implements IMapper {
|
|
|
730
724
|
public static createDefaultDialogEntity(owner_id: string): DialogEntity {
|
|
731
725
|
return {
|
|
732
726
|
customData: { todo: '' },
|
|
733
|
-
lastMessage: { dateSent:
|
|
727
|
+
lastMessage: { dateSent: 0, text: '', userId: 0 },
|
|
734
728
|
ownerId: owner_id,
|
|
735
729
|
type: DialogType.public,
|
|
736
730
|
unreadMessageCount: 0,
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import QB from 'quickblox/quickblox';
|
|
1
2
|
import { IMapper } from './IMapper';
|
|
2
3
|
import { DialogEntity } from '../../Domain/entity/DialogEntity';
|
|
3
4
|
import { DialogType } from '../../Domain/entity/DialogTypes';
|
|
@@ -49,7 +50,7 @@ export class DialogRemoteDTOMapper implements IMapper {
|
|
|
49
50
|
|
|
50
51
|
dialog.lastMessageText = dialogEntity.lastMessage.text;
|
|
51
52
|
|
|
52
|
-
dialog.lastMessageUserId = dialogEntity.lastMessage.userId
|
|
53
|
+
dialog.lastMessageUserId = dialogEntity.lastMessage.userId;
|
|
53
54
|
|
|
54
55
|
dialog.lastMessageDateSent = dialogEntity.lastMessage.dateSent;
|
|
55
56
|
|
|
@@ -86,11 +87,9 @@ export class DialogRemoteDTOMapper implements IMapper {
|
|
|
86
87
|
dialog.id,
|
|
87
88
|
dialog.name,
|
|
88
89
|
{
|
|
89
|
-
dateSent: dialog.lastMessageDateSent
|
|
90
|
-
? dialog.lastMessageDateSent
|
|
91
|
-
: '',
|
|
90
|
+
dateSent: dialog.lastMessageDateSent,
|
|
92
91
|
text: dialog.lastMessageText ? dialog.lastMessageText : '',
|
|
93
|
-
userId:
|
|
92
|
+
userId: dialog.lastMessageUserId,
|
|
94
93
|
},
|
|
95
94
|
dialog.ownerId,
|
|
96
95
|
dialog.type,
|
|
@@ -104,11 +103,9 @@ export class DialogRemoteDTOMapper implements IMapper {
|
|
|
104
103
|
{ todo: '' },
|
|
105
104
|
dialog.id,
|
|
106
105
|
{
|
|
107
|
-
dateSent: dialog.lastMessageDateSent
|
|
108
|
-
? dialog.lastMessageDateSent
|
|
109
|
-
: '',
|
|
106
|
+
dateSent: dialog.lastMessageDateSent,
|
|
110
107
|
text: dialog.lastMessageText ? dialog.lastMessageText : '',
|
|
111
|
-
userId:
|
|
108
|
+
userId: dialog.lastMessageUserId,
|
|
112
109
|
},
|
|
113
110
|
dialog.ownerId,
|
|
114
111
|
dialog.type,
|
|
@@ -123,11 +120,9 @@ export class DialogRemoteDTOMapper implements IMapper {
|
|
|
123
120
|
{ todo: '' },
|
|
124
121
|
dialog.id,
|
|
125
122
|
{
|
|
126
|
-
dateSent: dialog.lastMessageDateSent
|
|
127
|
-
? dialog.lastMessageDateSent
|
|
128
|
-
: '',
|
|
123
|
+
dateSent: dialog.lastMessageDateSent,
|
|
129
124
|
text: dialog.lastMessageText ? dialog.lastMessageText : '',
|
|
130
|
-
userId:
|
|
125
|
+
userId: dialog.lastMessageUserId,
|
|
131
126
|
},
|
|
132
127
|
dialog.ownerId,
|
|
133
128
|
dialog.type,
|
|
@@ -186,7 +181,7 @@ export class DialogRemoteDTOMapper implements IMapper {
|
|
|
186
181
|
public static createDefaultDialogEntity(owner_id: string): DialogEntity {
|
|
187
182
|
return {
|
|
188
183
|
customData: { todo: '' },
|
|
189
|
-
lastMessage: { dateSent:
|
|
184
|
+
lastMessage: { dateSent: 0, text: '', userId: 0 },
|
|
190
185
|
ownerId: owner_id,
|
|
191
186
|
type: DialogType.public,
|
|
192
187
|
unreadMessageCount: 0,
|
|
@@ -560,16 +555,10 @@ export class DialogRemoteDTOMapper implements IMapper {
|
|
|
560
555
|
|
|
561
556
|
switch (dialogType) {
|
|
562
557
|
case DialogType.private:
|
|
563
|
-
dialogEntity =
|
|
564
|
-
entity instanceof PrivateDialogEntity
|
|
565
|
-
? (entity as unknown as PrivateDialogEntity)
|
|
566
|
-
: null;
|
|
558
|
+
dialogEntity = entity as PrivateDialogEntity;
|
|
567
559
|
break;
|
|
568
560
|
case DialogType.public:
|
|
569
|
-
dialogEntity =
|
|
570
|
-
entity instanceof PublicDialogEntity
|
|
571
|
-
? (entity as unknown as PublicDialogEntity)
|
|
572
|
-
: null;
|
|
561
|
+
dialogEntity = entity as PublicDialogEntity;
|
|
573
562
|
break;
|
|
574
563
|
case DialogType.group:
|
|
575
564
|
dialogEntity = entity as GroupDialogEntity;
|
|
@@ -134,7 +134,7 @@ export class UserLocalDTOMapper implements IMapper {
|
|
|
134
134
|
return (
|
|
135
135
|
last_request_at !== undefined &&
|
|
136
136
|
last_request_at !== null &&
|
|
137
|
-
last_request_at > 0
|
|
137
|
+
last_request_at.length > 0
|
|
138
138
|
);
|
|
139
139
|
},
|
|
140
140
|
login(v: unknown): v is UserEntity['login'] {
|
|
@@ -376,7 +376,7 @@ export class UserLocalDTOMapper implements IMapper {
|
|
|
376
376
|
email: '',
|
|
377
377
|
full_name: '',
|
|
378
378
|
id: 0,
|
|
379
|
-
last_request_at:
|
|
379
|
+
last_request_at: '',
|
|
380
380
|
login: '',
|
|
381
381
|
updated_at: '',
|
|
382
382
|
user_tags: '',
|
|
@@ -146,7 +146,7 @@ export class UserRemoteDTOMapper implements IMapper {
|
|
|
146
146
|
return (
|
|
147
147
|
last_request_at !== undefined &&
|
|
148
148
|
last_request_at !== null &&
|
|
149
|
-
last_request_at > 0
|
|
149
|
+
last_request_at.length > 0
|
|
150
150
|
);
|
|
151
151
|
},
|
|
152
152
|
login(v: unknown): v is UserEntity['login'] {
|
|
@@ -387,7 +387,7 @@ export class UserRemoteDTOMapper implements IMapper {
|
|
|
387
387
|
email: '',
|
|
388
388
|
full_name: '',
|
|
389
389
|
id: 0,
|
|
390
|
-
last_request_at:
|
|
390
|
+
last_request_at: '',
|
|
391
391
|
login: '',
|
|
392
392
|
updated_at: '',
|
|
393
393
|
user_tags: '',
|
|
@@ -203,7 +203,7 @@ export default class UsersRepository {
|
|
|
203
203
|
for (let i = 0; i < usersIds.length; i += 1) {
|
|
204
204
|
let dto: RemoteUserDTO = new RemoteUserDTO();
|
|
205
205
|
|
|
206
|
-
dto.id = usersIds[i]
|
|
206
|
+
dto.id = usersIds[i]?.toString() || '-1';
|
|
207
207
|
// eslint-disable-next-line no-await-in-loop
|
|
208
208
|
dto = await this.remoteDataSource.getUser(dto);
|
|
209
209
|
arrayUserDTO.push(dto);
|
|
@@ -6,7 +6,7 @@ const listChats: PublicDialogEntity[] = [
|
|
|
6
6
|
id: '1',
|
|
7
7
|
name: 'Chat 1',
|
|
8
8
|
customData: { todo: '' },
|
|
9
|
-
lastMessage: { dateSent:
|
|
9
|
+
lastMessage: { dateSent: 0, text: '', userId: 0 },
|
|
10
10
|
ownerId: '',
|
|
11
11
|
photo: '',
|
|
12
12
|
type: 0,
|
|
@@ -17,7 +17,7 @@ const listChats: PublicDialogEntity[] = [
|
|
|
17
17
|
id: '2',
|
|
18
18
|
name: 'Chat 2',
|
|
19
19
|
customData: { todo: '' },
|
|
20
|
-
lastMessage: { dateSent:
|
|
20
|
+
lastMessage: { dateSent: 0, text: '', userId: 0 },
|
|
21
21
|
ownerId: '',
|
|
22
22
|
photo: '',
|
|
23
23
|
type: 0,
|
|
@@ -28,7 +28,7 @@ const listChats: PublicDialogEntity[] = [
|
|
|
28
28
|
id: '3',
|
|
29
29
|
name: 'Chat 3',
|
|
30
30
|
customData: { todo: '' },
|
|
31
|
-
lastMessage: { dateSent:
|
|
31
|
+
lastMessage: { dateSent: 0, text: '', userId: 0 },
|
|
32
32
|
ownerId: '',
|
|
33
33
|
photo: '',
|
|
34
34
|
type: 0,
|
|
@@ -39,7 +39,7 @@ const listChats: PublicDialogEntity[] = [
|
|
|
39
39
|
id: '4',
|
|
40
40
|
name: 'Chat 4',
|
|
41
41
|
customData: { todo: '' },
|
|
42
|
-
lastMessage: { dateSent:
|
|
42
|
+
lastMessage: { dateSent: 0, text: '', userId: 0 },
|
|
43
43
|
ownerId: '',
|
|
44
44
|
photo: '',
|
|
45
45
|
type: 0,
|
|
@@ -50,7 +50,7 @@ const listChats: PublicDialogEntity[] = [
|
|
|
50
50
|
id: '5',
|
|
51
51
|
name: 'Chat 5',
|
|
52
52
|
customData: { todo: '' },
|
|
53
|
-
lastMessage: { dateSent:
|
|
53
|
+
lastMessage: { dateSent: 0, text: '', userId: 0 },
|
|
54
54
|
ownerId: '',
|
|
55
55
|
photo: '',
|
|
56
56
|
type: 0,
|
|
@@ -64,7 +64,7 @@ const listCasheChats: PublicDialogEntity[] = [
|
|
|
64
64
|
id: '1',
|
|
65
65
|
name: 'Cash Chat 1',
|
|
66
66
|
customData: { todo: '' },
|
|
67
|
-
lastMessage: { dateSent:
|
|
67
|
+
lastMessage: { dateSent: 0, text: '', userId: 0 },
|
|
68
68
|
ownerId: '',
|
|
69
69
|
photo: '',
|
|
70
70
|
type: 0,
|
|
@@ -75,7 +75,7 @@ const listCasheChats: PublicDialogEntity[] = [
|
|
|
75
75
|
id: '2',
|
|
76
76
|
name: 'Cash Chat 2',
|
|
77
77
|
customData: { todo: '' },
|
|
78
|
-
lastMessage: { dateSent:
|
|
78
|
+
lastMessage: { dateSent: 0, text: '', userId: 0 },
|
|
79
79
|
ownerId: '',
|
|
80
80
|
photo: '',
|
|
81
81
|
type: 0,
|
|
@@ -86,7 +86,7 @@ const listCasheChats: PublicDialogEntity[] = [
|
|
|
86
86
|
id: '3',
|
|
87
87
|
name: 'Chat 3 from Cash',
|
|
88
88
|
customData: { todo: '' },
|
|
89
|
-
lastMessage: { dateSent:
|
|
89
|
+
lastMessage: { dateSent: 0, text: '', userId: 0 },
|
|
90
90
|
ownerId: '',
|
|
91
91
|
photo: '',
|
|
92
92
|
type: 0,
|
|
@@ -97,7 +97,7 @@ const listCasheChats: PublicDialogEntity[] = [
|
|
|
97
97
|
id: '4',
|
|
98
98
|
name: 'Chat 4 from Cash',
|
|
99
99
|
customData: { todo: '' },
|
|
100
|
-
lastMessage: { dateSent:
|
|
100
|
+
lastMessage: { dateSent: 0, text: '', userId: 0 },
|
|
101
101
|
ownerId: '',
|
|
102
102
|
photo: '',
|
|
103
103
|
type: 0,
|
|
@@ -108,7 +108,7 @@ const listCasheChats: PublicDialogEntity[] = [
|
|
|
108
108
|
id: '5',
|
|
109
109
|
name: 'Chat 5 from Cash',
|
|
110
110
|
customData: { todo: '' },
|
|
111
|
-
lastMessage: { dateSent:
|
|
111
|
+
lastMessage: { dateSent: 0, text: '', userId: 0 },
|
|
112
112
|
ownerId: '',
|
|
113
113
|
photo: '',
|
|
114
114
|
type: 0,
|
|
@@ -119,7 +119,7 @@ const listCasheChats: PublicDialogEntity[] = [
|
|
|
119
119
|
id: '6',
|
|
120
120
|
name: 'Chat 6 from Cash',
|
|
121
121
|
customData: { todo: '' },
|
|
122
|
-
lastMessage: { dateSent:
|
|
122
|
+
lastMessage: { dateSent: 0, text: '', userId: 0 },
|
|
123
123
|
ownerId: '',
|
|
124
124
|
photo: '',
|
|
125
125
|
type: 0,
|
|
@@ -133,7 +133,7 @@ const preloadedChats: PublicDialogEntity[] = [
|
|
|
133
133
|
id: '1',
|
|
134
134
|
name: 'Preload Chat 1',
|
|
135
135
|
customData: { todo: '' },
|
|
136
|
-
lastMessage: { dateSent:
|
|
136
|
+
lastMessage: { dateSent: 0, text: '', userId: 0 },
|
|
137
137
|
ownerId: '',
|
|
138
138
|
photo: '',
|
|
139
139
|
type: 0,
|
|
@@ -144,7 +144,7 @@ const preloadedChats: PublicDialogEntity[] = [
|
|
|
144
144
|
id: '2',
|
|
145
145
|
name: 'Preload Chat 2',
|
|
146
146
|
customData: { todo: '' },
|
|
147
|
-
lastMessage: { dateSent:
|
|
147
|
+
lastMessage: { dateSent: 0, text: '', userId: 0 },
|
|
148
148
|
ownerId: '',
|
|
149
149
|
photo: '',
|
|
150
150
|
type: 0,
|
|
@@ -155,7 +155,7 @@ const preloadedChats: PublicDialogEntity[] = [
|
|
|
155
155
|
id: '3',
|
|
156
156
|
name: 'Preload Chat 3',
|
|
157
157
|
customData: { todo: '' },
|
|
158
|
-
lastMessage: { dateSent:
|
|
158
|
+
lastMessage: { dateSent: 0, text: '', userId: 0 },
|
|
159
159
|
ownerId: '',
|
|
160
160
|
photo: '',
|
|
161
161
|
type: 0,
|
|
@@ -8,6 +8,10 @@ import {
|
|
|
8
8
|
UNEXPECTED_MAPPER_DTO_EXCEPTION_EXCEPTION_CODE,
|
|
9
9
|
UNEXPECTED_MAPPER_DTO_EXCEPTION_MESSAGE,
|
|
10
10
|
} from '../../exception/MapperDTOException';
|
|
11
|
+
import {
|
|
12
|
+
QBChatDialogType,
|
|
13
|
+
QBUIKitChatDialog,
|
|
14
|
+
} from '../../../../CommonTypes/CommonTypes';
|
|
11
15
|
|
|
12
16
|
type DtoValidator<T> = {
|
|
13
17
|
[key in keyof T]: (v: unknown) => v is T[key];
|
|
@@ -26,7 +30,7 @@ export class DialogDTOMapper implements IDTOMapper {
|
|
|
26
30
|
|
|
27
31
|
DialogDTOMapper.validateDTO(dialogDTO);
|
|
28
32
|
|
|
29
|
-
const dialog:
|
|
33
|
+
const dialog: QBUIKitChatDialog = {
|
|
30
34
|
_id: dialogDTO.id,
|
|
31
35
|
created_at: '',
|
|
32
36
|
last_message: DialogDTOMapper.formatLastMessageText(
|
|
@@ -34,7 +38,7 @@ export class DialogDTOMapper implements IDTOMapper {
|
|
|
34
38
|
),
|
|
35
39
|
last_message_date_sent: dialogDTO.lastMessageDateSent,
|
|
36
40
|
last_message_id: null,
|
|
37
|
-
last_message_user_id:
|
|
41
|
+
last_message_user_id: dialogDTO.lastMessageUserId,
|
|
38
42
|
name: dialogDTO.name,
|
|
39
43
|
occupants_ids: dialogDTO.participantsIds,
|
|
40
44
|
new_occupants_ids: dialogDTO.newParticipantsIds
|
|
@@ -53,7 +57,8 @@ export class DialogDTOMapper implements IDTOMapper {
|
|
|
53
57
|
|
|
54
58
|
// eslint-disable-next-line class-methods-use-this
|
|
55
59
|
toTDO<TArg, TResult>(qbEntity: TArg): Promise<TResult> {
|
|
56
|
-
const qbDialog:
|
|
60
|
+
const qbDialog: QBUIKitChatDialog =
|
|
61
|
+
qbEntity as unknown as QBUIKitChatDialog;
|
|
57
62
|
|
|
58
63
|
DialogDTOMapper.validateQBChatDialog(qbDialog);
|
|
59
64
|
|
|
@@ -62,11 +67,13 @@ export class DialogDTOMapper implements IDTOMapper {
|
|
|
62
67
|
dto.id = qbDialog._id;
|
|
63
68
|
dto.lastMessageId = qbDialog.last_message_id || '';
|
|
64
69
|
dto.lastMessageText = qbDialog.last_message as string;
|
|
65
|
-
dto.lastMessageDateSent = qbDialog.last_message_date_sent
|
|
70
|
+
dto.lastMessageDateSent = qbDialog.last_message_date_sent || 0;
|
|
66
71
|
dto.lastMessageUserId =
|
|
67
72
|
qbDialog.last_message_user_id === null
|
|
68
|
-
?
|
|
69
|
-
:
|
|
73
|
+
? 0
|
|
74
|
+
: // eslint-disable-next-line @typescript-eslint/no-unsafe-call
|
|
75
|
+
qbDialog.last_message_user_id;
|
|
76
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-call
|
|
70
77
|
dto.ownerId = qbDialog.user_id.toString();
|
|
71
78
|
dto.type = qbDialog.type as number;
|
|
72
79
|
dto.unreadMessageCount =
|
|
@@ -74,6 +81,7 @@ export class DialogDTOMapper implements IDTOMapper {
|
|
|
74
81
|
? 0
|
|
75
82
|
: qbDialog.unread_messages_count;
|
|
76
83
|
dto.updatedAt = qbDialog.updated_at;
|
|
84
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-call
|
|
77
85
|
dto.participantId = qbDialog.user_id.toString();
|
|
78
86
|
dto.name = qbDialog.name;
|
|
79
87
|
dto.photo = qbDialog.photo === null ? '' : qbDialog.photo;
|
|
@@ -89,14 +97,17 @@ export class DialogDTOMapper implements IDTOMapper {
|
|
|
89
97
|
|
|
90
98
|
dto.participantId = interlocutorId
|
|
91
99
|
? interlocutorId.toString()
|
|
92
|
-
:
|
|
100
|
+
: // eslint-disable-next-line @typescript-eslint/no-unsafe-call
|
|
101
|
+
qbDialog.user_id.toString();
|
|
93
102
|
dto.id = qbDialog._id;
|
|
94
103
|
dto.lastMessageText = qbDialog.last_message as string;
|
|
95
|
-
dto.lastMessageDateSent = qbDialog.last_message_date_sent
|
|
104
|
+
dto.lastMessageDateSent = qbDialog.last_message_date_sent || 0;
|
|
96
105
|
dto.lastMessageUserId =
|
|
97
106
|
qbDialog.last_message_user_id === null
|
|
98
|
-
?
|
|
99
|
-
:
|
|
107
|
+
? 0
|
|
108
|
+
: // eslint-disable-next-line @typescript-eslint/no-unsafe-call
|
|
109
|
+
qbDialog.last_message_user_id;
|
|
110
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-call
|
|
100
111
|
dto.ownerId = qbDialog.user_id.toString();
|
|
101
112
|
dto.type = qbDialog.type;
|
|
102
113
|
dto.unreadMessageCount =
|
|
@@ -108,11 +119,13 @@ export class DialogDTOMapper implements IDTOMapper {
|
|
|
108
119
|
case DialogType.public:
|
|
109
120
|
dto.id = qbDialog._id;
|
|
110
121
|
dto.lastMessageText = qbDialog.last_message as string;
|
|
111
|
-
dto.lastMessageDateSent = qbDialog.last_message_date_sent
|
|
122
|
+
dto.lastMessageDateSent = qbDialog.last_message_date_sent || 0;
|
|
112
123
|
dto.lastMessageUserId =
|
|
113
124
|
qbDialog.last_message_user_id === null
|
|
114
|
-
?
|
|
115
|
-
:
|
|
125
|
+
? 0
|
|
126
|
+
: // eslint-disable-next-line @typescript-eslint/no-unsafe-call
|
|
127
|
+
qbDialog.last_message_user_id;
|
|
128
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-call
|
|
116
129
|
dto.ownerId = qbDialog.user_id.toString();
|
|
117
130
|
dto.type = qbDialog.type;
|
|
118
131
|
dto.unreadMessageCount =
|
|
@@ -120,6 +133,7 @@ export class DialogDTOMapper implements IDTOMapper {
|
|
|
120
133
|
? 0
|
|
121
134
|
: qbDialog.unread_messages_count;
|
|
122
135
|
dto.updatedAt = qbDialog.updated_at;
|
|
136
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-call
|
|
123
137
|
dto.participantId = qbDialog.user_id.toString();
|
|
124
138
|
dto.name = qbDialog.name;
|
|
125
139
|
dto.photo = qbDialog.photo === null ? '' : qbDialog.photo;
|
|
@@ -127,11 +141,13 @@ export class DialogDTOMapper implements IDTOMapper {
|
|
|
127
141
|
case DialogType.group:
|
|
128
142
|
dto.id = qbDialog._id;
|
|
129
143
|
dto.lastMessageText = qbDialog.last_message as string;
|
|
130
|
-
dto.lastMessageDateSent = qbDialog.last_message_date_sent
|
|
144
|
+
dto.lastMessageDateSent = qbDialog.last_message_date_sent || 0;
|
|
131
145
|
dto.lastMessageUserId =
|
|
132
146
|
qbDialog.last_message_user_id === null
|
|
133
|
-
?
|
|
134
|
-
:
|
|
147
|
+
? 0
|
|
148
|
+
: // eslint-disable-next-line @typescript-eslint/no-unsafe-call
|
|
149
|
+
qbDialog.last_message_user_id;
|
|
150
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-call
|
|
135
151
|
dto.ownerId = qbDialog.user_id.toString();
|
|
136
152
|
dto.type = qbDialog.type;
|
|
137
153
|
dto.unreadMessageCount =
|
|
@@ -282,105 +298,107 @@ export class DialogDTOMapper implements IDTOMapper {
|
|
|
282
298
|
}
|
|
283
299
|
|
|
284
300
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
285
|
-
private static validateQBChatDialog(qbDialog:
|
|
286
|
-
const qbDialogValidator: DtoValidator<
|
|
287
|
-
_id(v: unknown): v is
|
|
288
|
-
const { _id } = v as
|
|
301
|
+
private static validateQBChatDialog(qbDialog: QBUIKitChatDialog) {
|
|
302
|
+
const qbDialogValidator: DtoValidator<QBUIKitChatDialog> = {
|
|
303
|
+
_id(v: unknown): v is QBUIKitChatDialog['_id'] {
|
|
304
|
+
const { _id } = v as QBUIKitChatDialog;
|
|
289
305
|
|
|
290
306
|
return _id !== undefined && _id !== null;
|
|
291
307
|
},
|
|
292
|
-
created_at(v: unknown): v is
|
|
293
|
-
const { created_at } = v as
|
|
308
|
+
created_at(v: unknown): v is QBUIKitChatDialog['created_at'] {
|
|
309
|
+
const { created_at } = v as QBUIKitChatDialog;
|
|
294
310
|
|
|
295
311
|
return created_at !== undefined && created_at !== null;
|
|
296
312
|
},
|
|
297
|
-
data(v: unknown): v is
|
|
298
|
-
const { data } = v as
|
|
313
|
+
data(v: unknown): v is QBUIKitChatDialog['data'] {
|
|
314
|
+
const { data } = v as QBUIKitChatDialog;
|
|
299
315
|
|
|
300
316
|
return data !== undefined && data !== null;
|
|
301
317
|
},
|
|
302
|
-
joined(v: unknown): v is
|
|
303
|
-
const { joined } = v as
|
|
318
|
+
joined(v: unknown): v is QBUIKitChatDialog['joined'] {
|
|
319
|
+
const { joined } = v as QBUIKitChatDialog;
|
|
304
320
|
|
|
305
321
|
return joined !== undefined && joined !== null;
|
|
306
322
|
},
|
|
307
|
-
last_message(v: unknown): v is
|
|
323
|
+
last_message(v: unknown): v is QBUIKitChatDialog['last_message'] {
|
|
308
324
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
309
|
-
const { last_message } = v as
|
|
325
|
+
const { last_message } = v as QBUIKitChatDialog;
|
|
310
326
|
|
|
311
327
|
// return last_message !== undefined && last_message !== null;
|
|
312
328
|
return true;
|
|
313
329
|
},
|
|
314
330
|
last_message_date_sent(
|
|
315
331
|
v: unknown,
|
|
316
|
-
): v is
|
|
317
|
-
const { last_message_date_sent } = v as
|
|
332
|
+
): v is QBUIKitChatDialog['last_message_date_sent'] {
|
|
333
|
+
const { last_message_date_sent } = v as QBUIKitChatDialog;
|
|
318
334
|
|
|
319
335
|
return (
|
|
320
336
|
last_message_date_sent !== undefined &&
|
|
321
337
|
last_message_date_sent !== null
|
|
322
338
|
);
|
|
323
339
|
},
|
|
324
|
-
last_message_id(v: unknown): v is
|
|
325
|
-
const { last_message_id } = v as
|
|
340
|
+
last_message_id(v: unknown): v is QBUIKitChatDialog['last_message_id'] {
|
|
341
|
+
const { last_message_id } = v as QBUIKitChatDialog;
|
|
326
342
|
|
|
327
343
|
return last_message_id !== undefined && last_message_id !== null;
|
|
328
344
|
},
|
|
329
345
|
last_message_user_id(
|
|
330
346
|
v: unknown,
|
|
331
|
-
): v is
|
|
332
|
-
const { last_message_user_id } = v as
|
|
347
|
+
): v is QBUIKitChatDialog['last_message_user_id'] {
|
|
348
|
+
const { last_message_user_id } = v as QBUIKitChatDialog;
|
|
333
349
|
|
|
334
350
|
return (
|
|
335
351
|
last_message_user_id !== undefined && last_message_user_id !== null
|
|
336
352
|
);
|
|
337
353
|
},
|
|
338
|
-
name(v: unknown): v is
|
|
339
|
-
const { name } = v as
|
|
354
|
+
name(v: unknown): v is QBUIKitChatDialog['name'] {
|
|
355
|
+
const { name } = v as QBUIKitChatDialog;
|
|
340
356
|
|
|
341
357
|
return name !== undefined && name !== null;
|
|
342
358
|
},
|
|
343
|
-
occupants_ids(v: unknown): v is
|
|
344
|
-
const { occupants_ids } = v as
|
|
359
|
+
occupants_ids(v: unknown): v is QBUIKitChatDialog['occupants_ids'] {
|
|
360
|
+
const { occupants_ids } = v as QBUIKitChatDialog;
|
|
345
361
|
|
|
346
362
|
return occupants_ids !== undefined && occupants_ids !== null;
|
|
347
363
|
},
|
|
348
|
-
new_occupants_ids(
|
|
349
|
-
|
|
364
|
+
new_occupants_ids(
|
|
365
|
+
v: unknown,
|
|
366
|
+
): v is QBUIKitChatDialog['new_occupants_ids'] {
|
|
367
|
+
const { new_occupants_ids } = v as QBUIKitChatDialog;
|
|
350
368
|
|
|
351
369
|
return new_occupants_ids !== undefined && new_occupants_ids !== null;
|
|
352
370
|
},
|
|
353
|
-
photo(v: unknown): v is
|
|
354
|
-
const { photo } = v as
|
|
371
|
+
photo(v: unknown): v is QBUIKitChatDialog['photo'] {
|
|
372
|
+
const { photo } = v as QBUIKitChatDialog;
|
|
355
373
|
|
|
356
374
|
return photo !== undefined && photo !== null;
|
|
357
375
|
},
|
|
358
|
-
type(v: unknown): v is
|
|
359
|
-
const { type } = v as
|
|
376
|
+
type(v: unknown): v is QBUIKitChatDialog['type'] {
|
|
377
|
+
const { type } = v as QBUIKitChatDialog;
|
|
360
378
|
|
|
361
379
|
return type !== undefined && type !== null;
|
|
362
380
|
},
|
|
363
381
|
unread_messages_count(
|
|
364
382
|
v: unknown,
|
|
365
|
-
): v is
|
|
366
|
-
const { unread_messages_count } = v as
|
|
383
|
+
): v is QBUIKitChatDialog['unread_messages_count'] {
|
|
384
|
+
const { unread_messages_count } = v as QBUIKitChatDialog;
|
|
367
385
|
|
|
368
386
|
return (
|
|
369
387
|
unread_messages_count !== undefined && unread_messages_count !== null
|
|
370
388
|
);
|
|
371
389
|
},
|
|
372
|
-
updated_at(v: unknown): v is
|
|
373
|
-
const { updated_at } = v as
|
|
390
|
+
updated_at(v: unknown): v is QBUIKitChatDialog['updated_at'] {
|
|
391
|
+
const { updated_at } = v as QBUIKitChatDialog;
|
|
374
392
|
|
|
375
393
|
return updated_at !== undefined && updated_at !== null;
|
|
376
394
|
},
|
|
377
|
-
user_id(v: unknown): v is
|
|
378
|
-
const { user_id } = v as
|
|
395
|
+
user_id(v: unknown): v is QBUIKitChatDialog['user_id'] {
|
|
396
|
+
const { user_id } = v as QBUIKitChatDialog;
|
|
379
397
|
|
|
380
398
|
return user_id !== undefined && user_id !== null;
|
|
381
399
|
},
|
|
382
|
-
xmpp_room_jid(v: unknown): v is
|
|
383
|
-
const { xmpp_room_jid } = v as
|
|
400
|
+
xmpp_room_jid(v: unknown): v is QBUIKitChatDialog['xmpp_room_jid'] {
|
|
401
|
+
const { xmpp_room_jid } = v as QBUIKitChatDialog;
|
|
384
402
|
|
|
385
403
|
return xmpp_room_jid !== undefined && xmpp_room_jid !== null;
|
|
386
404
|
},
|