Skip to content

Commit

Permalink
v0.3.1-beta.5
Browse files Browse the repository at this point in the history
  • Loading branch information
Artem-K-Koltunov committed Apr 23, 2024
1 parent 8790fbc commit 66a7c27
Show file tree
Hide file tree
Showing 9 changed files with 112 additions and 18 deletions.
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "quickblox-react-ui-kit",
"version": "0.3.1-beta.3",
"version": "0.3.1-beta.5",
"main": "dist/index-ui.js",
"license": "MIT",
"dependencies": {
Expand All @@ -12,7 +12,7 @@
"qb-ai-core": "^0.1.3",
"qb-ai-rephrase": "^0.1.2",
"qb-ai-translate": "^0.1.2",
"quickblox": "^2.16.3",
"quickblox": "^2.16.4",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react-router-dom": "^6.11.1",
Expand Down
34 changes: 30 additions & 4 deletions src/Presentation/Views/DialogInfo/DialogInfo.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -74,10 +74,18 @@ const DialogInfo: React.FC<HeaderDialogsProps> = ({
currentContext.storage.REMOTE_DATA_SOURCE.authInformation?.userId.toString();
const useSubContent = subHeaderContent || false;
const useUpContent = upHeaderContent || false;

const [isLeaving, setIsLeaving] = useState(false);
const toastLeavingId = React.useRef(null);
const leaveDialogHandler = () => {
if (!disableAction) {
// onLeaveDialog((dialogViewModel?.entity || dialog) as GroupDialogEntity);
setIsLeaving(true);
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
toastLeavingId.current = toast('leaving dialog', {
autoClose: false,
isLoading: true,
});
// eslint-disable-next-line promise/catch-or-return
dialogViewModel
.deleteDialog((dialogViewModel?.entity || dialog) as GroupDialogEntity)
.then((result) => {
Expand All @@ -90,6 +98,12 @@ const DialogInfo: React.FC<HeaderDialogsProps> = ({
.catch((e) => {
console.log(e);
toast("Can't leave dialog");
})
.finally(() => {
setIsLeaving(false);
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
toast.dismiss(toastLeavingId.current);
});
}
};
Expand Down Expand Up @@ -331,6 +345,18 @@ const DialogInfo: React.FC<HeaderDialogsProps> = ({

return (
<div style={{ ...rootStyles }} className="dialog-information-container">
<div
style={{
position: 'absolute',
top: '0',
left: '0',
width: '100%',
height: '100%',
backgroundColor: 'rgba(0, 0, 0, 0.5)',
zIndex: '100',
display: isLeaving ? 'block' : 'none',
}}
/>
<ColumnContainer>
{useUpContent && upHeaderContent}
<Header title="Dialog information" className="header-dialog-info">
Expand Down Expand Up @@ -371,8 +397,8 @@ const DialogInfo: React.FC<HeaderDialogsProps> = ({
>
<EditDialog
disableActions={disableAction}
nameDialog={dialogViewModel?.entity.name || dialog.name}
typeDialog={dialogViewModel?.entity.type || dialog.type}
nameDialog={dialogViewModel?.entity.name || dialog?.name}
typeDialog={dialogViewModel?.entity.type || dialog?.type}
ulrIcon={getUrlAvatar(dialogViewModel?.entity || dialog)}
typeAddEditDialog={TypeOpenDialog.edit}
clickUpdatedHandler={getDialogUpdatedInfoHandler}
Expand Down
2 changes: 1 addition & 1 deletion src/Presentation/Views/DialogList/DialogList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,7 @@ const YourComponent = ({ dialogListViewModel }) => {

return (
<div
key={index}
key={item.entity.id}
onClick={() => {
setDialogsToView((prevState) => {
// const newState = [...prevState];
Expand Down
5 changes: 3 additions & 2 deletions src/Presentation/Views/EditDialog/EditDialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ const EditDialog: React.FC<EditDialogProps> = ({
<UserAvatar
urlAvatar={urlAvatar}
clickRemoveAvatarHandler={() => {
setUrlAvatar('');
setUrlAvatar('null');
setErrorMessageUpload('');
}}
/>
Expand All @@ -159,7 +159,8 @@ const EditDialog: React.FC<EditDialogProps> = ({
if (clickUpdatedHandler) {
const params: EditDialogParams = {
dialogTitle: dialogName,
dialogAvatar: urlAvatar.length ? fileUploadAvatar : '',
// dialogAvatar: urlAvatar.length ? fileUploadAvatar : '',
dialogAvatar: urlAvatar === 'null' ? 'null' : fileUploadAvatar,
};

clickUpdatedHandler(params);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,10 @@ export default function useInviteMembersViewModel(): InviteMembersViewModel {
// work
const filteredUsers: UserEntity[] = data.ResultData.reduce(
(userList: UserEntity[], u: UserEntity) => {
if (!regex || regex.test(u.full_name)) {
const nameUserForTest =
u.full_name || u.login || u.email || u.id.toString();

if (!regex || regex.test(nameUserForTest)) {
userList.push(u);
}

Expand Down
10 changes: 10 additions & 0 deletions src/Presentation/Views/PreviewDialog/PreviewDialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,16 @@ const PreviewDialog: React.FC<PreviewDialogsProps> = ({
};
}, []);

useEffect(() => {
getFileForPreview();

return () => {
if (fileUrl) {
URL.revokeObjectURL(fileUrl);
}
};
}, [previewMessage]);

const trimFileName = (fileName: string): string => {
if (fileName.length > 16) {
return `${fileName.substring(0, 15)}... .${fileName.slice(
Expand Down
55 changes: 49 additions & 6 deletions src/Presentation/layouts/Desktop/QuickBloxUIKitDesktopLayout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ import CreateNewDialogFlow from '../../Views/Flow/CreateDialogFlow/CreateNewDial
import useModal from '../../../hooks/useModal';
import useQBConnection from '../../providers/QuickBloxUIKitProvider/useQBConnection';
import { ProxyConfig } from '../../../CommonTypes/CommonTypes';
import EventMessageType from '../../../Domain/entity/EventMessageType';

type AIWidgetPlaceHolder = {
enabled: boolean;
Expand Down Expand Up @@ -243,11 +244,17 @@ const QuickBloxUIKitDesktopLayout: React.FC<
browserOnline && connectionStatus,
);

connectionRepository.subscribe((status) => {
console.log(`Connection status: ${status ? 'CONNECTED' : 'DISCONNECTED'}`);
if (status) setIsOnline(true);
else setIsOnline(false);
});
connectionRepository.subscribe(
(status) => {
console.log(
`Connection status: ${status ? 'CONNECTED' : 'DISCONNECTED'}`,
);
if (status) setIsOnline(true);
else setIsOnline(false);
},
EventMessageType.LocalMessage,
'DESKTOP_LAYOUT',
);

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

const [isLeaving, setIsLeaving] = useState(false);
const toastLeavingId = React.useRef(null);
const handleLeaveDialog = () => {
if (dialogToLeave) {
setIsLeaving(true);
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
toastLeavingId.current = toast('leaving dialog', {
autoClose: false,
isLoading: true,
});
// eslint-disable-next-line promise/catch-or-return
dialogsViewModel
.deleteDialog(dialogToLeave as GroupDialogEntity)
.then((result) => {
Expand All @@ -708,6 +725,12 @@ const QuickBloxUIKitDesktopLayout: React.FC<
.catch((e) => {
console.log(e);
toast("Can't leave dialog");
})
.finally(() => {
setIsLeaving(false);
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
toast.dismiss(toastLeavingId.current);
});
}
};
Expand Down Expand Up @@ -892,12 +915,16 @@ const QuickBloxUIKitDesktopLayout: React.FC<
if (!resultOperation) {
toast(`Incorrect data`);
}
})
.finally(() => {
setFileToSend(null);
});
}
} else if (fileToSend) {
toast(
`file size ${fileToSend?.size} must be less then ${MAXSIZE_FOR_MESSAGE} mb.`,
);
setFileToSend(null);
}
}, [fileToSend]);
useEffect(() => {
Expand Down Expand Up @@ -986,6 +1013,18 @@ const QuickBloxUIKitDesktopLayout: React.FC<
return (
<ToastProvider>
<div className="qb-uikit-layout">
<div
style={{
position: 'absolute',
top: '0',
left: '0',
width: '100%',
height: '100%',
backgroundColor: 'rgba(0, 0, 0, 0.5)',
zIndex: '100',
display: isLeaving ? 'block' : 'none',
}}
/>
<DesktopLayout
mainContainerStyles={{
minHeight: workHeight,
Expand Down Expand Up @@ -1226,7 +1265,11 @@ const QuickBloxUIKitDesktopLayout: React.FC<
minHeight: clientContainerHeight,
maxHeight: clientContainerHeight,
}}
// subHeaderContent={<CompanyLogo />}
subHeaderContent={
<div>
<p>v0.3.1-beta.5</p>
</div>
}
// upHeaderContent={<CompanyLogo />}
dialog={selectedDialog}
dialogViewModel={dialogsViewModel}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -322,14 +322,22 @@ function QuickBloxUIKitProvider({
// };

useEffect(() => {
if (!accountData.accountKey || !accountData.appId || !accountData.authKey) {
if (
!accountData.accountKey ||
!accountData.appId ||
(!accountData.authKey && !accountData.sessionToken)
) {
toast(
'Please input AppId, AuthKey, AuthSecret, AccountKey to sign in/up',
);
}
}, []);

if (!accountData.accountKey || !accountData.appId || !accountData.authKey) {
if (
!accountData.accountKey ||
!accountData.appId ||
(!accountData.authKey && !accountData.sessionToken)
) {
return (
<>
<ToastContainer
Expand Down
3 changes: 3 additions & 0 deletions src/Presentation/ui-components/Avatar/Avatar.scss
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@
color: var(--secondary-text);

svg {
height: 100%;
width: 100%;

fill: var(--secondary-text);
padding: 10px;
}
Expand Down

0 comments on commit 66a7c27

Please sign in to comment.