Middle Column: Fix closing chat by <Esc>
This commit is contained in:
parent
a17240466a
commit
ac02fa4a4f
@ -33,7 +33,7 @@ import { pick } from '../../util/iteratees';
|
|||||||
import buildClassName from '../../util/buildClassName';
|
import buildClassName from '../../util/buildClassName';
|
||||||
import useCustomBackground from '../../hooks/useCustomBackground';
|
import useCustomBackground from '../../hooks/useCustomBackground';
|
||||||
import useWindowSize from '../../hooks/useWindowSize';
|
import useWindowSize from '../../hooks/useWindowSize';
|
||||||
import usePrevForAnimation from '../../hooks/usePrevForAnimation';
|
import usePrevDuringAnimation from '../../hooks/usePrevDuringAnimation';
|
||||||
import calculateMiddleFooterTransforms from './helpers/calculateMiddleFooterTransforms';
|
import calculateMiddleFooterTransforms from './helpers/calculateMiddleFooterTransforms';
|
||||||
import useLang from '../../hooks/useLang';
|
import useLang from '../../hooks/useLang';
|
||||||
|
|
||||||
@ -103,10 +103,10 @@ const MiddleColumn: FC<StateProps & DispatchProps> = ({
|
|||||||
const [isFabShown, setIsFabShown] = useState(false);
|
const [isFabShown, setIsFabShown] = useState(false);
|
||||||
const [isUnpinModalOpen, setIsUnpinModalOpen] = useState(false);
|
const [isUnpinModalOpen, setIsUnpinModalOpen] = useState(false);
|
||||||
|
|
||||||
const renderingChatId = usePrevForAnimation(chatId, CLOSE_ANIMATION_DURATION);
|
const renderingChatId = usePrevDuringAnimation(chatId, CLOSE_ANIMATION_DURATION);
|
||||||
const renderingThreadId = usePrevForAnimation(threadId, CLOSE_ANIMATION_DURATION);
|
const renderingThreadId = usePrevDuringAnimation(threadId, CLOSE_ANIMATION_DURATION);
|
||||||
const renderingMessageListType = usePrevForAnimation(messageListType, CLOSE_ANIMATION_DURATION);
|
const renderingMessageListType = usePrevDuringAnimation(messageListType, CLOSE_ANIMATION_DURATION);
|
||||||
const renderingCanPost = usePrevForAnimation(canPost, CLOSE_ANIMATION_DURATION);
|
const renderingCanPost = usePrevDuringAnimation(canPost, CLOSE_ANIMATION_DURATION);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
return chatId
|
return chatId
|
||||||
|
|||||||
@ -12,7 +12,7 @@ import { pick } from '../../../util/iteratees';
|
|||||||
import parseMessageInput from './helpers/parseMessageInput';
|
import parseMessageInput from './helpers/parseMessageInput';
|
||||||
import useOnChange from '../../../hooks/useOnChange';
|
import useOnChange from '../../../hooks/useOnChange';
|
||||||
import useShowTransition from '../../../hooks/useShowTransition';
|
import useShowTransition from '../../../hooks/useShowTransition';
|
||||||
import usePrevForAnimation from '../../../hooks/usePrevForAnimation';
|
import useCurrentOrPrev from '../../../hooks/useCurrentOrPrev';
|
||||||
import buildClassName from '../../../util/buildClassName';
|
import buildClassName from '../../../util/buildClassName';
|
||||||
|
|
||||||
import WebPage from '../message/WebPage';
|
import WebPage from '../message/WebPage';
|
||||||
@ -79,7 +79,7 @@ const WebPagePreview: FC<OwnProps & StateProps & DispatchProps> = ({
|
|||||||
const isShown = Boolean(webPagePreview && messageText.length && !noWebPage && !disabled);
|
const isShown = Boolean(webPagePreview && messageText.length && !noWebPage && !disabled);
|
||||||
const { shouldRender, transitionClassNames } = useShowTransition(isShown);
|
const { shouldRender, transitionClassNames } = useShowTransition(isShown);
|
||||||
|
|
||||||
const renderingWebPage = usePrevForAnimation(webPagePreview);
|
const renderingWebPage = useCurrentOrPrev(webPagePreview);
|
||||||
|
|
||||||
if (!shouldRender || !renderingWebPage) {
|
if (!shouldRender || !renderingWebPage) {
|
||||||
return undefined;
|
return undefined;
|
||||||
|
|||||||
@ -4,7 +4,7 @@ import usePrevious from './usePrevious';
|
|||||||
import useForceUpdate from './useForceUpdate';
|
import useForceUpdate from './useForceUpdate';
|
||||||
import useOnChange from './useOnChange';
|
import useOnChange from './useOnChange';
|
||||||
|
|
||||||
export default function usePrevForAnimation(current: any, duration?: number) {
|
export default function usePrevDuringAnimation(current: any, duration?: number) {
|
||||||
const prev = usePrevious(current, true);
|
const prev = usePrevious(current, true);
|
||||||
const timeoutRef = useRef<number>();
|
const timeoutRef = useRef<number>();
|
||||||
const forceUpdate = useForceUpdate();
|
const forceUpdate = useForceUpdate();
|
||||||
@ -26,5 +26,5 @@ export default function usePrevForAnimation(current: any, duration?: number) {
|
|||||||
}
|
}
|
||||||
}, [current]);
|
}, [current]);
|
||||||
|
|
||||||
return isCurrentPresent || (duration && !timeoutRef.current) ? current : prev;
|
return !timeoutRef.current || !duration || isCurrentPresent ? current : prev;
|
||||||
}
|
}
|
||||||
Loading…
x
Reference in New Issue
Block a user