diff --git a/src/components/main/Dialogs.tsx b/src/components/main/Dialogs.tsx index fc8ee9be4..87b4c5ff1 100644 --- a/src/components/main/Dialogs.tsx +++ b/src/components/main/Dialogs.tsx @@ -1,12 +1,13 @@ -import React, { FC, memo } from '../../lib/teact/teact'; +import React, { FC, memo, useEffect } from '../../lib/teact/teact'; import { getDispatch, withGlobal } from '../../lib/teact/teactn'; import { ApiError, ApiInviteInfo, ApiPhoto } from '../../api/types'; import getReadableErrorText from '../../util/getReadableErrorText'; import { pick } from '../../util/iteratees'; -import useLang from '../../hooks/useLang'; import renderText from '../common/helpers/renderText'; +import useLang from '../../hooks/useLang'; +import useFlag from '../../hooks/useFlag'; import Modal from '../ui/Modal'; import Button from '../ui/Button'; @@ -20,9 +21,16 @@ type StateProps = { const Dialogs: FC = ({ dialogs }) => { const { dismissDialog, acceptInviteConfirmation } = getDispatch(); + const [isModalOpen, openModal, closeModal] = useFlag(); const lang = useLang(); + useEffect(() => { + if (dialogs.length > 0) { + openModal(); + } + }, [dialogs, openModal]); + if (!dialogs.length) { return undefined; } @@ -34,7 +42,7 @@ const Dialogs: FC = ({ dialogs }) => {
{renderText(title)}
- @@ -50,7 +58,7 @@ const Dialogs: FC = ({ dialogs }) => { acceptInviteConfirmation({ hash, }); - dismissDialog(); + closeModal(); }; const participantsText = isChannel @@ -63,10 +71,11 @@ const Dialogs: FC = ({ dialogs }) => { return ( {about &&

{renderText(about)}

} {participantsCount !== undefined &&

{participantsText}

} @@ -80,7 +89,7 @@ const Dialogs: FC = ({ dialogs }) => { - +
); }; @@ -88,14 +97,15 @@ const Dialogs: FC = ({ dialogs }) => { const renderError = (error: ApiError) => { return ( {error.hasErrorKey ? getReadableErrorText(error) : renderText(error.message!, ['emoji', 'br'])}
- +
); @@ -111,7 +121,7 @@ const Dialogs: FC = ({ dialogs }) => { return (
- {dialogs.map(renderDialog)} + {Boolean(dialogs.length) && renderDialog(dialogs[dialogs.length - 1])}
); };