quickblox-react-ui-kit 0.3.0-beta.4 → 0.3.1-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/CommonTypes/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 +5 -4
- package/dist/Data/dto/dialog/LocalDialogDTO.d.ts +1 -1
- package/dist/Data/dto/dialog/RemoteDialogDTO.d.ts +1 -1
- package/dist/Data/source/remote/Mapper/MessageDTOMapper.d.ts +1 -0
- package/dist/Domain/entity/LastMessageEntity.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 +985 -973
- package/dist/index-ui.js.map +1 -1
- package/dist/qb-api-calls/index.d.ts +13 -12
- package/dist/utils/formatFileSize.d.ts +1 -0
- package/dist/utils/parse.d.ts +1 -0
- package/global.d.ts +159 -2836
- package/package.json +4 -2
- package/src/App.tsx +2 -1
- package/src/CommonTypes/CommonTypes.ts +228 -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 +30 -29
- package/src/Data/dto/dialog/LocalDialogDTO.ts +2 -2
- package/src/Data/dto/dialog/RemoteDialogDTO.ts +2 -2
- package/src/Data/mapper/DialogLocalDTOMapper.ts +4 -10
- package/src/Data/mapper/DialogRemoteDTOMapper.ts +5 -10
- 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 +65 -47
- 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 +31 -10
- package/src/Domain/entity/LastMessageEntity.ts +1 -1
- package/src/Presentation/Views/Dialog/useDialogViewModel.ts +8 -0
- package/src/Presentation/Views/DialogInfo/DialogInfo.tsx +1 -1
- package/src/Presentation/Views/DialogList/DialogList.tsx +65 -2
- package/src/Presentation/Views/EditDialog/EditDialog.tsx +4 -3
- package/src/Presentation/Views/InviteMembers/InviteMembers.tsx +9 -1
- package/src/Presentation/Views/PreviewDialog/PreviewDialog.tsx +1 -0
- package/src/Presentation/layouts/Desktop/QuickBloxUIKitDesktopLayout.tsx +388 -515
- 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 +39 -14
- package/src/utils/formatFileSize.ts +8 -0
- package/src/utils/parse.ts +2 -0
- package/storybook-static/703.1137fb37.iframe.bundle.js +33 -0
- package/storybook-static/703.1137fb37.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.0c6310aa.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/{docs-Introduction-mdx.ac401482.iframe.bundle.js → docs-Introduction-mdx.bcb06844.iframe.bundle.js} +2 -2
- package/storybook-static/{docs-Introduction-mdx.ac401482.iframe.bundle.js.map → docs-Introduction-mdx.bcb06844.iframe.bundle.js.map} +1 -1
- 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.8d5710fb.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.12da9712.iframe.bundle.js +0 -1
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
import React, { useState } from 'react';
|
|
2
2
|
import './Login.scss';
|
|
3
|
-
import { InitParams } from '../../../providers/QuickBloxUIKitProvider/QuickBloxUIKitProvider';
|
|
4
|
-
import useQbInitializedDataContext from '../../../providers/QuickBloxUIKitProvider/useQbInitializedDataContext';
|
|
5
3
|
import { LoginData } from '../../../../Data/source/remote/RemoteDataSource';
|
|
6
4
|
|
|
7
5
|
export type FunctionTypeLoginDataToVoid = (data: LoginData) => void;
|
|
@@ -11,11 +9,9 @@ type LoginProps = {
|
|
|
11
9
|
};
|
|
12
10
|
// eslint-disable-next-line react/function-component-definition
|
|
13
11
|
const Login: React.FC<LoginProps> = ({ loginHandler }: LoginProps) => {
|
|
14
|
-
const currentContext = useQbInitializedDataContext();
|
|
15
|
-
const [UserName, setUsername] = useState(
|
|
16
|
-
|
|
17
|
-
);
|
|
18
|
-
const [Password, setPassword] = useState('quickblox');
|
|
12
|
+
// const currentContext = useQbInitializedDataContext();
|
|
13
|
+
const [UserName, setUsername] = useState('');
|
|
14
|
+
const [Password, setPassword] = useState('');
|
|
19
15
|
|
|
20
16
|
// const [term, setTerm] = useState('');
|
|
21
17
|
|
|
@@ -36,11 +32,11 @@ const Login: React.FC<LoginProps> = ({ loginHandler }: LoginProps) => {
|
|
|
36
32
|
|
|
37
33
|
if (loginHandler) {
|
|
38
34
|
//
|
|
39
|
-
const oldData: InitParams = currentContext.InitParams;
|
|
40
|
-
const newData: InitParams = { ...oldData, loginData: data };
|
|
35
|
+
// const oldData: InitParams = currentContext.InitParams;
|
|
36
|
+
// const newData: InitParams = { ...oldData, loginData: data };
|
|
41
37
|
|
|
42
|
-
currentContext.updateQBInitParams(newData);
|
|
43
|
-
//
|
|
38
|
+
// currentContext.updateQBInitParams(newData);
|
|
39
|
+
// //
|
|
44
40
|
loginHandler(data);
|
|
45
41
|
}
|
|
46
42
|
};
|
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
import React from 'react';
|
|
1
|
+
import React, { useEffect } from 'react';
|
|
2
|
+
import { ToastContainer, toast } from 'react-toastify';
|
|
3
|
+
import 'react-toastify/dist/ReactToastify.css';
|
|
2
4
|
import { ProviderProps } from '../ProviderProps';
|
|
3
5
|
import { LocalDataSource } from '../../../Data/source/local/LocalDataSource';
|
|
4
6
|
import {
|
|
@@ -13,6 +15,7 @@ import ConnectionRepository from '../../../Data/repository/ConnectionRepository'
|
|
|
13
15
|
import EventMessagesRepository from '../../../Data/repository/EventMessagesRepository';
|
|
14
16
|
import { CallBackFunction } from '../../../Domain/use_cases/base/IUseCase';
|
|
15
17
|
import { DefaultConfigurations } from '../../../Data/DefaultConfigurations';
|
|
18
|
+
import { QBUIKitConfig } from '../../../CommonTypes/CommonTypes';
|
|
16
19
|
|
|
17
20
|
const initialValues = {
|
|
18
21
|
LOCAL_DATA_SOURCE: new LocalDataSource(), // localstorage or session storage
|
|
@@ -50,7 +53,7 @@ type AccountData = {
|
|
|
50
53
|
export type InitParams = {
|
|
51
54
|
maxFileSize: number;
|
|
52
55
|
accountData: AccountData;
|
|
53
|
-
qbConfig:
|
|
56
|
+
qbConfig: QBUIKitConfig;
|
|
54
57
|
loginData?: LoginData;
|
|
55
58
|
};
|
|
56
59
|
|
|
@@ -318,6 +321,31 @@ function QuickBloxUIKitProvider({
|
|
|
318
321
|
// setAuthProcessed(status);
|
|
319
322
|
// };
|
|
320
323
|
|
|
324
|
+
useEffect(() => {
|
|
325
|
+
if (!accountData.accountKey || !accountData.appId || !accountData.authKey) {
|
|
326
|
+
toast(
|
|
327
|
+
'Please input AppId, AuthKey, AuthSecret, AccountKey to sign in/up',
|
|
328
|
+
);
|
|
329
|
+
}
|
|
330
|
+
}, []);
|
|
331
|
+
|
|
332
|
+
if (!accountData.accountKey || !accountData.appId || !accountData.authKey) {
|
|
333
|
+
return (
|
|
334
|
+
<>
|
|
335
|
+
<ToastContainer
|
|
336
|
+
position="top-center"
|
|
337
|
+
autoClose={5000}
|
|
338
|
+
bodyClassName="toast__body"
|
|
339
|
+
toastClassName="toast"
|
|
340
|
+
pauseOnHover={false}
|
|
341
|
+
closeButton={false}
|
|
342
|
+
hideProgressBar
|
|
343
|
+
/>
|
|
344
|
+
{children}
|
|
345
|
+
</>
|
|
346
|
+
);
|
|
347
|
+
}
|
|
348
|
+
|
|
321
349
|
return (
|
|
322
350
|
<Provider
|
|
323
351
|
value={{
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import {
|
|
2
2
|
DetailedHTMLProps,
|
|
3
|
+
ForwardedRef,
|
|
3
4
|
InputHTMLAttributes,
|
|
4
5
|
ReactElement,
|
|
6
|
+
forwardRef,
|
|
5
7
|
useId,
|
|
6
8
|
} from 'react';
|
|
7
9
|
import cn from 'classnames';
|
|
@@ -24,55 +26,63 @@ interface TextFieldProps extends Omit<HTMLInputProps, 'onChange'> {
|
|
|
24
26
|
onChange: (value: string) => void;
|
|
25
27
|
}
|
|
26
28
|
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
29
|
+
const TextField = forwardRef(
|
|
30
|
+
(
|
|
31
|
+
{
|
|
32
|
+
label,
|
|
33
|
+
icon,
|
|
34
|
+
loading = false,
|
|
35
|
+
disabled = false,
|
|
36
|
+
className,
|
|
37
|
+
id,
|
|
38
|
+
value,
|
|
39
|
+
onChange,
|
|
40
|
+
...inputProps
|
|
41
|
+
}: TextFieldProps,
|
|
42
|
+
ref: ForwardedRef<HTMLInputElement>,
|
|
43
|
+
) => {
|
|
44
|
+
const defaultId = useId();
|
|
39
45
|
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
)}
|
|
49
|
-
>
|
|
50
|
-
{label && (
|
|
51
|
-
<label htmlFor={id || defaultId} className="text-field__label">
|
|
52
|
-
{label}
|
|
53
|
-
</label>
|
|
54
|
-
)}
|
|
55
|
-
|
|
56
|
-
<div className="text-field__wrapper">
|
|
57
|
-
{icon && <span className="text-field__icon">{icon}</span>}
|
|
58
|
-
<input
|
|
59
|
-
{...inputProps}
|
|
60
|
-
disabled={loading || disabled}
|
|
61
|
-
className="text-field__input"
|
|
62
|
-
id={id || defaultId}
|
|
63
|
-
value={value}
|
|
64
|
-
onChange={(e) => onChange(e.currentTarget.value)}
|
|
65
|
-
/>
|
|
66
|
-
{!loading && value && (
|
|
67
|
-
<RemoveSvg
|
|
68
|
-
className="text-field__reset"
|
|
69
|
-
onClick={() => onChange('')}
|
|
70
|
-
/>
|
|
46
|
+
return (
|
|
47
|
+
<div
|
|
48
|
+
className={cn(
|
|
49
|
+
'text-field',
|
|
50
|
+
{
|
|
51
|
+
'text-field--disabled': disabled,
|
|
52
|
+
},
|
|
53
|
+
className,
|
|
71
54
|
)}
|
|
72
|
-
|
|
73
|
-
|
|
55
|
+
>
|
|
56
|
+
{label && (
|
|
57
|
+
<label htmlFor={id || defaultId} className="text-field__label">
|
|
58
|
+
{label}
|
|
59
|
+
</label>
|
|
74
60
|
)}
|
|
61
|
+
|
|
62
|
+
<div className="text-field__wrapper">
|
|
63
|
+
{icon && <span className="text-field__icon">{icon}</span>}
|
|
64
|
+
<input
|
|
65
|
+
{...inputProps}
|
|
66
|
+
ref={ref}
|
|
67
|
+
disabled={loading || disabled}
|
|
68
|
+
className="text-field__input"
|
|
69
|
+
id={id || defaultId}
|
|
70
|
+
value={value}
|
|
71
|
+
onChange={(e) => onChange(e.currentTarget.value)}
|
|
72
|
+
/>
|
|
73
|
+
{!loading && value && (
|
|
74
|
+
<RemoveSvg
|
|
75
|
+
className="text-field__reset"
|
|
76
|
+
onClick={() => onChange('')}
|
|
77
|
+
/>
|
|
78
|
+
)}
|
|
79
|
+
{loading && !disabled && (
|
|
80
|
+
<Loader size="sm" className="text-field__loader" />
|
|
81
|
+
)}
|
|
82
|
+
</div>
|
|
75
83
|
</div>
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
84
|
+
);
|
|
85
|
+
},
|
|
86
|
+
);
|
|
87
|
+
|
|
88
|
+
export default TextField;
|
package/src/QBconfig.ts
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
|
|
1
|
+
import { QBUIKitConfig } from './CommonTypes/CommonTypes';
|
|
2
|
+
|
|
3
|
+
export const QBConfig: QBUIKitConfig = {
|
|
2
4
|
credentials: {
|
|
3
5
|
appId: 75949,
|
|
4
6
|
accountKey: 'uK_8uinNyz8-npTNB6tx',
|
|
@@ -122,7 +124,7 @@ export const QBConfig = {
|
|
|
122
124
|
},
|
|
123
125
|
},
|
|
124
126
|
appConfig: {
|
|
125
|
-
maxFileSize:
|
|
127
|
+
maxFileSize: 10485760,
|
|
126
128
|
sessionTimeOut: 122,
|
|
127
129
|
chatProtocol: {
|
|
128
130
|
active: 2,
|
|
@@ -135,15 +137,15 @@ export const QBConfig = {
|
|
|
135
137
|
api: 'api.quickblox.com',
|
|
136
138
|
chat: 'chat.quickblox.com',
|
|
137
139
|
},
|
|
138
|
-
on: {
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
},
|
|
140
|
+
// on: {
|
|
141
|
+
// // eslint-disable-next-line @typescript-eslint/no-unused-vars,@typescript-eslint/require-await
|
|
142
|
+
// async sessionExpired(handleResponse: any, retry: any) {
|
|
143
|
+
// console.log(
|
|
144
|
+
// // eslint-disable-next-line @typescript-eslint/restrict-template-expressions
|
|
145
|
+
// `QBconfig sessionExpired handle: ${handleResponse} ${retry}`,
|
|
146
|
+
// );
|
|
147
|
+
// },
|
|
148
|
+
// },
|
|
147
149
|
streamManagement: {
|
|
148
150
|
enable: true,
|
|
149
151
|
},
|
|
@@ -1,12 +1,37 @@
|
|
|
1
|
+
import QB, {
|
|
2
|
+
GetMessagesResult,
|
|
3
|
+
GetUserParams,
|
|
4
|
+
ListUserParams,
|
|
5
|
+
ListUserResponse,
|
|
6
|
+
QBBlob,
|
|
7
|
+
QBBlobCreateUploadParams,
|
|
8
|
+
QBChatMessage,
|
|
9
|
+
QBCustomObject,
|
|
10
|
+
QBDataDeletedResponse,
|
|
11
|
+
QBGetDialogResult,
|
|
12
|
+
QBLoginParams,
|
|
13
|
+
QBMediaParams,
|
|
14
|
+
QBMessageStatusParams,
|
|
15
|
+
QBSession,
|
|
16
|
+
QBSystemMessage,
|
|
17
|
+
QBUser,
|
|
18
|
+
QBUserCreateParams,
|
|
19
|
+
QBWebRTCSession,
|
|
20
|
+
} from 'quickblox/quickblox';
|
|
1
21
|
import { stringifyError } from '../utils/parse';
|
|
2
|
-
import {
|
|
22
|
+
import {
|
|
23
|
+
QBChatDialogType,
|
|
24
|
+
QBUIKitChatDialog,
|
|
25
|
+
QBUIKitChatNewMessage,
|
|
26
|
+
QBUIKitConfig,
|
|
27
|
+
} from '../CommonTypes/CommonTypes';
|
|
3
28
|
|
|
4
29
|
export type QBInitParams = {
|
|
5
30
|
appIdOrToken: string | number;
|
|
6
31
|
authKeyOrAppId: string | number;
|
|
7
32
|
authSecret?: string;
|
|
8
33
|
accountKey: string;
|
|
9
|
-
config?:
|
|
34
|
+
config?: QBUIKitConfig;
|
|
10
35
|
};
|
|
11
36
|
|
|
12
37
|
export function QBInit(params: QBInitParams) {
|
|
@@ -15,7 +40,7 @@ export function QBInit(params: QBInitParams) {
|
|
|
15
40
|
params.authKeyOrAppId,
|
|
16
41
|
params.authSecret,
|
|
17
42
|
params.accountKey,
|
|
18
|
-
params.config,
|
|
43
|
+
params.config?.appConfig,
|
|
19
44
|
);
|
|
20
45
|
}
|
|
21
46
|
|
|
@@ -298,7 +323,7 @@ export function QBCreatePrivateDialog(
|
|
|
298
323
|
}`,
|
|
299
324
|
);
|
|
300
325
|
|
|
301
|
-
return new Promise<
|
|
326
|
+
return new Promise<QBUIKitChatDialog>((resolve, reject) => {
|
|
302
327
|
QB.chat.dialog.create(
|
|
303
328
|
{ name: dialogName || '-', occupants_ids: [userId], type: 3, data },
|
|
304
329
|
(error, chat) => {
|
|
@@ -339,7 +364,7 @@ export function QBCreateGroupDialog(
|
|
|
339
364
|
};
|
|
340
365
|
}
|
|
341
366
|
|
|
342
|
-
return new Promise<
|
|
367
|
+
return new Promise<QBUIKitChatDialog>((resolve, reject) => {
|
|
343
368
|
QB.chat.dialog.create(
|
|
344
369
|
// {
|
|
345
370
|
// name: dialogName || '-',
|
|
@@ -360,10 +385,10 @@ export function QBCreateGroupDialog(
|
|
|
360
385
|
}
|
|
361
386
|
|
|
362
387
|
export function QBUpdateDialog(
|
|
363
|
-
dialogId:
|
|
388
|
+
dialogId: QBUIKitChatDialog['_id'],
|
|
364
389
|
data: Dictionary<unknown>,
|
|
365
390
|
) {
|
|
366
|
-
return new Promise<
|
|
391
|
+
return new Promise<QBUIKitChatDialog>((resolve, reject) => {
|
|
367
392
|
QB.chat.dialog.update(dialogId, data, (error, chat) => {
|
|
368
393
|
if (error) {
|
|
369
394
|
reject(stringifyError(error));
|
|
@@ -374,7 +399,7 @@ export function QBUpdateDialog(
|
|
|
374
399
|
});
|
|
375
400
|
}
|
|
376
401
|
|
|
377
|
-
export function QBJoinGroupDialog(dialogId:
|
|
402
|
+
export function QBJoinGroupDialog(dialogId: QBUIKitChatDialog['_id']) {
|
|
378
403
|
return new Promise((resolve, reject) => {
|
|
379
404
|
const dialogJid = QB.chat.helpers.getRoomJidFromDialogId(dialogId);
|
|
380
405
|
|
|
@@ -388,7 +413,7 @@ export function QBJoinGroupDialog(dialogId: QBChatDialog['_id']) {
|
|
|
388
413
|
});
|
|
389
414
|
}
|
|
390
415
|
|
|
391
|
-
export function QBDeleteDialog(dialogIds: Array<
|
|
416
|
+
export function QBDeleteDialog(dialogIds: Array<QBUIKitChatDialog['_id']>) {
|
|
392
417
|
return new Promise<void>((resolve, reject) => {
|
|
393
418
|
QB.chat.dialog.delete(dialogIds, (error) => {
|
|
394
419
|
if (error) {
|
|
@@ -400,7 +425,7 @@ export function QBDeleteDialog(dialogIds: Array<QBChatDialog['_id']>) {
|
|
|
400
425
|
});
|
|
401
426
|
}
|
|
402
427
|
|
|
403
|
-
export function QBLeaveDialog(dialogId:
|
|
428
|
+
export function QBLeaveDialog(dialogId: QBUIKitChatDialog['_id']) {
|
|
404
429
|
return new Promise((resolve, reject) => {
|
|
405
430
|
const dialogJid = QB.chat.helpers.getRoomJidFromDialogId(dialogId);
|
|
406
431
|
|
|
@@ -481,7 +506,7 @@ export function QBCreateAndUploadContent(
|
|
|
481
506
|
// //
|
|
482
507
|
|
|
483
508
|
export function qbChatGetMessagesExtended(
|
|
484
|
-
dialogId:
|
|
509
|
+
dialogId: QBUIKitChatDialog['_id'],
|
|
485
510
|
params: Partial<{
|
|
486
511
|
skip: number;
|
|
487
512
|
limit: number;
|
|
@@ -516,7 +541,7 @@ export function qbChatGetMessagesExtended(
|
|
|
516
541
|
}
|
|
517
542
|
//
|
|
518
543
|
export function QBSendIsTypingStatus(
|
|
519
|
-
dialog:
|
|
544
|
+
dialog: QBUIKitChatDialog,
|
|
520
545
|
senderId: QBUser['id'],
|
|
521
546
|
) {
|
|
522
547
|
const isPrivate: QBChatDialogType = 3;
|
|
@@ -534,7 +559,7 @@ export function QBSendIsTypingStatus(
|
|
|
534
559
|
}
|
|
535
560
|
}
|
|
536
561
|
export function QBSendIsStopTypingStatus(
|
|
537
|
-
dialog:
|
|
562
|
+
dialog: QBUIKitChatDialog,
|
|
538
563
|
senderId: QBUser['id'],
|
|
539
564
|
) {
|
|
540
565
|
const isPrivate: QBChatDialogType = 3;
|
|
@@ -555,7 +580,7 @@ export function QBSendIsStopTypingStatus(
|
|
|
555
580
|
|
|
556
581
|
export function QBChatSendMessage(
|
|
557
582
|
to: string | number, // artan 22.06.23
|
|
558
|
-
message:
|
|
583
|
+
message: QBUIKitChatNewMessage,
|
|
559
584
|
) {
|
|
560
585
|
return new Promise<QBChatMessage['_id']>((resolve) => {
|
|
561
586
|
resolve(QB.chat.send(to, message));
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export const formatFileSize = (size: number) => {
|
|
2
|
+
const units = ['B', 'kB', 'MB', 'GB', 'TB'];
|
|
3
|
+
const currentUnitIndex = Math.floor(Math.log(size) / Math.log(1024));
|
|
4
|
+
|
|
5
|
+
return `${Math.round(size / 1024 ** currentUnitIndex)} ${
|
|
6
|
+
units[currentUnitIndex]
|
|
7
|
+
}`;
|
|
8
|
+
};
|