Dialog: Fix missing closing animation (#1630)
This commit is contained in:
parent
392aee6c84
commit
23d1dc6d48
@ -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 { getDispatch, withGlobal } from '../../lib/teact/teactn';
|
||||||
|
|
||||||
import { ApiError, ApiInviteInfo, ApiPhoto } from '../../api/types';
|
import { ApiError, ApiInviteInfo, ApiPhoto } from '../../api/types';
|
||||||
|
|
||||||
import getReadableErrorText from '../../util/getReadableErrorText';
|
import getReadableErrorText from '../../util/getReadableErrorText';
|
||||||
import { pick } from '../../util/iteratees';
|
import { pick } from '../../util/iteratees';
|
||||||
import useLang from '../../hooks/useLang';
|
|
||||||
import renderText from '../common/helpers/renderText';
|
import renderText from '../common/helpers/renderText';
|
||||||
|
import useLang from '../../hooks/useLang';
|
||||||
|
import useFlag from '../../hooks/useFlag';
|
||||||
|
|
||||||
import Modal from '../ui/Modal';
|
import Modal from '../ui/Modal';
|
||||||
import Button from '../ui/Button';
|
import Button from '../ui/Button';
|
||||||
@ -20,9 +21,16 @@ type StateProps = {
|
|||||||
|
|
||||||
const Dialogs: FC<StateProps> = ({ dialogs }) => {
|
const Dialogs: FC<StateProps> = ({ dialogs }) => {
|
||||||
const { dismissDialog, acceptInviteConfirmation } = getDispatch();
|
const { dismissDialog, acceptInviteConfirmation } = getDispatch();
|
||||||
|
const [isModalOpen, openModal, closeModal] = useFlag();
|
||||||
|
|
||||||
const lang = useLang();
|
const lang = useLang();
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (dialogs.length > 0) {
|
||||||
|
openModal();
|
||||||
|
}
|
||||||
|
}, [dialogs, openModal]);
|
||||||
|
|
||||||
if (!dialogs.length) {
|
if (!dialogs.length) {
|
||||||
return undefined;
|
return undefined;
|
||||||
}
|
}
|
||||||
@ -34,7 +42,7 @@ const Dialogs: FC<StateProps> = ({ dialogs }) => {
|
|||||||
<div className="modal-title">
|
<div className="modal-title">
|
||||||
{renderText(title)}
|
{renderText(title)}
|
||||||
</div>
|
</div>
|
||||||
<Button round color="translucent" size="smaller" ariaLabel={lang('Close')} onClick={dismissDialog}>
|
<Button round color="translucent" size="smaller" ariaLabel={lang('Close')} onClick={closeModal}>
|
||||||
<i className="icon-close" />
|
<i className="icon-close" />
|
||||||
</Button>
|
</Button>
|
||||||
</div>
|
</div>
|
||||||
@ -50,7 +58,7 @@ const Dialogs: FC<StateProps> = ({ dialogs }) => {
|
|||||||
acceptInviteConfirmation({
|
acceptInviteConfirmation({
|
||||||
hash,
|
hash,
|
||||||
});
|
});
|
||||||
dismissDialog();
|
closeModal();
|
||||||
};
|
};
|
||||||
|
|
||||||
const participantsText = isChannel
|
const participantsText = isChannel
|
||||||
@ -63,10 +71,11 @@ const Dialogs: FC<StateProps> = ({ dialogs }) => {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<Modal
|
<Modal
|
||||||
isOpen
|
isOpen={isModalOpen}
|
||||||
onClose={dismissDialog}
|
onClose={closeModal}
|
||||||
className="error"
|
className="error"
|
||||||
header={renderInviteHeader(title, photo)}
|
header={renderInviteHeader(title, photo)}
|
||||||
|
onCloseAnimationEnd={dismissDialog}
|
||||||
>
|
>
|
||||||
{about && <p className="modal-about">{renderText(about)}</p>}
|
{about && <p className="modal-about">{renderText(about)}</p>}
|
||||||
{participantsCount !== undefined && <p>{participantsText}</p>}
|
{participantsCount !== undefined && <p>{participantsText}</p>}
|
||||||
@ -80,7 +89,7 @@ const Dialogs: FC<StateProps> = ({ dialogs }) => {
|
|||||||
<Button isText className="confirm-dialog-button" onClick={handleJoinClick}>
|
<Button isText className="confirm-dialog-button" onClick={handleJoinClick}>
|
||||||
{isRequestNeeded ? requestToJoinText : joinText}
|
{isRequestNeeded ? requestToJoinText : joinText}
|
||||||
</Button>
|
</Button>
|
||||||
<Button isText className="confirm-dialog-button" onClick={dismissDialog}>{lang('Cancel')}</Button>
|
<Button isText className="confirm-dialog-button" onClick={closeModal}>{lang('Cancel')}</Button>
|
||||||
</Modal>
|
</Modal>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
@ -88,14 +97,15 @@ const Dialogs: FC<StateProps> = ({ dialogs }) => {
|
|||||||
const renderError = (error: ApiError) => {
|
const renderError = (error: ApiError) => {
|
||||||
return (
|
return (
|
||||||
<Modal
|
<Modal
|
||||||
isOpen
|
isOpen={isModalOpen}
|
||||||
onClose={dismissDialog}
|
onClose={closeModal}
|
||||||
|
onCloseAnimationEnd={dismissDialog}
|
||||||
className="error"
|
className="error"
|
||||||
title={getErrorHeader(error)}
|
title={getErrorHeader(error)}
|
||||||
>
|
>
|
||||||
{error.hasErrorKey ? getReadableErrorText(error) : renderText(error.message!, ['emoji', 'br'])}
|
{error.hasErrorKey ? getReadableErrorText(error) : renderText(error.message!, ['emoji', 'br'])}
|
||||||
<div>
|
<div>
|
||||||
<Button isText onClick={dismissDialog}>{lang('OK')}</Button>
|
<Button isText onClick={closeModal}>{lang('OK')}</Button>
|
||||||
</div>
|
</div>
|
||||||
</Modal>
|
</Modal>
|
||||||
);
|
);
|
||||||
@ -111,7 +121,7 @@ const Dialogs: FC<StateProps> = ({ dialogs }) => {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<div id="Dialogs">
|
<div id="Dialogs">
|
||||||
{dialogs.map(renderDialog)}
|
{Boolean(dialogs.length) && renderDialog(dialogs[dialogs.length - 1])}
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user