Skip to content

Commit 66a7c27

Browse files
v0.3.1-beta.5
1 parent 8790fbc commit 66a7c27

File tree

9 files changed

+112
-18
lines changed

9 files changed

+112
-18
lines changed

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "quickblox-react-ui-kit",
3-
"version": "0.3.1-beta.3",
3+
"version": "0.3.1-beta.5",
44
"main": "dist/index-ui.js",
55
"license": "MIT",
66
"dependencies": {
@@ -12,7 +12,7 @@
1212
"qb-ai-core": "^0.1.3",
1313
"qb-ai-rephrase": "^0.1.2",
1414
"qb-ai-translate": "^0.1.2",
15-
"quickblox": "^2.16.3",
15+
"quickblox": "^2.16.4",
1616
"react": "^18.2.0",
1717
"react-dom": "^18.2.0",
1818
"react-router-dom": "^6.11.1",

src/Presentation/Views/DialogInfo/DialogInfo.tsx

Lines changed: 30 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -74,10 +74,18 @@ const DialogInfo: React.FC<HeaderDialogsProps> = ({
7474
currentContext.storage.REMOTE_DATA_SOURCE.authInformation?.userId.toString();
7575
const useSubContent = subHeaderContent || false;
7676
const useUpContent = upHeaderContent || false;
77-
77+
const [isLeaving, setIsLeaving] = useState(false);
78+
const toastLeavingId = React.useRef(null);
7879
const leaveDialogHandler = () => {
7980
if (!disableAction) {
80-
// onLeaveDialog((dialogViewModel?.entity || dialog) as GroupDialogEntity);
81+
setIsLeaving(true);
82+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
83+
// @ts-ignore
84+
toastLeavingId.current = toast('leaving dialog', {
85+
autoClose: false,
86+
isLoading: true,
87+
});
88+
// eslint-disable-next-line promise/catch-or-return
8189
dialogViewModel
8290
.deleteDialog((dialogViewModel?.entity || dialog) as GroupDialogEntity)
8391
.then((result) => {
@@ -90,6 +98,12 @@ const DialogInfo: React.FC<HeaderDialogsProps> = ({
9098
.catch((e) => {
9199
console.log(e);
92100
toast("Can't leave dialog");
101+
})
102+
.finally(() => {
103+
setIsLeaving(false);
104+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
105+
// @ts-ignore
106+
toast.dismiss(toastLeavingId.current);
93107
});
94108
}
95109
};
@@ -331,6 +345,18 @@ const DialogInfo: React.FC<HeaderDialogsProps> = ({
331345

332346
return (
333347
<div style={{ ...rootStyles }} className="dialog-information-container">
348+
<div
349+
style={{
350+
position: 'absolute',
351+
top: '0',
352+
left: '0',
353+
width: '100%',
354+
height: '100%',
355+
backgroundColor: 'rgba(0, 0, 0, 0.5)',
356+
zIndex: '100',
357+
display: isLeaving ? 'block' : 'none',
358+
}}
359+
/>
334360
<ColumnContainer>
335361
{useUpContent && upHeaderContent}
336362
<Header title="Dialog information" className="header-dialog-info">
@@ -371,8 +397,8 @@ const DialogInfo: React.FC<HeaderDialogsProps> = ({
371397
>
372398
<EditDialog
373399
disableActions={disableAction}
374-
nameDialog={dialogViewModel?.entity.name || dialog.name}
375-
typeDialog={dialogViewModel?.entity.type || dialog.type}
400+
nameDialog={dialogViewModel?.entity.name || dialog?.name}
401+
typeDialog={dialogViewModel?.entity.type || dialog?.type}
376402
ulrIcon={getUrlAvatar(dialogViewModel?.entity || dialog)}
377403
typeAddEditDialog={TypeOpenDialog.edit}
378404
clickUpdatedHandler={getDialogUpdatedInfoHandler}

src/Presentation/Views/DialogList/DialogList.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -281,7 +281,7 @@ const YourComponent = ({ dialogListViewModel }) => {
281281

282282
return (
283283
<div
284-
key={index}
284+
key={item.entity.id}
285285
onClick={() => {
286286
setDialogsToView((prevState) => {
287287
// const newState = [...prevState];

src/Presentation/Views/EditDialog/EditDialog.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ const EditDialog: React.FC<EditDialogProps> = ({
140140
<UserAvatar
141141
urlAvatar={urlAvatar}
142142
clickRemoveAvatarHandler={() => {
143-
setUrlAvatar('');
143+
setUrlAvatar('null');
144144
setErrorMessageUpload('');
145145
}}
146146
/>
@@ -159,7 +159,8 @@ const EditDialog: React.FC<EditDialogProps> = ({
159159
if (clickUpdatedHandler) {
160160
const params: EditDialogParams = {
161161
dialogTitle: dialogName,
162-
dialogAvatar: urlAvatar.length ? fileUploadAvatar : '',
162+
// dialogAvatar: urlAvatar.length ? fileUploadAvatar : '',
163+
dialogAvatar: urlAvatar === 'null' ? 'null' : fileUploadAvatar,
163164
};
164165

165166
clickUpdatedHandler(params);

src/Presentation/Views/InviteMembers/useInviteMembersViewModel.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,10 @@ export default function useInviteMembersViewModel(): InviteMembersViewModel {
7171
// work
7272
const filteredUsers: UserEntity[] = data.ResultData.reduce(
7373
(userList: UserEntity[], u: UserEntity) => {
74-
if (!regex || regex.test(u.full_name)) {
74+
const nameUserForTest =
75+
u.full_name || u.login || u.email || u.id.toString();
76+
77+
if (!regex || regex.test(nameUserForTest)) {
7578
userList.push(u);
7679
}
7780

src/Presentation/Views/PreviewDialog/PreviewDialog.tsx

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -231,6 +231,16 @@ const PreviewDialog: React.FC<PreviewDialogsProps> = ({
231231
};
232232
}, []);
233233

234+
useEffect(() => {
235+
getFileForPreview();
236+
237+
return () => {
238+
if (fileUrl) {
239+
URL.revokeObjectURL(fileUrl);
240+
}
241+
};
242+
}, [previewMessage]);
243+
234244
const trimFileName = (fileName: string): string => {
235245
if (fileName.length > 16) {
236246
return `${fileName.substring(0, 15)}... .${fileName.slice(

src/Presentation/layouts/Desktop/QuickBloxUIKitDesktopLayout.tsx

Lines changed: 49 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ import CreateNewDialogFlow from '../../Views/Flow/CreateDialogFlow/CreateNewDial
6060
import useModal from '../../../hooks/useModal';
6161
import useQBConnection from '../../providers/QuickBloxUIKitProvider/useQBConnection';
6262
import { ProxyConfig } from '../../../CommonTypes/CommonTypes';
63+
import EventMessageType from '../../../Domain/entity/EventMessageType';
6364

6465
type AIWidgetPlaceHolder = {
6566
enabled: boolean;
@@ -243,11 +244,17 @@ const QuickBloxUIKitDesktopLayout: React.FC<
243244
browserOnline && connectionStatus,
244245
);
245246

246-
connectionRepository.subscribe((status) => {
247-
console.log(`Connection status: ${status ? 'CONNECTED' : 'DISCONNECTED'}`);
248-
if (status) setIsOnline(true);
249-
else setIsOnline(false);
250-
});
247+
connectionRepository.subscribe(
248+
(status) => {
249+
console.log(
250+
`Connection status: ${status ? 'CONNECTED' : 'DISCONNECTED'}`,
251+
);
252+
if (status) setIsOnline(true);
253+
else setIsOnline(false);
254+
},
255+
EventMessageType.LocalMessage,
256+
'DESKTOP_LAYOUT',
257+
);
251258

252259
const [needRefresh, setNeedRefresh] = useState(false);
253260
const toastConnectionErrorId = React.useRef(null);
@@ -694,8 +701,18 @@ const QuickBloxUIKitDesktopLayout: React.FC<
694701
setIsOpen((state) => !state);
695702
};
696703

704+
const [isLeaving, setIsLeaving] = useState(false);
705+
const toastLeavingId = React.useRef(null);
697706
const handleLeaveDialog = () => {
698707
if (dialogToLeave) {
708+
setIsLeaving(true);
709+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
710+
// @ts-ignore
711+
toastLeavingId.current = toast('leaving dialog', {
712+
autoClose: false,
713+
isLoading: true,
714+
});
715+
// eslint-disable-next-line promise/catch-or-return
699716
dialogsViewModel
700717
.deleteDialog(dialogToLeave as GroupDialogEntity)
701718
.then((result) => {
@@ -708,6 +725,12 @@ const QuickBloxUIKitDesktopLayout: React.FC<
708725
.catch((e) => {
709726
console.log(e);
710727
toast("Can't leave dialog");
728+
})
729+
.finally(() => {
730+
setIsLeaving(false);
731+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
732+
// @ts-ignore
733+
toast.dismiss(toastLeavingId.current);
711734
});
712735
}
713736
};
@@ -892,12 +915,16 @@ const QuickBloxUIKitDesktopLayout: React.FC<
892915
if (!resultOperation) {
893916
toast(`Incorrect data`);
894917
}
918+
})
919+
.finally(() => {
920+
setFileToSend(null);
895921
});
896922
}
897923
} else if (fileToSend) {
898924
toast(
899925
`file size ${fileToSend?.size} must be less then ${MAXSIZE_FOR_MESSAGE} mb.`,
900926
);
927+
setFileToSend(null);
901928
}
902929
}, [fileToSend]);
903930
useEffect(() => {
@@ -986,6 +1013,18 @@ const QuickBloxUIKitDesktopLayout: React.FC<
9861013
return (
9871014
<ToastProvider>
9881015
<div className="qb-uikit-layout">
1016+
<div
1017+
style={{
1018+
position: 'absolute',
1019+
top: '0',
1020+
left: '0',
1021+
width: '100%',
1022+
height: '100%',
1023+
backgroundColor: 'rgba(0, 0, 0, 0.5)',
1024+
zIndex: '100',
1025+
display: isLeaving ? 'block' : 'none',
1026+
}}
1027+
/>
9891028
<DesktopLayout
9901029
mainContainerStyles={{
9911030
minHeight: workHeight,
@@ -1226,7 +1265,11 @@ const QuickBloxUIKitDesktopLayout: React.FC<
12261265
minHeight: clientContainerHeight,
12271266
maxHeight: clientContainerHeight,
12281267
}}
1229-
// subHeaderContent={<CompanyLogo />}
1268+
subHeaderContent={
1269+
<div>
1270+
<p>v0.3.1-beta.5</p>
1271+
</div>
1272+
}
12301273
// upHeaderContent={<CompanyLogo />}
12311274
dialog={selectedDialog}
12321275
dialogViewModel={dialogsViewModel}

src/Presentation/providers/QuickBloxUIKitProvider/QuickBloxUIKitProvider.tsx

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -322,14 +322,22 @@ function QuickBloxUIKitProvider({
322322
// };
323323

324324
useEffect(() => {
325-
if (!accountData.accountKey || !accountData.appId || !accountData.authKey) {
325+
if (
326+
!accountData.accountKey ||
327+
!accountData.appId ||
328+
(!accountData.authKey && !accountData.sessionToken)
329+
) {
326330
toast(
327331
'Please input AppId, AuthKey, AuthSecret, AccountKey to sign in/up',
328332
);
329333
}
330334
}, []);
331335

332-
if (!accountData.accountKey || !accountData.appId || !accountData.authKey) {
336+
if (
337+
!accountData.accountKey ||
338+
!accountData.appId ||
339+
(!accountData.authKey && !accountData.sessionToken)
340+
) {
333341
return (
334342
<>
335343
<ToastContainer

src/Presentation/ui-components/Avatar/Avatar.scss

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@
1313
color: var(--secondary-text);
1414

1515
svg {
16+
height: 100%;
17+
width: 100%;
18+
1619
fill: var(--secondary-text);
1720
padding: 10px;
1821
}

0 commit comments

Comments
 (0)