[Perf] Re-implement useShowTransition to avoid re-renders
f-u
This commit is contained in:
parent
9b5c527a8a
commit
63f1ca396d
@ -17,7 +17,7 @@ import { getSuggestedLanguage } from './helpers/getSuggestedLanguage';
|
|||||||
|
|
||||||
import useAsync from '../../hooks/useAsync';
|
import useAsync from '../../hooks/useAsync';
|
||||||
import useFlag from '../../hooks/useFlag';
|
import useFlag from '../../hooks/useFlag';
|
||||||
import useMediaTransition from '../../hooks/useMediaTransition';
|
import useMediaTransitionDeprecated from '../../hooks/useMediaTransitionDeprecated';
|
||||||
import useOldLang from '../../hooks/useOldLang';
|
import useOldLang from '../../hooks/useOldLang';
|
||||||
import useOldLangString from '../../hooks/useOldLangString';
|
import useOldLangString from '../../hooks/useOldLangString';
|
||||||
|
|
||||||
@ -90,7 +90,7 @@ const AuthCode: FC<StateProps> = ({
|
|||||||
});
|
});
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
const transitionClassNames = useMediaTransition(isQrMounted);
|
const transitionClassNames = useMediaTransitionDeprecated(isQrMounted);
|
||||||
|
|
||||||
useLayoutEffect(() => {
|
useLayoutEffect(() => {
|
||||||
if (!authQrCode || !qrCode) {
|
if (!authQrCode || !qrCode) {
|
||||||
|
|||||||
@ -12,7 +12,7 @@ import buildClassName from '../../../util/buildClassName';
|
|||||||
|
|
||||||
import useCurrentOrPrev from '../../../hooks/useCurrentOrPrev';
|
import useCurrentOrPrev from '../../../hooks/useCurrentOrPrev';
|
||||||
import useOldLang from '../../../hooks/useOldLang';
|
import useOldLang from '../../../hooks/useOldLang';
|
||||||
import useShowTransition from '../../../hooks/useShowTransition';
|
import useShowTransitionDeprecated from '../../../hooks/useShowTransitionDeprecated';
|
||||||
|
|
||||||
import AvatarList from '../../common/AvatarList';
|
import AvatarList from '../../common/AvatarList';
|
||||||
import Button from '../../ui/Button';
|
import Button from '../../ui/Button';
|
||||||
@ -89,7 +89,7 @@ const GroupCallTopPane: FC<OwnProps & StateProps> = ({
|
|||||||
const {
|
const {
|
||||||
shouldRender,
|
shouldRender,
|
||||||
transitionClassNames,
|
transitionClassNames,
|
||||||
} = useShowTransition(Boolean(groupCall && isActive));
|
} = useShowTransitionDeprecated(Boolean(groupCall && isActive));
|
||||||
|
|
||||||
const renderingParticipantCount = useCurrentOrPrev(groupCall?.participantsCount, true);
|
const renderingParticipantCount = useCurrentOrPrev(groupCall?.participantsCount, true);
|
||||||
const renderingFetchedParticipants = useCurrentOrPrev(fetchedParticipants, true);
|
const renderingFetchedParticipants = useCurrentOrPrev(fetchedParticipants, true);
|
||||||
|
|||||||
@ -6,7 +6,7 @@ import buildClassName from '../../util/buildClassName';
|
|||||||
|
|
||||||
import useFlag from '../../hooks/useFlag';
|
import useFlag from '../../hooks/useFlag';
|
||||||
import useLastCallback from '../../hooks/useLastCallback';
|
import useLastCallback from '../../hooks/useLastCallback';
|
||||||
import useMediaTransition from '../../hooks/useMediaTransition';
|
import useMediaTransitionDeprecated from '../../hooks/useMediaTransitionDeprecated';
|
||||||
|
|
||||||
import AnimatedSticker from './AnimatedSticker';
|
import AnimatedSticker from './AnimatedSticker';
|
||||||
|
|
||||||
@ -29,7 +29,7 @@ function AnimatedIcon(props: OwnProps) {
|
|||||||
...otherProps
|
...otherProps
|
||||||
} = props;
|
} = props;
|
||||||
const [isAnimationLoaded, markAnimationLoaded] = useFlag(false);
|
const [isAnimationLoaded, markAnimationLoaded] = useFlag(false);
|
||||||
const transitionClassNames = useMediaTransition(noTransition || isAnimationLoaded);
|
const transitionClassNames = useMediaTransitionDeprecated(noTransition || isAnimationLoaded);
|
||||||
|
|
||||||
const handleLoad = useLastCallback(() => {
|
const handleLoad = useLastCallback(() => {
|
||||||
markAnimationLoaded();
|
markAnimationLoaded();
|
||||||
|
|||||||
@ -7,7 +7,7 @@ import buildStyle from '../../util/buildStyle';
|
|||||||
|
|
||||||
import useFlag from '../../hooks/useFlag';
|
import useFlag from '../../hooks/useFlag';
|
||||||
import useLastCallback from '../../hooks/useLastCallback';
|
import useLastCallback from '../../hooks/useLastCallback';
|
||||||
import useMediaTransition from '../../hooks/useMediaTransition';
|
import useMediaTransitionDeprecated from '../../hooks/useMediaTransitionDeprecated';
|
||||||
|
|
||||||
import AnimatedIcon from './AnimatedIcon';
|
import AnimatedIcon from './AnimatedIcon';
|
||||||
|
|
||||||
@ -27,10 +27,10 @@ function AnimatedIconWithPreview(props: OwnProps) {
|
|||||||
} = props;
|
} = props;
|
||||||
|
|
||||||
const [isThumbOpen, , unmarkThumbOpen] = useFlag(Boolean(thumbDataUri));
|
const [isThumbOpen, , unmarkThumbOpen] = useFlag(Boolean(thumbDataUri));
|
||||||
const thumbClassNames = useMediaTransition(isThumbOpen);
|
const thumbClassNames = useMediaTransitionDeprecated(isThumbOpen);
|
||||||
|
|
||||||
const [isPreviewOpen, markPreviewOpen, unmarkPreviewOpen] = useFlag(loadedPreviewUrls.has(previewUrl));
|
const [isPreviewOpen, markPreviewOpen, unmarkPreviewOpen] = useFlag(loadedPreviewUrls.has(previewUrl));
|
||||||
const previewClassNames = useMediaTransition(isPreviewOpen);
|
const previewClassNames = useMediaTransitionDeprecated(isPreviewOpen);
|
||||||
|
|
||||||
const [isAnimationReady, markAnimationReady] = useFlag(false);
|
const [isAnimationReady, markAnimationReady] = useFlag(false);
|
||||||
|
|
||||||
|
|||||||
@ -38,7 +38,7 @@ import useLastCallback from '../../hooks/useLastCallback';
|
|||||||
import useMedia from '../../hooks/useMedia';
|
import useMedia from '../../hooks/useMedia';
|
||||||
import useMediaWithLoadProgress from '../../hooks/useMediaWithLoadProgress';
|
import useMediaWithLoadProgress from '../../hooks/useMediaWithLoadProgress';
|
||||||
import useOldLang from '../../hooks/useOldLang';
|
import useOldLang from '../../hooks/useOldLang';
|
||||||
import useShowTransition from '../../hooks/useShowTransition';
|
import useShowTransitionDeprecated from '../../hooks/useShowTransitionDeprecated';
|
||||||
|
|
||||||
import Button from '../ui/Button';
|
import Button from '../ui/Button';
|
||||||
import Link from '../ui/Link';
|
import Link from '../ui/Link';
|
||||||
@ -213,7 +213,7 @@ const Audio: FC<OwnProps> = ({
|
|||||||
const {
|
const {
|
||||||
shouldRender: shouldRenderSpinner,
|
shouldRender: shouldRenderSpinner,
|
||||||
transitionClassNames: spinnerClassNames,
|
transitionClassNames: spinnerClassNames,
|
||||||
} = useShowTransition(isTransferring);
|
} = useShowTransitionDeprecated(isTransferring);
|
||||||
|
|
||||||
const shouldRenderCross = shouldRenderSpinner && (isLoadingForPlaying || isUploading);
|
const shouldRenderCross = shouldRenderSpinner && (isLoadingForPlaying || isUploading);
|
||||||
|
|
||||||
|
|||||||
@ -34,7 +34,7 @@ import renderText from './helpers/renderText';
|
|||||||
import { useFastClick } from '../../hooks/useFastClick';
|
import { useFastClick } from '../../hooks/useFastClick';
|
||||||
import useLastCallback from '../../hooks/useLastCallback';
|
import useLastCallback from '../../hooks/useLastCallback';
|
||||||
import useMedia from '../../hooks/useMedia';
|
import useMedia from '../../hooks/useMedia';
|
||||||
import useMediaTransition from '../../hooks/useMediaTransition';
|
import useMediaTransitionDeprecated from '../../hooks/useMediaTransitionDeprecated';
|
||||||
import useOldLang from '../../hooks/useOldLang';
|
import useOldLang from '../../hooks/useOldLang';
|
||||||
|
|
||||||
import OptimizedVideo from '../ui/OptimizedVideo';
|
import OptimizedVideo from '../ui/OptimizedVideo';
|
||||||
@ -160,7 +160,7 @@ const Avatar: FC<OwnProps> = ({
|
|||||||
// `videoBlobUrl` can be taken from memory cache, so we need to check `shouldLoadVideo` again
|
// `videoBlobUrl` can be taken from memory cache, so we need to check `shouldLoadVideo` again
|
||||||
const shouldPlayVideo = Boolean(videoBlobUrl && shouldLoadVideo);
|
const shouldPlayVideo = Boolean(videoBlobUrl && shouldLoadVideo);
|
||||||
|
|
||||||
const transitionClassNames = useMediaTransition(hasBlobUrl);
|
const transitionClassNames = useMediaTransitionDeprecated(hasBlobUrl);
|
||||||
|
|
||||||
const handleVideoEnded = useLastCallback((e) => {
|
const handleVideoEnded = useLastCallback((e) => {
|
||||||
const video = e.currentTarget;
|
const video = e.currentTarget;
|
||||||
|
|||||||
@ -124,7 +124,7 @@ import useOldLang from '../../hooks/useOldLang';
|
|||||||
import usePreviousDeprecated from '../../hooks/usePreviousDeprecated';
|
import usePreviousDeprecated from '../../hooks/usePreviousDeprecated';
|
||||||
import useSchedule from '../../hooks/useSchedule';
|
import useSchedule from '../../hooks/useSchedule';
|
||||||
import useSendMessageAction from '../../hooks/useSendMessageAction';
|
import useSendMessageAction from '../../hooks/useSendMessageAction';
|
||||||
import useShowTransition from '../../hooks/useShowTransition';
|
import useShowTransitionDeprecated from '../../hooks/useShowTransitionDeprecated';
|
||||||
import { useStateRef } from '../../hooks/useStateRef';
|
import { useStateRef } from '../../hooks/useStateRef';
|
||||||
import useSyncEffect from '../../hooks/useSyncEffect';
|
import useSyncEffect from '../../hooks/useSyncEffect';
|
||||||
import useAttachmentModal from '../middle/composer/hooks/useAttachmentModal';
|
import useAttachmentModal from '../middle/composer/hooks/useAttachmentModal';
|
||||||
@ -1425,7 +1425,7 @@ const Composer: FC<OwnProps & StateProps> = ({
|
|||||||
const {
|
const {
|
||||||
shouldRender: shouldRenderReactionSelector,
|
shouldRender: shouldRenderReactionSelector,
|
||||||
transitionClassNames: reactionSelectorTransitonClassNames,
|
transitionClassNames: reactionSelectorTransitonClassNames,
|
||||||
} = useShowTransition(isReactionSelectorOpen);
|
} = useShowTransitionDeprecated(isReactionSelectorOpen);
|
||||||
const areVoiceMessagesNotAllowed = mainButtonState === MainButtonState.Record
|
const areVoiceMessagesNotAllowed = mainButtonState === MainButtonState.Record
|
||||||
&& (!canAttachMedia || !canSendVoiceByPrivacy || !canSendVoices);
|
&& (!canAttachMedia || !canSendVoiceByPrivacy || !canSendVoices);
|
||||||
|
|
||||||
|
|||||||
@ -14,9 +14,9 @@ import renderText from './helpers/renderText';
|
|||||||
|
|
||||||
import useAppLayout from '../../hooks/useAppLayout';
|
import useAppLayout from '../../hooks/useAppLayout';
|
||||||
import useCanvasBlur from '../../hooks/useCanvasBlur';
|
import useCanvasBlur from '../../hooks/useCanvasBlur';
|
||||||
import useMediaTransition from '../../hooks/useMediaTransition';
|
import useMediaTransitionDeprecated from '../../hooks/useMediaTransitionDeprecated';
|
||||||
import useOldLang from '../../hooks/useOldLang';
|
import useOldLang from '../../hooks/useOldLang';
|
||||||
import useShowTransition from '../../hooks/useShowTransition';
|
import useShowTransitionDeprecated from '../../hooks/useShowTransitionDeprecated';
|
||||||
|
|
||||||
import Link from '../ui/Link';
|
import Link from '../ui/Link';
|
||||||
import ProgressSpinner from '../ui/ProgressSpinner';
|
import ProgressSpinner from '../ui/ProgressSpinner';
|
||||||
@ -75,12 +75,12 @@ const File: FC<OwnProps> = ({
|
|||||||
const [withThumb] = useState(!previewData);
|
const [withThumb] = useState(!previewData);
|
||||||
const noThumb = Boolean(previewData);
|
const noThumb = Boolean(previewData);
|
||||||
const thumbRef = useCanvasBlur(thumbnailDataUri, noThumb, isMobile && !IS_CANVAS_FILTER_SUPPORTED);
|
const thumbRef = useCanvasBlur(thumbnailDataUri, noThumb, isMobile && !IS_CANVAS_FILTER_SUPPORTED);
|
||||||
const thumbClassNames = useMediaTransition(!noThumb);
|
const thumbClassNames = useMediaTransitionDeprecated(!noThumb);
|
||||||
|
|
||||||
const {
|
const {
|
||||||
shouldRender: shouldSpinnerRender,
|
shouldRender: shouldSpinnerRender,
|
||||||
transitionClassNames: spinnerClassNames,
|
transitionClassNames: spinnerClassNames,
|
||||||
} = useShowTransition(isTransferring, undefined, true);
|
} = useShowTransitionDeprecated(isTransferring, undefined, true);
|
||||||
|
|
||||||
const color = getColorFromExtension(extension);
|
const color = getColorFromExtension(extension);
|
||||||
const sizeString = getFileSizeString(size);
|
const sizeString = getFileSizeString(size);
|
||||||
|
|||||||
@ -19,7 +19,7 @@ import useFlag from '../../hooks/useFlag';
|
|||||||
import { useIsIntersecting } from '../../hooks/useIntersectionObserver';
|
import { useIsIntersecting } from '../../hooks/useIntersectionObserver';
|
||||||
import useLastCallback from '../../hooks/useLastCallback';
|
import useLastCallback from '../../hooks/useLastCallback';
|
||||||
import useMedia from '../../hooks/useMedia';
|
import useMedia from '../../hooks/useMedia';
|
||||||
import useMediaTransition from '../../hooks/useMediaTransition';
|
import useMediaTransitionDeprecated from '../../hooks/useMediaTransitionDeprecated';
|
||||||
|
|
||||||
import MediaSpoiler from './MediaSpoiler';
|
import MediaSpoiler from './MediaSpoiler';
|
||||||
|
|
||||||
@ -46,7 +46,7 @@ const Media: FC<OwnProps> = ({
|
|||||||
const isIntersecting = useIsIntersecting(ref, observeIntersection);
|
const isIntersecting = useIsIntersecting(ref, observeIntersection);
|
||||||
const thumbDataUri = getMessageMediaThumbDataUri(message);
|
const thumbDataUri = getMessageMediaThumbDataUri(message);
|
||||||
const mediaBlobUrl = useMedia(getMessageMediaHash(message, 'pictogram'), !isIntersecting);
|
const mediaBlobUrl = useMedia(getMessageMediaHash(message, 'pictogram'), !isIntersecting);
|
||||||
const transitionClassNames = useMediaTransition(mediaBlobUrl);
|
const transitionClassNames = useMediaTransitionDeprecated(mediaBlobUrl);
|
||||||
|
|
||||||
const video = getMessageVideo(message);
|
const video = getMessageVideo(message);
|
||||||
|
|
||||||
|
|||||||
@ -6,7 +6,7 @@ import buildClassName from '../../util/buildClassName';
|
|||||||
|
|
||||||
import useCanvasBlur from '../../hooks/useCanvasBlur';
|
import useCanvasBlur from '../../hooks/useCanvasBlur';
|
||||||
import useLastCallback from '../../hooks/useLastCallback';
|
import useLastCallback from '../../hooks/useLastCallback';
|
||||||
import useShowTransition from '../../hooks/useShowTransition';
|
import useShowTransitionDeprecated from '../../hooks/useShowTransitionDeprecated';
|
||||||
|
|
||||||
import styles from './MediaSpoiler.module.scss';
|
import styles from './MediaSpoiler.module.scss';
|
||||||
|
|
||||||
@ -33,7 +33,7 @@ const MediaSpoiler: FC<OwnProps> = ({
|
|||||||
// eslint-disable-next-line no-null/no-null
|
// eslint-disable-next-line no-null/no-null
|
||||||
const ref = useRef<HTMLDivElement>(null);
|
const ref = useRef<HTMLDivElement>(null);
|
||||||
|
|
||||||
const { shouldRender, transitionClassNames } = useShowTransition(
|
const { shouldRender, transitionClassNames } = useShowTransitionDeprecated(
|
||||||
isVisible, undefined, true, withAnimation ? false : undefined, undefined, ANIMATION_DURATION,
|
isVisible, undefined, true, withAnimation ? false : undefined, undefined, ANIMATION_DURATION,
|
||||||
);
|
);
|
||||||
const canvasRef = useCanvasBlur(thumbDataUri, !shouldRender, undefined, BLUR_RADIUS, width, height);
|
const canvasRef = useCanvasBlur(thumbDataUri, !shouldRender, undefined, BLUR_RADIUS, width, height);
|
||||||
|
|||||||
@ -5,7 +5,7 @@ import buildClassName from '../../util/buildClassName';
|
|||||||
import renderText from './helpers/renderText';
|
import renderText from './helpers/renderText';
|
||||||
|
|
||||||
import useOldLang from '../../hooks/useOldLang';
|
import useOldLang from '../../hooks/useOldLang';
|
||||||
import useShowTransition from '../../hooks/useShowTransition';
|
import useShowTransitionDeprecated from '../../hooks/useShowTransitionDeprecated';
|
||||||
|
|
||||||
import './NothingFound.scss';
|
import './NothingFound.scss';
|
||||||
|
|
||||||
@ -18,7 +18,7 @@ const DEFAULT_TEXT = 'Nothing found.';
|
|||||||
|
|
||||||
const NothingFound: FC<OwnProps> = ({ text = DEFAULT_TEXT, description }) => {
|
const NothingFound: FC<OwnProps> = ({ text = DEFAULT_TEXT, description }) => {
|
||||||
const lang = useOldLang();
|
const lang = useOldLang();
|
||||||
const { transitionClassNames } = useShowTransition(true);
|
const { transitionClassNames } = useShowTransitionDeprecated(true);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className={buildClassName('NothingFound', transitionClassNames, description && 'with-description')}>
|
<div className={buildClassName('NothingFound', transitionClassNames, description && 'with-description')}>
|
||||||
|
|||||||
@ -14,7 +14,7 @@ import stopEvent from '../../util/stopEvent';
|
|||||||
import { useIsIntersecting } from '../../hooks/useIntersectionObserver';
|
import { useIsIntersecting } from '../../hooks/useIntersectionObserver';
|
||||||
import useLastCallback from '../../hooks/useLastCallback';
|
import useLastCallback from '../../hooks/useLastCallback';
|
||||||
import useMedia from '../../hooks/useMedia';
|
import useMedia from '../../hooks/useMedia';
|
||||||
import useMediaTransition from '../../hooks/useMediaTransition';
|
import useMediaTransitionDeprecated from '../../hooks/useMediaTransitionDeprecated';
|
||||||
|
|
||||||
import './Media.scss';
|
import './Media.scss';
|
||||||
|
|
||||||
@ -42,7 +42,7 @@ const PreviewMedia: FC<OwnProps> = ({
|
|||||||
const thumbDataUri = getMessageMediaThumbDataUri(media);
|
const thumbDataUri = getMessageMediaThumbDataUri(media);
|
||||||
|
|
||||||
const mediaBlobUrl = useMedia(getMessageMediaHash(media, 'preview'), !isIntersecting);
|
const mediaBlobUrl = useMedia(getMessageMediaHash(media, 'preview'), !isIntersecting);
|
||||||
const transitionClassNames = useMediaTransition(mediaBlobUrl);
|
const transitionClassNames = useMediaTransitionDeprecated(mediaBlobUrl);
|
||||||
|
|
||||||
const video = media.content.video;
|
const video = media.content.video;
|
||||||
|
|
||||||
|
|||||||
@ -27,7 +27,7 @@ import useAppLayout from '../../hooks/useAppLayout';
|
|||||||
import useCanvasBlur from '../../hooks/useCanvasBlur';
|
import useCanvasBlur from '../../hooks/useCanvasBlur';
|
||||||
import useFlag from '../../hooks/useFlag';
|
import useFlag from '../../hooks/useFlag';
|
||||||
import useMedia from '../../hooks/useMedia';
|
import useMedia from '../../hooks/useMedia';
|
||||||
import useMediaTransition from '../../hooks/useMediaTransition';
|
import useMediaTransitionDeprecated from '../../hooks/useMediaTransitionDeprecated';
|
||||||
import useOldLang from '../../hooks/useOldLang';
|
import useOldLang from '../../hooks/useOldLang';
|
||||||
|
|
||||||
import OptimizedVideo from '../ui/OptimizedVideo';
|
import OptimizedVideo from '../ui/OptimizedVideo';
|
||||||
@ -82,7 +82,7 @@ const ProfilePhoto: FC<OwnProps> = ({
|
|||||||
const fullMediaData = videoBlobUrl || photoBlobUrl;
|
const fullMediaData = videoBlobUrl || photoBlobUrl;
|
||||||
const [isVideoReady, markVideoReady] = useFlag();
|
const [isVideoReady, markVideoReady] = useFlag();
|
||||||
const isFullMediaReady = Boolean(fullMediaData && (!isVideo || isVideoReady));
|
const isFullMediaReady = Boolean(fullMediaData && (!isVideo || isVideoReady));
|
||||||
const transitionClassNames = useMediaTransition(isFullMediaReady);
|
const transitionClassNames = useMediaTransitionDeprecated(isFullMediaReady);
|
||||||
const isBlurredThumb = canHaveMedia && !isFullMediaReady && !previewBlobUrl && photo?.thumbnail?.dataUri;
|
const isBlurredThumb = canHaveMedia && !isFullMediaReady && !previewBlobUrl && photo?.thumbnail?.dataUri;
|
||||||
const blurredThumbCanvasRef = useCanvasBlur(
|
const blurredThumbCanvasRef = useCanvasBlur(
|
||||||
photo?.thumbnail?.dataUri, !isBlurredThumb, isMobile && !IS_CANVAS_FILTER_SUPPORTED,
|
photo?.thumbnail?.dataUri, !isBlurredThumb, isMobile && !IS_CANVAS_FILTER_SUPPORTED,
|
||||||
|
|||||||
@ -13,7 +13,7 @@ import buildClassName from '../../util/buildClassName';
|
|||||||
import useCoordsInSharedCanvas from '../../hooks/useCoordsInSharedCanvas';
|
import useCoordsInSharedCanvas from '../../hooks/useCoordsInSharedCanvas';
|
||||||
import useLastCallback from '../../hooks/useLastCallback';
|
import useLastCallback from '../../hooks/useLastCallback';
|
||||||
import useMedia from '../../hooks/useMedia';
|
import useMedia from '../../hooks/useMedia';
|
||||||
import useMediaTransition from '../../hooks/useMediaTransition';
|
import useMediaTransitionDeprecated from '../../hooks/useMediaTransitionDeprecated';
|
||||||
|
|
||||||
import AnimatedIconWithPreview from './AnimatedIconWithPreview';
|
import AnimatedIconWithPreview from './AnimatedIconWithPreview';
|
||||||
import CustomEmoji from './CustomEmoji';
|
import CustomEmoji from './CustomEmoji';
|
||||||
@ -61,7 +61,7 @@ const ReactionEmoji: FC<OwnProps> = ({
|
|||||||
onClick(reaction);
|
onClick(reaction);
|
||||||
});
|
});
|
||||||
|
|
||||||
const transitionClassNames = useMediaTransition(mediaData);
|
const transitionClassNames = useMediaTransitionDeprecated(mediaData);
|
||||||
const fullClassName = buildClassName(
|
const fullClassName = buildClassName(
|
||||||
styles.root,
|
styles.root,
|
||||||
isSelected && styles.selected,
|
isSelected && styles.selected,
|
||||||
|
|||||||
@ -9,7 +9,7 @@ import { isSameReaction } from '../../global/helpers';
|
|||||||
import buildClassName from '../../util/buildClassName';
|
import buildClassName from '../../util/buildClassName';
|
||||||
|
|
||||||
import useMedia from '../../hooks/useMedia';
|
import useMedia from '../../hooks/useMedia';
|
||||||
import useMediaTransition from '../../hooks/useMediaTransition';
|
import useMediaTransitionDeprecated from '../../hooks/useMediaTransitionDeprecated';
|
||||||
|
|
||||||
import CustomEmoji from './CustomEmoji';
|
import CustomEmoji from './CustomEmoji';
|
||||||
|
|
||||||
@ -41,7 +41,7 @@ const ReactionStaticEmoji: FC<OwnProps> = ({
|
|||||||
const staticIconId = availableReaction?.staticIcon?.id;
|
const staticIconId = availableReaction?.staticIcon?.id;
|
||||||
const mediaData = useMedia(`document${staticIconId}`, !staticIconId, ApiMediaFormat.BlobUrl);
|
const mediaData = useMedia(`document${staticIconId}`, !staticIconId, ApiMediaFormat.BlobUrl);
|
||||||
|
|
||||||
const transitionClassNames = useMediaTransition(mediaData);
|
const transitionClassNames = useMediaTransitionDeprecated(mediaData);
|
||||||
|
|
||||||
const shouldApplySizeFix = 'emoticon' in reaction && reaction.emoticon === '🦄';
|
const shouldApplySizeFix = 'emoticon' in reaction && reaction.emoticon === '🦄';
|
||||||
const shouldReplaceWithHeartIcon = withIconHeart && 'emoticon' in reaction && reaction.emoticon === '❤';
|
const shouldReplaceWithHeartIcon = withIconHeart && 'emoticon' in reaction && reaction.emoticon === '❤';
|
||||||
|
|||||||
@ -27,7 +27,7 @@ import useAppLayout from '../../hooks/useAppLayout';
|
|||||||
import useFlag from '../../hooks/useFlag';
|
import useFlag from '../../hooks/useFlag';
|
||||||
import { useIsIntersecting } from '../../hooks/useIntersectionObserver';
|
import { useIsIntersecting } from '../../hooks/useIntersectionObserver';
|
||||||
import useLastCallback from '../../hooks/useLastCallback';
|
import useLastCallback from '../../hooks/useLastCallback';
|
||||||
import useMediaTransition from '../../hooks/useMediaTransition';
|
import useMediaTransitionDeprecated from '../../hooks/useMediaTransitionDeprecated';
|
||||||
import useOldLang from '../../hooks/useOldLang';
|
import useOldLang from '../../hooks/useOldLang';
|
||||||
import useResizeObserver from '../../hooks/useResizeObserver';
|
import useResizeObserver from '../../hooks/useResizeObserver';
|
||||||
import useWindowSize from '../../hooks/window/useWindowSize';
|
import useWindowSize from '../../hooks/window/useWindowSize';
|
||||||
@ -138,7 +138,7 @@ const StickerSet: FC<OwnProps> = ({
|
|||||||
const [itemsPerRow, setItemsPerRow] = useState(getItemsPerRowFallback(windowWidth));
|
const [itemsPerRow, setItemsPerRow] = useState(getItemsPerRowFallback(windowWidth));
|
||||||
|
|
||||||
const isIntersecting = useIsIntersecting(ref, observeIntersection ?? observeIntersectionForShowingItems);
|
const isIntersecting = useIsIntersecting(ref, observeIntersection ?? observeIntersectionForShowingItems);
|
||||||
const transitionClassNames = useMediaTransition(isIntersecting);
|
const transitionClassNames = useMediaTransitionDeprecated(isIntersecting);
|
||||||
|
|
||||||
// `isNearActive` is set in advance during animation, but it is not reliable for short sets
|
// `isNearActive` is set in advance during animation, but it is not reliable for short sets
|
||||||
const shouldRender = isNearActive || isIntersecting;
|
const shouldRender = isNearActive || isIntersecting;
|
||||||
|
|||||||
@ -123,9 +123,13 @@ const StickerView: FC<OwnProps> = ({
|
|||||||
const thumbData = cachedPreview || previewMediaData || thumbDataUri;
|
const thumbData = cachedPreview || previewMediaData || thumbDataUri;
|
||||||
const isThumbOpaque = sharedCanvasRef && !withTranslucentThumb;
|
const isThumbOpaque = sharedCanvasRef && !withTranslucentThumb;
|
||||||
|
|
||||||
const thumbClassNames = useMediaTransition(thumbData && !isFullMediaReady);
|
const noCrossTransition = Boolean(isLottie && withPreview);
|
||||||
const fullMediaClassNames = useMediaTransition(isFullMediaReady);
|
const thumbRef = useMediaTransition<HTMLImageElement>(thumbData && !isFullMediaReady, {
|
||||||
const noTransition = isLottie && withPreview;
|
noCloseTransition: noCrossTransition,
|
||||||
|
});
|
||||||
|
const fullMediaRef = useMediaTransition<HTMLElement>(isFullMediaReady, {
|
||||||
|
noOpenTransition: noCrossTransition,
|
||||||
|
});
|
||||||
|
|
||||||
const coords = useCoordsInSharedCanvas(containerRef, sharedCanvasRef);
|
const coords = useCoordsInSharedCanvas(containerRef, sharedCanvasRef);
|
||||||
|
|
||||||
@ -144,13 +148,13 @@ const StickerView: FC<OwnProps> = ({
|
|||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<img
|
<img
|
||||||
|
ref={thumbRef}
|
||||||
src={thumbData}
|
src={thumbData}
|
||||||
className={buildClassName(
|
className={buildClassName(
|
||||||
styles.thumb,
|
styles.thumb,
|
||||||
noTransition && styles.noTransition,
|
noCrossTransition && styles.noTransition,
|
||||||
isThumbOpaque && styles.thumbOpaque,
|
isThumbOpaque && styles.thumbOpaque,
|
||||||
thumbClassName,
|
thumbClassName,
|
||||||
thumbClassNames,
|
|
||||||
'sticker-media',
|
'sticker-media',
|
||||||
)}
|
)}
|
||||||
alt=""
|
alt=""
|
||||||
@ -158,14 +162,14 @@ const StickerView: FC<OwnProps> = ({
|
|||||||
/>
|
/>
|
||||||
{shouldRenderFullMedia && (isLottie ? (
|
{shouldRenderFullMedia && (isLottie ? (
|
||||||
<AnimatedSticker
|
<AnimatedSticker
|
||||||
|
ref={fullMediaRef as React.RefObject<HTMLDivElement>}
|
||||||
key={renderId}
|
key={renderId}
|
||||||
renderId={renderId}
|
renderId={renderId}
|
||||||
size={size}
|
size={size}
|
||||||
className={buildClassName(
|
className={buildClassName(
|
||||||
styles.media,
|
styles.media,
|
||||||
(noTransition || isThumbOpaque) && styles.noTransition,
|
(noCrossTransition || isThumbOpaque) && styles.noTransition,
|
||||||
fullMediaClassName,
|
fullMediaClassName,
|
||||||
fullMediaClassNames,
|
|
||||||
)}
|
)}
|
||||||
tgsUrl={fullMediaData}
|
tgsUrl={fullMediaData}
|
||||||
play={shouldPlay}
|
play={shouldPlay}
|
||||||
@ -182,8 +186,9 @@ const StickerView: FC<OwnProps> = ({
|
|||||||
/>
|
/>
|
||||||
) : isVideo ? (
|
) : isVideo ? (
|
||||||
<OptimizedVideo
|
<OptimizedVideo
|
||||||
|
ref={fullMediaRef as React.RefObject<HTMLVideoElement>}
|
||||||
canPlay={shouldPlay}
|
canPlay={shouldPlay}
|
||||||
className={buildClassName(styles.media, fullMediaClassName, fullMediaClassNames, 'sticker-media')}
|
className={buildClassName(styles.media, fullMediaClassName, 'sticker-media')}
|
||||||
src={fullMediaData}
|
src={fullMediaData}
|
||||||
playsInline
|
playsInline
|
||||||
muted
|
muted
|
||||||
@ -197,7 +202,8 @@ const StickerView: FC<OwnProps> = ({
|
|||||||
/>
|
/>
|
||||||
) : (
|
) : (
|
||||||
<img
|
<img
|
||||||
className={buildClassName(styles.media, fullMediaClassName, fullMediaClassNames, 'sticker-media')}
|
ref={fullMediaRef as React.RefObject<HTMLImageElement>}
|
||||||
|
className={buildClassName(styles.media, fullMediaClassName, 'sticker-media')}
|
||||||
src={fullMediaData}
|
src={fullMediaData}
|
||||||
alt={emoji}
|
alt={emoji}
|
||||||
style={filterStyle}
|
style={filterStyle}
|
||||||
|
|||||||
@ -17,7 +17,7 @@ import { pause } from '../../util/schedulers';
|
|||||||
|
|
||||||
import useEffectOnce from '../../hooks/useEffectOnce';
|
import useEffectOnce from '../../hooks/useEffectOnce';
|
||||||
import useFlag from '../../hooks/useFlag';
|
import useFlag from '../../hooks/useFlag';
|
||||||
import useShowTransition from '../../hooks/useShowTransition';
|
import useShowTransitionDeprecated from '../../hooks/useShowTransitionDeprecated';
|
||||||
|
|
||||||
// Workaround for incorrect bundling by Webpack: force including in the main chunk
|
// Workaround for incorrect bundling by Webpack: force including in the main chunk
|
||||||
import '../ui/Modal.scss';
|
import '../ui/Modal.scss';
|
||||||
@ -110,7 +110,7 @@ const UiLoader: FC<OwnProps & StateProps> = ({
|
|||||||
const [isReady, markReady] = useFlag();
|
const [isReady, markReady] = useFlag();
|
||||||
const {
|
const {
|
||||||
shouldRender: shouldRenderMask, transitionClassNames,
|
shouldRender: shouldRenderMask, transitionClassNames,
|
||||||
} = useShowTransition(!isReady, undefined, true);
|
} = useShowTransitionDeprecated(!isReady, undefined, true);
|
||||||
|
|
||||||
useEffectOnce(() => {
|
useEffectOnce(() => {
|
||||||
let timeout: number | undefined;
|
let timeout: number | undefined;
|
||||||
|
|||||||
@ -16,7 +16,7 @@ import useFlag from '../../../hooks/useFlag';
|
|||||||
import { useIsIntersecting } from '../../../hooks/useIntersectionObserver';
|
import { useIsIntersecting } from '../../../hooks/useIntersectionObserver';
|
||||||
import useLastCallback from '../../../hooks/useLastCallback';
|
import useLastCallback from '../../../hooks/useLastCallback';
|
||||||
import useMedia from '../../../hooks/useMedia';
|
import useMedia from '../../../hooks/useMedia';
|
||||||
import useShowTransition from '../../../hooks/useShowTransition';
|
import useShowTransitionDeprecated from '../../../hooks/useShowTransitionDeprecated';
|
||||||
import useCustomEmoji from '../hooks/useCustomEmoji';
|
import useCustomEmoji from '../hooks/useCustomEmoji';
|
||||||
|
|
||||||
import AnimatedSticker from '../AnimatedSticker';
|
import AnimatedSticker from '../AnimatedSticker';
|
||||||
@ -125,11 +125,11 @@ const ReactionAnimatedEmoji = ({
|
|||||||
const {
|
const {
|
||||||
shouldRender: shouldRenderEffect,
|
shouldRender: shouldRenderEffect,
|
||||||
transitionClassNames: animationClassNames,
|
transitionClassNames: animationClassNames,
|
||||||
} = useShowTransition(shouldPlayEffect, undefined, true, 'slow');
|
} = useShowTransitionDeprecated(shouldPlayEffect, undefined, true, 'slow');
|
||||||
const {
|
const {
|
||||||
shouldRender: shouldRenderCenter,
|
shouldRender: shouldRenderCenter,
|
||||||
transitionClassNames: centerAnimationClassNames,
|
transitionClassNames: centerAnimationClassNames,
|
||||||
} = useShowTransition(shouldPlayCenter, undefined, true, 'slow');
|
} = useShowTransitionDeprecated(shouldPlayCenter, undefined, true, 'slow');
|
||||||
|
|
||||||
const handleEnded = useLastCallback(() => {
|
const handleEnded = useLastCallback(() => {
|
||||||
stopActiveReaction({ containerId, reaction });
|
stopActiveReaction({ containerId, reaction });
|
||||||
@ -140,7 +140,7 @@ const ReactionAnimatedEmoji = ({
|
|||||||
const {
|
const {
|
||||||
shouldRender: shouldRenderStatic,
|
shouldRender: shouldRenderStatic,
|
||||||
transitionClassNames: staticClassNames,
|
transitionClassNames: staticClassNames,
|
||||||
} = useShowTransition(shouldShowStatic, undefined, true);
|
} = useShowTransitionDeprecated(shouldShowStatic, undefined, true);
|
||||||
|
|
||||||
const rootClassName = buildClassName(
|
const rootClassName = buildClassName(
|
||||||
styles.root,
|
styles.root,
|
||||||
|
|||||||
@ -14,7 +14,7 @@ import useForumPanelRender from '../../hooks/useForumPanelRender';
|
|||||||
import useHistoryBack from '../../hooks/useHistoryBack';
|
import useHistoryBack from '../../hooks/useHistoryBack';
|
||||||
import useLastCallback from '../../hooks/useLastCallback';
|
import useLastCallback from '../../hooks/useLastCallback';
|
||||||
import useOldLang from '../../hooks/useOldLang';
|
import useOldLang from '../../hooks/useOldLang';
|
||||||
import useShowTransition from '../../hooks/useShowTransition';
|
import useShowTransitionDeprecated from '../../hooks/useShowTransitionDeprecated';
|
||||||
import useLeftHeaderButtonRtlForumTransition from './main/hooks/useLeftHeaderButtonRtlForumTransition';
|
import useLeftHeaderButtonRtlForumTransition from './main/hooks/useLeftHeaderButtonRtlForumTransition';
|
||||||
|
|
||||||
import StoryRibbon from '../story/StoryRibbon';
|
import StoryRibbon from '../story/StoryRibbon';
|
||||||
@ -70,7 +70,7 @@ const ArchivedChats: FC<OwnProps> = ({
|
|||||||
const {
|
const {
|
||||||
shouldRender: shouldRenderTitle,
|
shouldRender: shouldRenderTitle,
|
||||||
transitionClassNames: titleClassNames,
|
transitionClassNames: titleClassNames,
|
||||||
} = useShowTransition(!isForumPanelOpen);
|
} = useShowTransitionDeprecated(!isForumPanelOpen);
|
||||||
|
|
||||||
const {
|
const {
|
||||||
shouldRenderForumPanel, handleForumPanelAnimationEnd,
|
shouldRenderForumPanel, handleForumPanelAnimationEnd,
|
||||||
@ -82,7 +82,9 @@ const ArchivedChats: FC<OwnProps> = ({
|
|||||||
shouldRender: shouldRenderStoryRibbon,
|
shouldRender: shouldRenderStoryRibbon,
|
||||||
transitionClassNames: storyRibbonClassNames,
|
transitionClassNames: storyRibbonClassNames,
|
||||||
isClosing: isStoryRibbonClosing,
|
isClosing: isStoryRibbonClosing,
|
||||||
} = useShowTransition(isStoryRibbonShown, undefined, undefined, '', false, ANIMATION_DURATION + ANIMATION_END_DELAY);
|
} = useShowTransitionDeprecated(
|
||||||
|
isStoryRibbonShown, undefined, undefined, '', false, ANIMATION_DURATION + ANIMATION_END_DELAY,
|
||||||
|
);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="ArchivedChats">
|
<div className="ArchivedChats">
|
||||||
|
|||||||
@ -57,7 +57,7 @@ import useEnsureMessage from '../../../hooks/useEnsureMessage';
|
|||||||
import useFlag from '../../../hooks/useFlag';
|
import useFlag from '../../../hooks/useFlag';
|
||||||
import { useIsIntersecting } from '../../../hooks/useIntersectionObserver';
|
import { useIsIntersecting } from '../../../hooks/useIntersectionObserver';
|
||||||
import useLastCallback from '../../../hooks/useLastCallback';
|
import useLastCallback from '../../../hooks/useLastCallback';
|
||||||
import useShowTransition from '../../../hooks/useShowTransition';
|
import useShowTransitionDeprecated from '../../../hooks/useShowTransitionDeprecated';
|
||||||
import useChatListEntry from './hooks/useChatListEntry';
|
import useChatListEntry from './hooks/useChatListEntry';
|
||||||
|
|
||||||
import Avatar from '../../common/Avatar';
|
import Avatar from '../../common/Avatar';
|
||||||
@ -290,7 +290,7 @@ const Chat: FC<OwnProps & StateProps> = ({
|
|||||||
}, [chat, chatId, isForum, isIntersecting]);
|
}, [chat, chatId, isForum, isIntersecting]);
|
||||||
|
|
||||||
const isOnline = user && userStatus && isUserOnline(user, userStatus);
|
const isOnline = user && userStatus && isUserOnline(user, userStatus);
|
||||||
const { hasShownClass: isAvatarOnlineShown } = useShowTransition(isOnline);
|
const { hasShownClass: isAvatarOnlineShown } = useShowTransitionDeprecated(isOnline);
|
||||||
|
|
||||||
const href = useMemo(() => {
|
const href = useMemo(() => {
|
||||||
if (!IS_OPEN_IN_NEW_TAB_SUPPORTED) return undefined;
|
if (!IS_OPEN_IN_NEW_TAB_SUPPORTED) return undefined;
|
||||||
|
|||||||
@ -24,7 +24,7 @@ import { useFolderManagerForUnreadCounters } from '../../../hooks/useFolderManag
|
|||||||
import useHistoryBack from '../../../hooks/useHistoryBack';
|
import useHistoryBack from '../../../hooks/useHistoryBack';
|
||||||
import useLastCallback from '../../../hooks/useLastCallback';
|
import useLastCallback from '../../../hooks/useLastCallback';
|
||||||
import useOldLang from '../../../hooks/useOldLang';
|
import useOldLang from '../../../hooks/useOldLang';
|
||||||
import useShowTransition from '../../../hooks/useShowTransition';
|
import useShowTransitionDeprecated from '../../../hooks/useShowTransitionDeprecated';
|
||||||
|
|
||||||
import StoryRibbon from '../../story/StoryRibbon';
|
import StoryRibbon from '../../story/StoryRibbon';
|
||||||
import TabList from '../../ui/TabList';
|
import TabList from '../../ui/TabList';
|
||||||
@ -103,7 +103,7 @@ const ChatFolders: FC<OwnProps & StateProps> = ({
|
|||||||
shouldRender: shouldRenderStoryRibbon,
|
shouldRender: shouldRenderStoryRibbon,
|
||||||
transitionClassNames: storyRibbonClassNames,
|
transitionClassNames: storyRibbonClassNames,
|
||||||
isClosing: isStoryRibbonClosing,
|
isClosing: isStoryRibbonClosing,
|
||||||
} = useShowTransition(isStoryRibbonShown, undefined, undefined, '');
|
} = useShowTransitionDeprecated(isStoryRibbonShown, undefined, undefined, '');
|
||||||
|
|
||||||
const allChatsFolder: ApiChatFolder = useMemo(() => {
|
const allChatsFolder: ApiChatFolder = useMemo(() => {
|
||||||
return {
|
return {
|
||||||
@ -283,7 +283,7 @@ const ChatFolders: FC<OwnProps & StateProps> = ({
|
|||||||
|
|
||||||
const {
|
const {
|
||||||
shouldRender: shouldRenderPlaceholder, transitionClassNames,
|
shouldRender: shouldRenderPlaceholder, transitionClassNames,
|
||||||
} = useShowTransition(!orderedFolderIds, undefined, true);
|
} = useShowTransitionDeprecated(!orderedFolderIds, undefined, true);
|
||||||
|
|
||||||
function renderCurrentTab(isActive: boolean) {
|
function renderCurrentTab(isActive: boolean) {
|
||||||
const activeFolder = Object.values(chatFoldersById)
|
const activeFolder = Object.values(chatFoldersById)
|
||||||
|
|||||||
@ -15,7 +15,7 @@ import { IS_ELECTRON, IS_TOUCH_ENV } from '../../../util/windowEnvironment';
|
|||||||
import useForumPanelRender from '../../../hooks/useForumPanelRender';
|
import useForumPanelRender from '../../../hooks/useForumPanelRender';
|
||||||
import useLastCallback from '../../../hooks/useLastCallback';
|
import useLastCallback from '../../../hooks/useLastCallback';
|
||||||
import useOldLang from '../../../hooks/useOldLang';
|
import useOldLang from '../../../hooks/useOldLang';
|
||||||
import useShowTransition from '../../../hooks/useShowTransition';
|
import useShowTransitionDeprecated from '../../../hooks/useShowTransitionDeprecated';
|
||||||
|
|
||||||
import Button from '../../ui/Button';
|
import Button from '../../ui/Button';
|
||||||
import Transition from '../../ui/Transition';
|
import Transition from '../../ui/Transition';
|
||||||
@ -86,7 +86,7 @@ const LeftMain: FC<OwnProps> = ({
|
|||||||
const {
|
const {
|
||||||
shouldRender: shouldRenderUpdateButton,
|
shouldRender: shouldRenderUpdateButton,
|
||||||
transitionClassNames: updateButtonClassNames,
|
transitionClassNames: updateButtonClassNames,
|
||||||
} = useShowTransition(isAppUpdateAvailable || isElectronUpdateAvailable);
|
} = useShowTransitionDeprecated(isAppUpdateAvailable || isElectronUpdateAvailable);
|
||||||
|
|
||||||
const isMouseInside = useRef(false);
|
const isMouseInside = useRef(false);
|
||||||
|
|
||||||
|
|||||||
@ -17,7 +17,7 @@ import useCanvasBlur from '../../../hooks/useCanvasBlur';
|
|||||||
import useMedia from '../../../hooks/useMedia';
|
import useMedia from '../../../hooks/useMedia';
|
||||||
import useMediaWithLoadProgress from '../../../hooks/useMediaWithLoadProgress';
|
import useMediaWithLoadProgress from '../../../hooks/useMediaWithLoadProgress';
|
||||||
import usePreviousDeprecated from '../../../hooks/usePreviousDeprecated';
|
import usePreviousDeprecated from '../../../hooks/usePreviousDeprecated';
|
||||||
import useShowTransition from '../../../hooks/useShowTransition';
|
import useShowTransitionDeprecated from '../../../hooks/useShowTransitionDeprecated';
|
||||||
|
|
||||||
import ProgressSpinner from '../../ui/ProgressSpinner';
|
import ProgressSpinner from '../../ui/ProgressSpinner';
|
||||||
|
|
||||||
@ -41,7 +41,7 @@ const WallpaperTile: FC<OwnProps> = ({
|
|||||||
const localBlobUrl = document.previewBlobUrl;
|
const localBlobUrl = document.previewBlobUrl;
|
||||||
const previewBlobUrl = useMedia(`${localMediaHash}?size=m`);
|
const previewBlobUrl = useMedia(`${localMediaHash}?size=m`);
|
||||||
const thumbRef = useCanvasBlur(document.thumbnail?.dataUri, Boolean(previewBlobUrl), true);
|
const thumbRef = useCanvasBlur(document.thumbnail?.dataUri, Boolean(previewBlobUrl), true);
|
||||||
const { transitionClassNames } = useShowTransition(
|
const { transitionClassNames } = useShowTransitionDeprecated(
|
||||||
Boolean(previewBlobUrl || localBlobUrl),
|
Boolean(previewBlobUrl || localBlobUrl),
|
||||||
undefined,
|
undefined,
|
||||||
undefined,
|
undefined,
|
||||||
@ -53,7 +53,7 @@ const WallpaperTile: FC<OwnProps> = ({
|
|||||||
mediaData: fullMedia, loadProgress,
|
mediaData: fullMedia, loadProgress,
|
||||||
} = useMediaWithLoadProgress(localMediaHash, !isLoadAllowed);
|
} = useMediaWithLoadProgress(localMediaHash, !isLoadAllowed);
|
||||||
const wasLoadDisabled = usePreviousDeprecated(isLoadAllowed) === false;
|
const wasLoadDisabled = usePreviousDeprecated(isLoadAllowed) === false;
|
||||||
const { shouldRender: shouldRenderSpinner, transitionClassNames: spinnerClassNames } = useShowTransition(
|
const { shouldRender: shouldRenderSpinner, transitionClassNames: spinnerClassNames } = useShowTransitionDeprecated(
|
||||||
(isLoadAllowed && !fullMedia) || slug === UPLOADING_WALLPAPER_SLUG,
|
(isLoadAllowed && !fullMedia) || slug === UPLOADING_WALLPAPER_SLUG,
|
||||||
undefined,
|
undefined,
|
||||||
wasLoadDisabled,
|
wasLoadDisabled,
|
||||||
|
|||||||
@ -12,7 +12,7 @@ import { LOCAL_TGS_URLS } from '../common/helpers/animatedAssets';
|
|||||||
import useTimeout from '../../hooks/schedulers/useTimeout';
|
import useTimeout from '../../hooks/schedulers/useTimeout';
|
||||||
import useFlag from '../../hooks/useFlag';
|
import useFlag from '../../hooks/useFlag';
|
||||||
import useOldLang from '../../hooks/useOldLang';
|
import useOldLang from '../../hooks/useOldLang';
|
||||||
import useShowTransition from '../../hooks/useShowTransition';
|
import useShowTransitionDeprecated from '../../hooks/useShowTransitionDeprecated';
|
||||||
|
|
||||||
import AnimatedIconWithPreview from '../common/AnimatedIconWithPreview';
|
import AnimatedIconWithPreview from '../common/AnimatedIconWithPreview';
|
||||||
import PasswordForm from '../common/PasswordForm';
|
import PasswordForm from '../common/PasswordForm';
|
||||||
@ -55,7 +55,7 @@ const LockScreen: FC<OwnProps & StateProps> = ({
|
|||||||
const [validationError, setValidationError] = useState<string>('');
|
const [validationError, setValidationError] = useState<string>('');
|
||||||
const [shouldShowPasscode, setShouldShowPasscode] = useState(false);
|
const [shouldShowPasscode, setShouldShowPasscode] = useState(false);
|
||||||
const [isSignOutDialogOpen, openSignOutConfirmation, closeSignOutConfirmation] = useFlag(false);
|
const [isSignOutDialogOpen, openSignOutConfirmation, closeSignOutConfirmation] = useFlag(false);
|
||||||
const { shouldRender } = useShowTransition(isLocked);
|
const { shouldRender } = useShowTransitionDeprecated(isLocked);
|
||||||
|
|
||||||
useTimeout(resetInvalidUnlockAttempts, timeoutUntil ? timeoutUntil - Date.now() : undefined);
|
useTimeout(resetInvalidUnlockAttempts, timeoutUntil ? timeoutUntil - Date.now() : undefined);
|
||||||
|
|
||||||
|
|||||||
@ -7,18 +7,12 @@ import React, {
|
|||||||
import { addExtraClass } from '../../lib/teact/teact-dom';
|
import { addExtraClass } from '../../lib/teact/teact-dom';
|
||||||
import { getActions, getGlobal, withGlobal } from '../../global';
|
import { getActions, getGlobal, withGlobal } from '../../global';
|
||||||
|
|
||||||
import type {
|
import type { ApiChatFolder, ApiMessage, ApiUser } from '../../api/types';
|
||||||
ApiChatFolder,
|
|
||||||
ApiMessage,
|
|
||||||
ApiUser,
|
|
||||||
} from '../../api/types';
|
|
||||||
import type { ApiLimitTypeWithModal, TabState } from '../../global/types';
|
import type { ApiLimitTypeWithModal, TabState } from '../../global/types';
|
||||||
import type { LangCode } from '../../types';
|
import type { LangCode } from '../../types';
|
||||||
import { ElectronEvent } from '../../types/electron';
|
import { ElectronEvent } from '../../types/electron';
|
||||||
|
|
||||||
import {
|
import { BASE_EMOJI_KEYWORD_LANG, DEBUG, INACTIVE_MARKER } from '../../config';
|
||||||
BASE_EMOJI_KEYWORD_LANG, DEBUG, INACTIVE_MARKER,
|
|
||||||
} from '../../config';
|
|
||||||
import { requestNextMutation } from '../../lib/fasterdom/fasterdom';
|
import { requestNextMutation } from '../../lib/fasterdom/fasterdom';
|
||||||
import {
|
import {
|
||||||
selectCanAnimateInterface,
|
selectCanAnimateInterface,
|
||||||
@ -430,9 +424,12 @@ const Main = ({
|
|||||||
}
|
}
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
const leftColumnTransition = useShowTransition(
|
useShowTransition({
|
||||||
isLeftColumnOpen, undefined, true, undefined, shouldSkipHistoryAnimations, undefined, true,
|
ref: containerRef,
|
||||||
);
|
isOpen: isLeftColumnOpen,
|
||||||
|
noCloseTransition: shouldSkipHistoryAnimations,
|
||||||
|
prefix: 'left-column-',
|
||||||
|
});
|
||||||
const willAnimateLeftColumnRef = useRef(false);
|
const willAnimateLeftColumnRef = useRef(false);
|
||||||
const forceUpdate = useForceUpdate();
|
const forceUpdate = useForceUpdate();
|
||||||
|
|
||||||
@ -459,9 +456,12 @@ const Main = ({
|
|||||||
});
|
});
|
||||||
}, [isLeftColumnOpen, withInterfaceAnimations, forceUpdate]);
|
}, [isLeftColumnOpen, withInterfaceAnimations, forceUpdate]);
|
||||||
|
|
||||||
const rightColumnTransition = useShowTransition(
|
useShowTransition({
|
||||||
isRightColumnOpen, undefined, true, undefined, shouldSkipHistoryAnimations, undefined, true,
|
ref: containerRef,
|
||||||
);
|
isOpen: isRightColumnOpen,
|
||||||
|
noCloseTransition: shouldSkipHistoryAnimations,
|
||||||
|
prefix: 'right-column-',
|
||||||
|
});
|
||||||
const willAnimateRightColumnRef = useRef(false);
|
const willAnimateRightColumnRef = useRef(false);
|
||||||
const [isNarrowMessageList, setIsNarrowMessageList] = useState(isRightColumnOpen);
|
const [isNarrowMessageList, setIsNarrowMessageList] = useState(isRightColumnOpen);
|
||||||
|
|
||||||
@ -491,11 +491,7 @@ const Main = ({
|
|||||||
}, [isMiddleColumnOpen, isRightColumnOpen, noRightColumnAnimation, forceUpdate]);
|
}, [isMiddleColumnOpen, isRightColumnOpen, noRightColumnAnimation, forceUpdate]);
|
||||||
|
|
||||||
const className = buildClassName(
|
const className = buildClassName(
|
||||||
leftColumnTransition.hasShownClass && 'left-column-shown',
|
|
||||||
leftColumnTransition.hasOpenClass && 'left-column-open',
|
|
||||||
willAnimateLeftColumnRef.current && 'left-column-animating',
|
willAnimateLeftColumnRef.current && 'left-column-animating',
|
||||||
rightColumnTransition.hasShownClass && 'right-column-shown',
|
|
||||||
rightColumnTransition.hasOpenClass && 'right-column-open',
|
|
||||||
willAnimateRightColumnRef.current && 'right-column-animating',
|
willAnimateRightColumnRef.current && 'right-column-animating',
|
||||||
isNarrowMessageList && 'narrow-message-list',
|
isNarrowMessageList && 'narrow-message-list',
|
||||||
shouldSkipHistoryAnimations && 'history-animation-disabled',
|
shouldSkipHistoryAnimations && 'history-animation-disabled',
|
||||||
|
|||||||
@ -7,7 +7,7 @@ import buildClassName from '../../../../util/buildClassName';
|
|||||||
|
|
||||||
import useCanvasBlur from '../../../../hooks/useCanvasBlur';
|
import useCanvasBlur from '../../../../hooks/useCanvasBlur';
|
||||||
import useMedia from '../../../../hooks/useMedia';
|
import useMedia from '../../../../hooks/useMedia';
|
||||||
import useMediaTransition from '../../../../hooks/useMediaTransition';
|
import useMediaTransitionDeprecated from '../../../../hooks/useMediaTransitionDeprecated';
|
||||||
|
|
||||||
import OptimizedVideo from '../../../ui/OptimizedVideo';
|
import OptimizedVideo from '../../../ui/OptimizedVideo';
|
||||||
|
|
||||||
@ -34,7 +34,7 @@ const PremiumFeaturePreviewVideo: FC<OwnProps> = ({
|
|||||||
}) => {
|
}) => {
|
||||||
const mediaData = useMedia(`document${videoId}`);
|
const mediaData = useMedia(`document${videoId}`);
|
||||||
const thumbnailRef = useCanvasBlur(videoThumbnail.dataUri);
|
const thumbnailRef = useCanvasBlur(videoThumbnail.dataUri);
|
||||||
const transitionClassNames = useMediaTransition(mediaData);
|
const transitionClassNames = useMediaTransitionDeprecated(mediaData);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className={styles.root}>
|
<div className={styles.root}>
|
||||||
|
|||||||
@ -17,7 +17,7 @@ import useBuffering from '../../hooks/useBuffering';
|
|||||||
import useCurrentTimeSignal from '../../hooks/useCurrentTimeSignal';
|
import useCurrentTimeSignal from '../../hooks/useCurrentTimeSignal';
|
||||||
import useLastCallback from '../../hooks/useLastCallback';
|
import useLastCallback from '../../hooks/useLastCallback';
|
||||||
import usePictureInPicture from '../../hooks/usePictureInPicture';
|
import usePictureInPicture from '../../hooks/usePictureInPicture';
|
||||||
import useShowTransition from '../../hooks/useShowTransition';
|
import useShowTransitionDeprecated from '../../hooks/useShowTransitionDeprecated';
|
||||||
import useVideoCleanup from '../../hooks/useVideoCleanup';
|
import useVideoCleanup from '../../hooks/useVideoCleanup';
|
||||||
import useFullscreen from '../../hooks/window/useFullscreen';
|
import useFullscreen from '../../hooks/window/useFullscreen';
|
||||||
import useControlsSignal from './hooks/useControlsSignal';
|
import useControlsSignal from './hooks/useControlsSignal';
|
||||||
@ -126,11 +126,15 @@ const VideoPlayer: FC<OwnProps> = ({
|
|||||||
const {
|
const {
|
||||||
shouldRender: shouldRenderSpinner,
|
shouldRender: shouldRenderSpinner,
|
||||||
transitionClassNames: spinnerClassNames,
|
transitionClassNames: spinnerClassNames,
|
||||||
} = useShowTransition(!isBuffered && !isUnsupported, undefined, undefined, 'slow');
|
} = useShowTransitionDeprecated(
|
||||||
|
!isBuffered && !isUnsupported, undefined, undefined, 'slow',
|
||||||
|
);
|
||||||
const {
|
const {
|
||||||
shouldRender: shouldRenderPlayButton,
|
shouldRender: shouldRenderPlayButton,
|
||||||
transitionClassNames: playButtonClassNames,
|
transitionClassNames: playButtonClassNames,
|
||||||
} = useShowTransition(IS_IOS && !isPlaying && !shouldRenderSpinner && !isUnsupported, undefined, undefined, 'slow');
|
} = useShowTransitionDeprecated(
|
||||||
|
IS_IOS && !isPlaying && !shouldRenderSpinner && !isUnsupported, undefined, undefined, 'slow',
|
||||||
|
);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
lockControls(shouldRenderSpinner);
|
lockControls(shouldRenderSpinner);
|
||||||
|
|||||||
@ -38,7 +38,7 @@ import useEnsureMessage from '../../hooks/useEnsureMessage';
|
|||||||
import useFlag from '../../hooks/useFlag';
|
import useFlag from '../../hooks/useFlag';
|
||||||
import { useIsIntersecting, useOnIntersect } from '../../hooks/useIntersectionObserver';
|
import { useIsIntersecting, useOnIntersect } from '../../hooks/useIntersectionObserver';
|
||||||
import useOldLang from '../../hooks/useOldLang';
|
import useOldLang from '../../hooks/useOldLang';
|
||||||
import useShowTransition from '../../hooks/useShowTransition';
|
import useShowTransitionDeprecated from '../../hooks/useShowTransitionDeprecated';
|
||||||
import useFocusMessage from './message/hooks/useFocusMessage';
|
import useFocusMessage from './message/hooks/useFocusMessage';
|
||||||
|
|
||||||
import AnimatedIconFromSticker from '../common/AnimatedIconFromSticker';
|
import AnimatedIconFromSticker from '../common/AnimatedIconFromSticker';
|
||||||
@ -161,7 +161,7 @@ const ActionMessage: FC<OwnProps & StateProps> = ({
|
|||||||
}
|
}
|
||||||
}, [isVisible, requestConfetti]);
|
}, [isVisible, requestConfetti]);
|
||||||
|
|
||||||
const { transitionClassNames } = useShowTransition(isShown, undefined, noAppearanceAnimation, false);
|
const { transitionClassNames } = useShowTransitionDeprecated(isShown, undefined, noAppearanceAnimation, false);
|
||||||
|
|
||||||
// No need for expensive global updates on users and chats, so we avoid them
|
// No need for expensive global updates on users and chats, so we avoid them
|
||||||
const usersById = getGlobal().users.byId;
|
const usersById = getGlobal().users.byId;
|
||||||
|
|||||||
@ -43,7 +43,7 @@ import useFlag from '../../hooks/useFlag';
|
|||||||
import useLastCallback from '../../hooks/useLastCallback';
|
import useLastCallback from '../../hooks/useLastCallback';
|
||||||
import useOldLang from '../../hooks/useOldLang';
|
import useOldLang from '../../hooks/useOldLang';
|
||||||
import usePrevDuringAnimation from '../../hooks/usePrevDuringAnimation';
|
import usePrevDuringAnimation from '../../hooks/usePrevDuringAnimation';
|
||||||
import useShowTransition from '../../hooks/useShowTransition';
|
import useShowTransitionDeprecated from '../../hooks/useShowTransitionDeprecated';
|
||||||
|
|
||||||
import DeleteChatModal from '../common/DeleteChatModal';
|
import DeleteChatModal from '../common/DeleteChatModal';
|
||||||
import ReportModal from '../common/ReportModal';
|
import ReportModal from '../common/ReportModal';
|
||||||
@ -211,7 +211,7 @@ const HeaderMenuContainer: FC<OwnProps & StateProps> = ({
|
|||||||
const [shouldRenderMuteModal, markRenderMuteModal, unmarkRenderMuteModal] = useFlag();
|
const [shouldRenderMuteModal, markRenderMuteModal, unmarkRenderMuteModal] = useFlag();
|
||||||
const { x, y } = anchor;
|
const { x, y } = anchor;
|
||||||
|
|
||||||
useShowTransition(isOpen, onCloseAnimationEnd, undefined, false);
|
useShowTransitionDeprecated(isOpen, onCloseAnimationEnd, undefined, false);
|
||||||
const isViewGroupInfoShown = usePrevDuringAnimation(
|
const isViewGroupInfoShown = usePrevDuringAnimation(
|
||||||
(!isChatInfoShown && isForum) ? true : undefined, CLOSE_MENU_ANIMATION_DURATION,
|
(!isChatInfoShown && isForum) ? true : undefined, CLOSE_MENU_ANIMATION_DURATION,
|
||||||
);
|
);
|
||||||
|
|||||||
@ -63,7 +63,7 @@ import useLastCallback from '../../hooks/useLastCallback';
|
|||||||
import useLongPress from '../../hooks/useLongPress';
|
import useLongPress from '../../hooks/useLongPress';
|
||||||
import useOldLang from '../../hooks/useOldLang';
|
import useOldLang from '../../hooks/useOldLang';
|
||||||
import usePreviousDeprecated from '../../hooks/usePreviousDeprecated';
|
import usePreviousDeprecated from '../../hooks/usePreviousDeprecated';
|
||||||
import useShowTransition from '../../hooks/useShowTransition';
|
import useShowTransitionDeprecated from '../../hooks/useShowTransitionDeprecated';
|
||||||
import useWindowSize from '../../hooks/window/useWindowSize';
|
import useWindowSize from '../../hooks/window/useWindowSize';
|
||||||
|
|
||||||
import GroupCallTopPane from '../calls/group/GroupCallTopPane';
|
import GroupCallTopPane from '../calls/group/GroupCallTopPane';
|
||||||
@ -310,20 +310,20 @@ const MiddleHeader: FC<OwnProps & StateProps> = ({
|
|||||||
const {
|
const {
|
||||||
shouldRender: shouldShowChatReportPanel,
|
shouldRender: shouldShowChatReportPanel,
|
||||||
transitionClassNames: chatReportPanelClassNames,
|
transitionClassNames: chatReportPanelClassNames,
|
||||||
} = useShowTransition(hasChatSettings);
|
} = useShowTransitionDeprecated(hasChatSettings);
|
||||||
const renderingChatSettings = useCurrentOrPrev(hasChatSettings ? settings : undefined, true);
|
const renderingChatSettings = useCurrentOrPrev(hasChatSettings ? settings : undefined, true);
|
||||||
|
|
||||||
const {
|
const {
|
||||||
shouldRender: shouldRenderAudioPlayer,
|
shouldRender: shouldRenderAudioPlayer,
|
||||||
transitionClassNames: audioPlayerClassNames,
|
transitionClassNames: audioPlayerClassNames,
|
||||||
} = useShowTransition(Boolean(audioMessage));
|
} = useShowTransitionDeprecated(Boolean(audioMessage));
|
||||||
|
|
||||||
const renderingAudioMessage = useCurrentOrPrev(audioMessage, true);
|
const renderingAudioMessage = useCurrentOrPrev(audioMessage, true);
|
||||||
|
|
||||||
const {
|
const {
|
||||||
shouldRender: shouldRenderPinnedMessage,
|
shouldRender: shouldRenderPinnedMessage,
|
||||||
transitionClassNames: pinnedMessageClassNames,
|
transitionClassNames: pinnedMessageClassNames,
|
||||||
} = useShowTransition(Boolean(pinnedMessage) && !isMiddleSearchOpen, undefined, true);
|
} = useShowTransitionDeprecated(Boolean(pinnedMessage) && !isMiddleSearchOpen, undefined, true);
|
||||||
|
|
||||||
const renderingPinnedMessage = useCurrentOrPrev(pinnedMessage, true);
|
const renderingPinnedMessage = useCurrentOrPrev(pinnedMessage, true);
|
||||||
const renderingPinnedMessagesCount = useCurrentOrPrev(pinnedMessagesCount, true);
|
const renderingPinnedMessagesCount = useCurrentOrPrev(pinnedMessagesCount, true);
|
||||||
|
|||||||
@ -14,7 +14,7 @@ import freezeWhenClosed from '../../../util/hoc/freezeWhenClosed';
|
|||||||
import setTooltipItemVisible from '../../../util/setTooltipItemVisible';
|
import setTooltipItemVisible from '../../../util/setTooltipItemVisible';
|
||||||
|
|
||||||
import useLastCallback from '../../../hooks/useLastCallback';
|
import useLastCallback from '../../../hooks/useLastCallback';
|
||||||
import useShowTransition from '../../../hooks/useShowTransition';
|
import useShowTransitionDeprecated from '../../../hooks/useShowTransitionDeprecated';
|
||||||
import { useKeyboardNavigation } from './hooks/useKeyboardNavigation';
|
import { useKeyboardNavigation } from './hooks/useKeyboardNavigation';
|
||||||
|
|
||||||
import ChatCommand from './ChatCommand';
|
import ChatCommand from './ChatCommand';
|
||||||
@ -56,7 +56,7 @@ const ChatCommandTooltip: FC<OwnProps> = ({
|
|||||||
|
|
||||||
// eslint-disable-next-line no-null/no-null
|
// eslint-disable-next-line no-null/no-null
|
||||||
const containerRef = useRef<HTMLDivElement>(null);
|
const containerRef = useRef<HTMLDivElement>(null);
|
||||||
const { shouldRender, transitionClassNames } = useShowTransition(isOpen, undefined, undefined, false);
|
const { shouldRender, transitionClassNames } = useShowTransitionDeprecated(isOpen, undefined, undefined, false);
|
||||||
|
|
||||||
const handleSendCommand = useLastCallback(({ botId, command }: ApiBotCommand) => {
|
const handleSendCommand = useLastCallback(({ botId, command }: ApiBotCommand) => {
|
||||||
// No need for expensive global updates on users and chats, so we avoid them
|
// No need for expensive global updates on users and chats, so we avoid them
|
||||||
|
|||||||
@ -36,7 +36,7 @@ import useLang from '../../../hooks/useLang';
|
|||||||
import useLastCallback from '../../../hooks/useLastCallback';
|
import useLastCallback from '../../../hooks/useLastCallback';
|
||||||
import useMenuPosition from '../../../hooks/useMenuPosition';
|
import useMenuPosition from '../../../hooks/useMenuPosition';
|
||||||
import useOldLang from '../../../hooks/useOldLang';
|
import useOldLang from '../../../hooks/useOldLang';
|
||||||
import useShowTransition from '../../../hooks/useShowTransition';
|
import useShowTransitionDeprecated from '../../../hooks/useShowTransitionDeprecated';
|
||||||
|
|
||||||
import { ClosableEmbeddedMessage } from '../../common/embedded/EmbeddedMessage';
|
import { ClosableEmbeddedMessage } from '../../common/embedded/EmbeddedMessage';
|
||||||
import Icon from '../../common/icons/Icon';
|
import Icon from '../../common/icons/Icon';
|
||||||
@ -131,7 +131,7 @@ const ComposerEmbeddedMessage: FC<OwnProps & StateProps> = ({
|
|||||||
|
|
||||||
const {
|
const {
|
||||||
shouldRender, transitionClassNames,
|
shouldRender, transitionClassNames,
|
||||||
} = useShowTransition(
|
} = useShowTransitionDeprecated(
|
||||||
isShown && !isReplyToTopicStart && !isReplyToDiscussion,
|
isShown && !isReplyToTopicStart && !isReplyToDiscussion,
|
||||||
undefined,
|
undefined,
|
||||||
!shouldAnimate,
|
!shouldAnimate,
|
||||||
|
|||||||
@ -14,7 +14,7 @@ import useHorizontalScroll from '../../../hooks/useHorizontalScroll';
|
|||||||
import { useIntersectionObserver } from '../../../hooks/useIntersectionObserver';
|
import { useIntersectionObserver } from '../../../hooks/useIntersectionObserver';
|
||||||
import useLastCallback from '../../../hooks/useLastCallback';
|
import useLastCallback from '../../../hooks/useLastCallback';
|
||||||
import usePreviousDeprecated from '../../../hooks/usePreviousDeprecated';
|
import usePreviousDeprecated from '../../../hooks/usePreviousDeprecated';
|
||||||
import useShowTransition from '../../../hooks/useShowTransition';
|
import useShowTransitionDeprecated from '../../../hooks/useShowTransitionDeprecated';
|
||||||
|
|
||||||
import StickerButton from '../../common/StickerButton';
|
import StickerButton from '../../common/StickerButton';
|
||||||
import Loading from '../../ui/Loading';
|
import Loading from '../../ui/Loading';
|
||||||
@ -52,7 +52,7 @@ const CustomEmojiTooltip: FC<OwnProps & StateProps> = ({
|
|||||||
|
|
||||||
// eslint-disable-next-line no-null/no-null
|
// eslint-disable-next-line no-null/no-null
|
||||||
const containerRef = useRef<HTMLDivElement>(null);
|
const containerRef = useRef<HTMLDivElement>(null);
|
||||||
const { shouldRender, transitionClassNames } = useShowTransition(isOpen, undefined, undefined, false);
|
const { shouldRender, transitionClassNames } = useShowTransitionDeprecated(isOpen, undefined, undefined, false);
|
||||||
const prevStickers = usePreviousDeprecated(customEmoji, true);
|
const prevStickers = usePreviousDeprecated(customEmoji, true);
|
||||||
const displayedStickers = customEmoji || prevStickers;
|
const displayedStickers = customEmoji || prevStickers;
|
||||||
|
|
||||||
|
|||||||
@ -13,7 +13,7 @@ import getFilesFromDataTransferItems from './helpers/getFilesFromDataTransferIte
|
|||||||
import useLastCallback from '../../../hooks/useLastCallback';
|
import useLastCallback from '../../../hooks/useLastCallback';
|
||||||
import useOldLang from '../../../hooks/useOldLang';
|
import useOldLang from '../../../hooks/useOldLang';
|
||||||
import usePreviousDeprecated from '../../../hooks/usePreviousDeprecated';
|
import usePreviousDeprecated from '../../../hooks/usePreviousDeprecated';
|
||||||
import useShowTransition from '../../../hooks/useShowTransition';
|
import useShowTransitionDeprecated from '../../../hooks/useShowTransitionDeprecated';
|
||||||
|
|
||||||
import Portal from '../../ui/Portal';
|
import Portal from '../../ui/Portal';
|
||||||
import DropTarget from './DropTarget';
|
import DropTarget from './DropTarget';
|
||||||
@ -44,7 +44,7 @@ const DropArea: FC<OwnProps> = ({
|
|||||||
// eslint-disable-next-line no-null/no-null
|
// eslint-disable-next-line no-null/no-null
|
||||||
const hideTimeoutRef = useRef<number>(null);
|
const hideTimeoutRef = useRef<number>(null);
|
||||||
const prevWithQuick = usePreviousDeprecated(withQuick);
|
const prevWithQuick = usePreviousDeprecated(withQuick);
|
||||||
const { shouldRender, transitionClassNames } = useShowTransition(isOpen);
|
const { shouldRender, transitionClassNames } = useShowTransitionDeprecated(isOpen);
|
||||||
const isInAlbum = editingMessage && editingMessage?.groupedId;
|
const isInAlbum = editingMessage && editingMessage?.groupedId;
|
||||||
|
|
||||||
useEffect(() => (isOpen ? captureEscKeyListener(onHide) : undefined), [isOpen, onHide]);
|
useEffect(() => (isOpen ? captureEscKeyListener(onHide) : undefined), [isOpen, onHide]);
|
||||||
|
|||||||
@ -10,7 +10,7 @@ import { REM } from '../../common/helpers/mediaDimensions';
|
|||||||
|
|
||||||
import useAppLayout from '../../../hooks/useAppLayout';
|
import useAppLayout from '../../../hooks/useAppLayout';
|
||||||
import { useOnIntersect } from '../../../hooks/useIntersectionObserver';
|
import { useOnIntersect } from '../../../hooks/useIntersectionObserver';
|
||||||
import useMediaTransition from '../../../hooks/useMediaTransition';
|
import useMediaTransitionDeprecated from '../../../hooks/useMediaTransitionDeprecated';
|
||||||
import useOldLang from '../../../hooks/useOldLang';
|
import useOldLang from '../../../hooks/useOldLang';
|
||||||
|
|
||||||
import EmojiButton from './EmojiButton';
|
import EmojiButton from './EmojiButton';
|
||||||
@ -38,7 +38,7 @@ const EmojiCategory: FC<OwnProps> = ({
|
|||||||
|
|
||||||
useOnIntersect(ref, observeIntersection);
|
useOnIntersect(ref, observeIntersection);
|
||||||
|
|
||||||
const transitionClassNames = useMediaTransition(shouldRender);
|
const transitionClassNames = useMediaTransitionDeprecated(shouldRender);
|
||||||
|
|
||||||
const lang = useOldLang();
|
const lang = useOldLang();
|
||||||
const { isMobile } = useAppLayout();
|
const { isMobile } = useAppLayout();
|
||||||
|
|||||||
@ -13,7 +13,7 @@ import useHorizontalScroll from '../../../hooks/useHorizontalScroll';
|
|||||||
import { useIntersectionObserver } from '../../../hooks/useIntersectionObserver';
|
import { useIntersectionObserver } from '../../../hooks/useIntersectionObserver';
|
||||||
import useLastCallback from '../../../hooks/useLastCallback';
|
import useLastCallback from '../../../hooks/useLastCallback';
|
||||||
import usePrevDuringAnimation from '../../../hooks/usePrevDuringAnimation';
|
import usePrevDuringAnimation from '../../../hooks/usePrevDuringAnimation';
|
||||||
import useShowTransition from '../../../hooks/useShowTransition';
|
import useShowTransitionDeprecated from '../../../hooks/useShowTransitionDeprecated';
|
||||||
import { useKeyboardNavigation } from './hooks/useKeyboardNavigation';
|
import { useKeyboardNavigation } from './hooks/useKeyboardNavigation';
|
||||||
|
|
||||||
import Loading from '../../ui/Loading';
|
import Loading from '../../ui/Loading';
|
||||||
@ -79,7 +79,7 @@ const EmojiTooltip: FC<OwnProps> = ({
|
|||||||
}) => {
|
}) => {
|
||||||
// eslint-disable-next-line no-null/no-null
|
// eslint-disable-next-line no-null/no-null
|
||||||
const containerRef = useRef<HTMLDivElement>(null);
|
const containerRef = useRef<HTMLDivElement>(null);
|
||||||
const { shouldRender, transitionClassNames } = useShowTransition(isOpen, undefined, undefined, false);
|
const { shouldRender, transitionClassNames } = useShowTransitionDeprecated(isOpen, undefined, undefined, false);
|
||||||
const listEmojis: (Emoji | ApiSticker)[] = usePrevDuringAnimation(
|
const listEmojis: (Emoji | ApiSticker)[] = usePrevDuringAnimation(
|
||||||
emojis.length ? [...customEmojis, ...emojis] : undefined, CLOSE_DURATION,
|
emojis.length ? [...customEmojis, ...emojis] : undefined, CLOSE_DURATION,
|
||||||
) || [];
|
) || [];
|
||||||
|
|||||||
@ -17,7 +17,7 @@ import useCurrentOrPrev from '../../../hooks/useCurrentOrPrev';
|
|||||||
import { useIntersectionObserver } from '../../../hooks/useIntersectionObserver';
|
import { useIntersectionObserver } from '../../../hooks/useIntersectionObserver';
|
||||||
import useLastCallback from '../../../hooks/useLastCallback';
|
import useLastCallback from '../../../hooks/useLastCallback';
|
||||||
import usePreviousDeprecated from '../../../hooks/usePreviousDeprecated';
|
import usePreviousDeprecated from '../../../hooks/usePreviousDeprecated';
|
||||||
import useShowTransition from '../../../hooks/useShowTransition';
|
import useShowTransitionDeprecated from '../../../hooks/useShowTransitionDeprecated';
|
||||||
import { useKeyboardNavigation } from './hooks/useKeyboardNavigation';
|
import { useKeyboardNavigation } from './hooks/useKeyboardNavigation';
|
||||||
|
|
||||||
import InfiniteScroll from '../../ui/InfiniteScroll';
|
import InfiniteScroll from '../../ui/InfiniteScroll';
|
||||||
@ -71,7 +71,7 @@ const InlineBotTooltip: FC<OwnProps> = ({
|
|||||||
|
|
||||||
// eslint-disable-next-line no-null/no-null
|
// eslint-disable-next-line no-null/no-null
|
||||||
const containerRef = useRef<HTMLDivElement>(null);
|
const containerRef = useRef<HTMLDivElement>(null);
|
||||||
const { shouldRender, transitionClassNames } = useShowTransition(isOpen, undefined, undefined, false);
|
const { shouldRender, transitionClassNames } = useShowTransitionDeprecated(isOpen, undefined, undefined, false);
|
||||||
const renderedIsGallery = useCurrentOrPrev(isGallery, shouldRender);
|
const renderedIsGallery = useCurrentOrPrev(isGallery, shouldRender);
|
||||||
const {
|
const {
|
||||||
observe: observeIntersection,
|
observe: observeIntersection,
|
||||||
|
|||||||
@ -9,7 +9,7 @@ import setTooltipItemVisible from '../../../util/setTooltipItemVisible';
|
|||||||
|
|
||||||
import useLastCallback from '../../../hooks/useLastCallback';
|
import useLastCallback from '../../../hooks/useLastCallback';
|
||||||
import usePreviousDeprecated from '../../../hooks/usePreviousDeprecated';
|
import usePreviousDeprecated from '../../../hooks/usePreviousDeprecated';
|
||||||
import useShowTransition from '../../../hooks/useShowTransition';
|
import useShowTransitionDeprecated from '../../../hooks/useShowTransitionDeprecated';
|
||||||
import { useKeyboardNavigation } from './hooks/useKeyboardNavigation';
|
import { useKeyboardNavigation } from './hooks/useKeyboardNavigation';
|
||||||
|
|
||||||
import PrivateChatInfo from '../../common/PrivateChatInfo';
|
import PrivateChatInfo from '../../common/PrivateChatInfo';
|
||||||
@ -32,7 +32,7 @@ const MentionTooltip: FC<OwnProps> = ({
|
|||||||
}) => {
|
}) => {
|
||||||
// eslint-disable-next-line no-null/no-null
|
// eslint-disable-next-line no-null/no-null
|
||||||
const containerRef = useRef<HTMLDivElement>(null);
|
const containerRef = useRef<HTMLDivElement>(null);
|
||||||
const { shouldRender, transitionClassNames } = useShowTransition(isOpen, undefined, undefined, false);
|
const { shouldRender, transitionClassNames } = useShowTransitionDeprecated(isOpen, undefined, undefined, false);
|
||||||
|
|
||||||
const handleUserSelect = useLastCallback((userId: string, forceFocus = false) => {
|
const handleUserSelect = useLastCallback((userId: string, forceFocus = false) => {
|
||||||
// No need for expensive global updates on users, so we avoid them
|
// No need for expensive global updates on users, so we avoid them
|
||||||
|
|||||||
@ -17,7 +17,7 @@ import useDynamicColorListener from '../../../hooks/stickers/useDynamicColorList
|
|||||||
import useCoordsInSharedCanvas from '../../../hooks/useCoordsInSharedCanvas';
|
import useCoordsInSharedCanvas from '../../../hooks/useCoordsInSharedCanvas';
|
||||||
import { useIsIntersecting } from '../../../hooks/useIntersectionObserver';
|
import { useIsIntersecting } from '../../../hooks/useIntersectionObserver';
|
||||||
import useMedia from '../../../hooks/useMedia';
|
import useMedia from '../../../hooks/useMedia';
|
||||||
import useMediaTransition from '../../../hooks/useMediaTransition';
|
import useMediaTransitionDeprecated from '../../../hooks/useMediaTransitionDeprecated';
|
||||||
import useCustomEmoji from '../../common/hooks/useCustomEmoji';
|
import useCustomEmoji from '../../common/hooks/useCustomEmoji';
|
||||||
|
|
||||||
import AnimatedSticker from '../../common/AnimatedSticker';
|
import AnimatedSticker from '../../common/AnimatedSticker';
|
||||||
@ -68,7 +68,7 @@ const StickerSetCover: FC<OwnProps> = ({
|
|||||||
const mediaHash = ((hasThumbnail && !shouldFallbackToStatic) || hasAnimatedThumb) && `stickerSet${stickerSet.id}`;
|
const mediaHash = ((hasThumbnail && !shouldFallbackToStatic) || hasAnimatedThumb) && `stickerSet${stickerSet.id}`;
|
||||||
const mediaData = useMedia(mediaHash, !isIntersecting);
|
const mediaData = useMedia(mediaHash, !isIntersecting);
|
||||||
const isReady = thumbCustomEmojiId || mediaData || staticMediaData;
|
const isReady = thumbCustomEmojiId || mediaData || staticMediaData;
|
||||||
const transitionClassNames = useMediaTransition(isReady);
|
const transitionClassNames = useMediaTransitionDeprecated(isReady);
|
||||||
|
|
||||||
const coords = useCoordsInSharedCanvas(containerRef, sharedCanvasRef);
|
const coords = useCoordsInSharedCanvas(containerRef, sharedCanvasRef);
|
||||||
|
|
||||||
|
|||||||
@ -13,7 +13,7 @@ import captureEscKeyListener from '../../../util/captureEscKeyListener';
|
|||||||
import { useIntersectionObserver } from '../../../hooks/useIntersectionObserver';
|
import { useIntersectionObserver } from '../../../hooks/useIntersectionObserver';
|
||||||
import usePreviousDeprecated from '../../../hooks/usePreviousDeprecated';
|
import usePreviousDeprecated from '../../../hooks/usePreviousDeprecated';
|
||||||
import useSendMessageAction from '../../../hooks/useSendMessageAction';
|
import useSendMessageAction from '../../../hooks/useSendMessageAction';
|
||||||
import useShowTransition from '../../../hooks/useShowTransition';
|
import useShowTransitionDeprecated from '../../../hooks/useShowTransitionDeprecated';
|
||||||
|
|
||||||
import StickerButton from '../../common/StickerButton';
|
import StickerButton from '../../common/StickerButton';
|
||||||
import Loading from '../../ui/Loading';
|
import Loading from '../../ui/Loading';
|
||||||
@ -48,7 +48,7 @@ const StickerTooltip: FC<OwnProps & StateProps> = ({
|
|||||||
}) => {
|
}) => {
|
||||||
// eslint-disable-next-line no-null/no-null
|
// eslint-disable-next-line no-null/no-null
|
||||||
const containerRef = useRef<HTMLDivElement>(null);
|
const containerRef = useRef<HTMLDivElement>(null);
|
||||||
const { shouldRender, transitionClassNames } = useShowTransition(isOpen, undefined, undefined, false);
|
const { shouldRender, transitionClassNames } = useShowTransitionDeprecated(isOpen, undefined, undefined, false);
|
||||||
const prevStickers = usePreviousDeprecated(stickers, true);
|
const prevStickers = usePreviousDeprecated(stickers, true);
|
||||||
const displayedStickers = stickers || prevStickers;
|
const displayedStickers = stickers || prevStickers;
|
||||||
const sendMessageAction = useSendMessageAction(chatId, threadId);
|
const sendMessageAction = useSendMessageAction(chatId, threadId);
|
||||||
|
|||||||
@ -17,7 +17,7 @@ import useAppLayout from '../../../hooks/useAppLayout';
|
|||||||
import useLastCallback from '../../../hooks/useLastCallback';
|
import useLastCallback from '../../../hooks/useLastCallback';
|
||||||
import useMouseInside from '../../../hooks/useMouseInside';
|
import useMouseInside from '../../../hooks/useMouseInside';
|
||||||
import useOldLang from '../../../hooks/useOldLang';
|
import useOldLang from '../../../hooks/useOldLang';
|
||||||
import useShowTransition from '../../../hooks/useShowTransition';
|
import useShowTransitionDeprecated from '../../../hooks/useShowTransitionDeprecated';
|
||||||
|
|
||||||
import CustomEmojiPicker from '../../common/CustomEmojiPicker';
|
import CustomEmojiPicker from '../../common/CustomEmojiPicker';
|
||||||
import Button from '../../ui/Button';
|
import Button from '../../ui/Button';
|
||||||
@ -110,7 +110,7 @@ const SymbolMenu: FC<OwnProps & StateProps> = ({
|
|||||||
const { isMobile } = useAppLayout();
|
const { isMobile } = useAppLayout();
|
||||||
|
|
||||||
const [handleMouseEnter, handleMouseLeave] = useMouseInside(isOpen, onClose, undefined, isMobile);
|
const [handleMouseEnter, handleMouseLeave] = useMouseInside(isOpen, onClose, undefined, isMobile);
|
||||||
const { shouldRender, transitionClassNames } = useShowTransition(isOpen, onClose, false, false);
|
const { shouldRender, transitionClassNames } = useShowTransitionDeprecated(isOpen, onClose, false, false);
|
||||||
|
|
||||||
const lang = useOldLang();
|
const lang = useOldLang();
|
||||||
|
|
||||||
|
|||||||
@ -17,7 +17,7 @@ import { INPUT_CUSTOM_EMOJI_SELECTOR } from './helpers/customEmoji';
|
|||||||
import useFlag from '../../../hooks/useFlag';
|
import useFlag from '../../../hooks/useFlag';
|
||||||
import useLastCallback from '../../../hooks/useLastCallback';
|
import useLastCallback from '../../../hooks/useLastCallback';
|
||||||
import useOldLang from '../../../hooks/useOldLang';
|
import useOldLang from '../../../hooks/useOldLang';
|
||||||
import useShowTransition from '../../../hooks/useShowTransition';
|
import useShowTransitionDeprecated from '../../../hooks/useShowTransitionDeprecated';
|
||||||
import useVirtualBackdrop from '../../../hooks/useVirtualBackdrop';
|
import useVirtualBackdrop from '../../../hooks/useVirtualBackdrop';
|
||||||
|
|
||||||
import Button from '../../ui/Button';
|
import Button from '../../ui/Button';
|
||||||
@ -64,7 +64,7 @@ const TextFormatter: FC<OwnProps> = ({
|
|||||||
const containerRef = useRef<HTMLDivElement>(null);
|
const containerRef = useRef<HTMLDivElement>(null);
|
||||||
// eslint-disable-next-line no-null/no-null
|
// eslint-disable-next-line no-null/no-null
|
||||||
const linkUrlInputRef = useRef<HTMLInputElement>(null);
|
const linkUrlInputRef = useRef<HTMLInputElement>(null);
|
||||||
const { shouldRender, transitionClassNames } = useShowTransition(isOpen);
|
const { shouldRender, transitionClassNames } = useShowTransitionDeprecated(isOpen);
|
||||||
const [isLinkControlOpen, openLinkControl, closeLinkControl] = useFlag();
|
const [isLinkControlOpen, openLinkControl, closeLinkControl] = useFlag();
|
||||||
const [linkUrl, setLinkUrl] = useState('');
|
const [linkUrl, setLinkUrl] = useState('');
|
||||||
const [isEditingLink, setIsEditingLink] = useState(false);
|
const [isEditingLink, setIsEditingLink] = useState(false);
|
||||||
|
|||||||
@ -25,7 +25,7 @@ import useDerivedState from '../../../hooks/useDerivedState';
|
|||||||
import useLastCallback from '../../../hooks/useLastCallback';
|
import useLastCallback from '../../../hooks/useLastCallback';
|
||||||
import useMenuPosition from '../../../hooks/useMenuPosition';
|
import useMenuPosition from '../../../hooks/useMenuPosition';
|
||||||
import useOldLang from '../../../hooks/useOldLang';
|
import useOldLang from '../../../hooks/useOldLang';
|
||||||
import useShowTransition from '../../../hooks/useShowTransition';
|
import useShowTransitionDeprecated from '../../../hooks/useShowTransitionDeprecated';
|
||||||
import useSyncEffect from '../../../hooks/useSyncEffect';
|
import useSyncEffect from '../../../hooks/useSyncEffect';
|
||||||
|
|
||||||
import Button from '../../ui/Button';
|
import Button from '../../ui/Button';
|
||||||
@ -113,7 +113,7 @@ const WebPagePreview: FC<OwnProps & StateProps> = ({
|
|||||||
const isShown = useDerivedState(() => {
|
const isShown = useDerivedState(() => {
|
||||||
return Boolean(webPagePreview && getHtml() && !noWebPage && !isDisabled);
|
return Boolean(webPagePreview && getHtml() && !noWebPage && !isDisabled);
|
||||||
}, [isDisabled, getHtml, noWebPage, webPagePreview]);
|
}, [isDisabled, getHtml, noWebPage, webPagePreview]);
|
||||||
const { shouldRender, transitionClassNames } = useShowTransition(isShown);
|
const { shouldRender, transitionClassNames } = useShowTransitionDeprecated(isShown);
|
||||||
|
|
||||||
const renderingWebPage = useCurrentOrPrev(webPagePreview, true);
|
const renderingWebPage = useCurrentOrPrev(webPagePreview, true);
|
||||||
|
|
||||||
|
|||||||
@ -10,7 +10,7 @@ import buildClassName from '../../../../util/buildClassName';
|
|||||||
|
|
||||||
import useLastCallback from '../../../../hooks/useLastCallback';
|
import useLastCallback from '../../../../hooks/useLastCallback';
|
||||||
import useMedia from '../../../../hooks/useMedia';
|
import useMedia from '../../../../hooks/useMedia';
|
||||||
import useMediaTransition from '../../../../hooks/useMediaTransition';
|
import useMediaTransitionDeprecated from '../../../../hooks/useMediaTransitionDeprecated';
|
||||||
|
|
||||||
import BaseResult from './BaseResult';
|
import BaseResult from './BaseResult';
|
||||||
|
|
||||||
@ -43,7 +43,7 @@ const MediaResult: FC<OwnProps> = ({
|
|||||||
|
|
||||||
const thumbnailBlobUrl = useMedia(getWebDocumentHash(webThumbnail));
|
const thumbnailBlobUrl = useMedia(getWebDocumentHash(webThumbnail));
|
||||||
const mediaBlobUrl = useMedia(photo && getPhotoMediaHash(photo, 'pictogram'));
|
const mediaBlobUrl = useMedia(photo && getPhotoMediaHash(photo, 'pictogram'));
|
||||||
const transitionClassNames = useMediaTransition(mediaBlobUrl || thumbnailBlobUrl);
|
const transitionClassNames = useMediaTransitionDeprecated(mediaBlobUrl || thumbnailBlobUrl);
|
||||||
|
|
||||||
const handleClick = useLastCallback(() => {
|
const handleClick = useLastCallback(() => {
|
||||||
onClick(inlineResult);
|
onClick(inlineResult);
|
||||||
|
|||||||
@ -14,7 +14,7 @@ import useCurrentOrPrev from '../../../hooks/useCurrentOrPrev';
|
|||||||
import useLastCallback from '../../../hooks/useLastCallback';
|
import useLastCallback from '../../../hooks/useLastCallback';
|
||||||
import useMedia from '../../../hooks/useMedia';
|
import useMedia from '../../../hooks/useMedia';
|
||||||
import useOldLang from '../../../hooks/useOldLang';
|
import useOldLang from '../../../hooks/useOldLang';
|
||||||
import useShowTransition from '../../../hooks/useShowTransition';
|
import useShowTransitionDeprecated from '../../../hooks/useShowTransitionDeprecated';
|
||||||
|
|
||||||
import MediaAreaOverlay from '../../story/mediaArea/MediaAreaOverlay';
|
import MediaAreaOverlay from '../../story/mediaArea/MediaAreaOverlay';
|
||||||
|
|
||||||
@ -41,7 +41,7 @@ function BaseStory({
|
|||||||
const imgBlobUrl = useMedia(imageHash);
|
const imgBlobUrl = useMedia(imageHash);
|
||||||
const thumbnail = isLoaded ? (video ? video.thumbnail?.dataUri : story.content.photo?.thumbnail?.dataUri) : undefined;
|
const thumbnail = isLoaded ? (video ? video.thumbnail?.dataUri : story.content.photo?.thumbnail?.dataUri) : undefined;
|
||||||
const mediaUrl = useCurrentOrPrev(imgBlobUrl, true);
|
const mediaUrl = useCurrentOrPrev(imgBlobUrl, true);
|
||||||
const { shouldRender, transitionClassNames } = useShowTransition(Boolean(mediaUrl));
|
const { shouldRender, transitionClassNames } = useShowTransitionDeprecated(Boolean(mediaUrl));
|
||||||
const blurredBackgroundRef = useCanvasBlur(
|
const blurredBackgroundRef = useCanvasBlur(
|
||||||
thumbnail,
|
thumbnail,
|
||||||
isExpired && !isPreview,
|
isExpired && !isPreview,
|
||||||
|
|||||||
@ -63,7 +63,7 @@ import useFlag from '../../../hooks/useFlag';
|
|||||||
import useLastCallback from '../../../hooks/useLastCallback';
|
import useLastCallback from '../../../hooks/useLastCallback';
|
||||||
import useOldLang from '../../../hooks/useOldLang';
|
import useOldLang from '../../../hooks/useOldLang';
|
||||||
import useSchedule from '../../../hooks/useSchedule';
|
import useSchedule from '../../../hooks/useSchedule';
|
||||||
import useShowTransition from '../../../hooks/useShowTransition';
|
import useShowTransitionDeprecated from '../../../hooks/useShowTransitionDeprecated';
|
||||||
|
|
||||||
import PinMessageModal from '../../common/PinMessageModal.async';
|
import PinMessageModal from '../../common/PinMessageModal.async';
|
||||||
import ReportModal from '../../common/ReportModal';
|
import ReportModal from '../../common/ReportModal';
|
||||||
@ -230,7 +230,7 @@ const ContextMenuContainer: FC<OwnProps & StateProps> = ({
|
|||||||
} = getActions();
|
} = getActions();
|
||||||
|
|
||||||
const lang = useOldLang();
|
const lang = useOldLang();
|
||||||
const { transitionClassNames } = useShowTransition(isOpen, onCloseAnimationEnd, undefined, false);
|
const { transitionClassNames } = useShowTransitionDeprecated(isOpen, onCloseAnimationEnd, undefined, false);
|
||||||
const [isMenuOpen, setIsMenuOpen] = useState(true);
|
const [isMenuOpen, setIsMenuOpen] = useState(true);
|
||||||
const [isReportModalOpen, setIsReportModalOpen] = useState(false);
|
const [isReportModalOpen, setIsReportModalOpen] = useState(false);
|
||||||
const [isPinModalOpen, setIsPinModalOpen] = useState(false);
|
const [isPinModalOpen, setIsPinModalOpen] = useState(false);
|
||||||
|
|||||||
@ -132,7 +132,7 @@ import useLastCallback from '../../../hooks/useLastCallback';
|
|||||||
import useOldLang from '../../../hooks/useOldLang';
|
import useOldLang from '../../../hooks/useOldLang';
|
||||||
import usePreviousDeprecated from '../../../hooks/usePreviousDeprecated';
|
import usePreviousDeprecated from '../../../hooks/usePreviousDeprecated';
|
||||||
import useResizeObserver from '../../../hooks/useResizeObserver';
|
import useResizeObserver from '../../../hooks/useResizeObserver';
|
||||||
import useShowTransition from '../../../hooks/useShowTransition';
|
import useShowTransitionDeprecated from '../../../hooks/useShowTransitionDeprecated';
|
||||||
import useTextLanguage from '../../../hooks/useTextLanguage';
|
import useTextLanguage from '../../../hooks/useTextLanguage';
|
||||||
import useThrottledCallback from '../../../hooks/useThrottledCallback';
|
import useThrottledCallback from '../../../hooks/useThrottledCallback';
|
||||||
import useDetectChatLanguage from './hooks/useDetectChatLanguage';
|
import useDetectChatLanguage from './hooks/useDetectChatLanguage';
|
||||||
@ -473,7 +473,7 @@ const Message: FC<OwnProps & StateProps> = ({
|
|||||||
setTimeout(markShown, appearanceOrder * APPEARANCE_DELAY);
|
setTimeout(markShown, appearanceOrder * APPEARANCE_DELAY);
|
||||||
}, [appearanceOrder, markShown, noAppearanceAnimation]);
|
}, [appearanceOrder, markShown, noAppearanceAnimation]);
|
||||||
|
|
||||||
const { transitionClassNames } = useShowTransition(
|
const { transitionClassNames } = useShowTransitionDeprecated(
|
||||||
isShown || isJustAdded,
|
isShown || isJustAdded,
|
||||||
undefined,
|
undefined,
|
||||||
noAppearanceAnimation && !isJustAdded,
|
noAppearanceAnimation && !isJustAdded,
|
||||||
|
|||||||
@ -87,7 +87,6 @@ type OwnProps = {
|
|||||||
hasCustomEmoji?: boolean;
|
hasCustomEmoji?: boolean;
|
||||||
customEmojiSets?: ApiStickerSet[];
|
customEmojiSets?: ApiStickerSet[];
|
||||||
canPlayAnimatedEmojis?: boolean;
|
canPlayAnimatedEmojis?: boolean;
|
||||||
noTransition?: boolean;
|
|
||||||
isInSavedMessages?: boolean;
|
isInSavedMessages?: boolean;
|
||||||
shouldRenderShowWhen?: boolean;
|
shouldRenderShowWhen?: boolean;
|
||||||
canLoadReadDate?: boolean;
|
canLoadReadDate?: boolean;
|
||||||
@ -176,7 +175,6 @@ const MessageContextMenu: FC<OwnProps> = ({
|
|||||||
hasCustomEmoji,
|
hasCustomEmoji,
|
||||||
customEmojiSets,
|
customEmojiSets,
|
||||||
canPlayAnimatedEmojis,
|
canPlayAnimatedEmojis,
|
||||||
noTransition,
|
|
||||||
isInSavedMessages,
|
isInSavedMessages,
|
||||||
shouldRenderShowWhen,
|
shouldRenderShowWhen,
|
||||||
canLoadReadDate,
|
canLoadReadDate,
|
||||||
@ -353,7 +351,6 @@ const MessageContextMenu: FC<OwnProps> = ({
|
|||||||
className={buildClassName(
|
className={buildClassName(
|
||||||
'MessageContextMenu', 'fluid', withReactions && 'with-reactions',
|
'MessageContextMenu', 'fluid', withReactions && 'with-reactions',
|
||||||
)}
|
)}
|
||||||
shouldSkipTransition={noTransition}
|
|
||||||
onClose={onClose}
|
onClose={onClose}
|
||||||
onCloseAnimationEnd={onCloseAnimationEnd}
|
onCloseAnimationEnd={onCloseAnimationEnd}
|
||||||
>
|
>
|
||||||
|
|||||||
@ -22,10 +22,10 @@ import useFlag from '../../../hooks/useFlag';
|
|||||||
import { useIsIntersecting } from '../../../hooks/useIntersectionObserver';
|
import { useIsIntersecting } from '../../../hooks/useIntersectionObserver';
|
||||||
import useLastCallback from '../../../hooks/useLastCallback';
|
import useLastCallback from '../../../hooks/useLastCallback';
|
||||||
import useLayoutEffectWithPrevDeps from '../../../hooks/useLayoutEffectWithPrevDeps';
|
import useLayoutEffectWithPrevDeps from '../../../hooks/useLayoutEffectWithPrevDeps';
|
||||||
import useMediaTransition from '../../../hooks/useMediaTransition';
|
import useMediaTransitionDeprecated from '../../../hooks/useMediaTransitionDeprecated';
|
||||||
import useMediaWithLoadProgress from '../../../hooks/useMediaWithLoadProgress';
|
import useMediaWithLoadProgress from '../../../hooks/useMediaWithLoadProgress';
|
||||||
import usePreviousDeprecated from '../../../hooks/usePreviousDeprecated';
|
import usePreviousDeprecated from '../../../hooks/usePreviousDeprecated';
|
||||||
import useShowTransition from '../../../hooks/useShowTransition';
|
import useShowTransitionDeprecated from '../../../hooks/useShowTransitionDeprecated';
|
||||||
import useBlurredMediaThumbRef from './hooks/useBlurredMediaThumbRef';
|
import useBlurredMediaThumbRef from './hooks/useBlurredMediaThumbRef';
|
||||||
|
|
||||||
import MediaSpoiler from '../../common/MediaSpoiler';
|
import MediaSpoiler from '../../common/MediaSpoiler';
|
||||||
@ -106,7 +106,7 @@ const Photo = <T,>({
|
|||||||
const noThumb = Boolean(fullMediaData);
|
const noThumb = Boolean(fullMediaData);
|
||||||
const thumbRef = useBlurredMediaThumbRef(photo, noThumb);
|
const thumbRef = useBlurredMediaThumbRef(photo, noThumb);
|
||||||
const blurredBackgroundRef = useBlurredMediaThumbRef(photo, !withBlurredBackground);
|
const blurredBackgroundRef = useBlurredMediaThumbRef(photo, !withBlurredBackground);
|
||||||
const thumbClassNames = useMediaTransition(!noThumb);
|
const thumbClassNames = useMediaTransitionDeprecated(!noThumb);
|
||||||
const thumbDataUri = getMediaThumbUri(photo);
|
const thumbDataUri = getMediaThumbUri(photo);
|
||||||
|
|
||||||
const [isSpoilerShown, showSpoiler, hideSpoiler] = useFlag(isPaidPreview || photo.isSpoiler);
|
const [isSpoilerShown, showSpoiler, hideSpoiler] = useFlag(isPaidPreview || photo.isSpoiler);
|
||||||
@ -139,11 +139,11 @@ const Photo = <T,>({
|
|||||||
const {
|
const {
|
||||||
shouldRender: shouldRenderSpinner,
|
shouldRender: shouldRenderSpinner,
|
||||||
transitionClassNames: spinnerClassNames,
|
transitionClassNames: spinnerClassNames,
|
||||||
} = useShowTransition(isTransferring, undefined, wasLoadDisabled, 'slow');
|
} = useShowTransitionDeprecated(isTransferring, undefined, wasLoadDisabled, 'slow');
|
||||||
const {
|
const {
|
||||||
shouldRender: shouldRenderDownloadButton,
|
shouldRender: shouldRenderDownloadButton,
|
||||||
transitionClassNames: downloadButtonClassNames,
|
transitionClassNames: downloadButtonClassNames,
|
||||||
} = useShowTransition(!fullMediaData && !isLoadAllowed);
|
} = useShowTransitionDeprecated(!fullMediaData && !isLoadAllowed);
|
||||||
|
|
||||||
const handleClick = useLastCallback((e: React.MouseEvent<HTMLElement>) => {
|
const handleClick = useLastCallback((e: React.MouseEvent<HTMLElement>) => {
|
||||||
if (isUploading) {
|
if (isUploading) {
|
||||||
|
|||||||
@ -25,10 +25,10 @@ import { useThrottledSignal } from '../../../hooks/useAsyncResolvers';
|
|||||||
import useFlag from '../../../hooks/useFlag';
|
import useFlag from '../../../hooks/useFlag';
|
||||||
import { useIsIntersecting } from '../../../hooks/useIntersectionObserver';
|
import { useIsIntersecting } from '../../../hooks/useIntersectionObserver';
|
||||||
import useLastCallback from '../../../hooks/useLastCallback';
|
import useLastCallback from '../../../hooks/useLastCallback';
|
||||||
import useMediaTransition from '../../../hooks/useMediaTransition';
|
import useMediaTransitionDeprecated from '../../../hooks/useMediaTransitionDeprecated';
|
||||||
import useMediaWithLoadProgress from '../../../hooks/useMediaWithLoadProgress';
|
import useMediaWithLoadProgress from '../../../hooks/useMediaWithLoadProgress';
|
||||||
import usePreviousDeprecated from '../../../hooks/usePreviousDeprecated';
|
import usePreviousDeprecated from '../../../hooks/usePreviousDeprecated';
|
||||||
import useShowTransition from '../../../hooks/useShowTransition';
|
import useShowTransitionDeprecated from '../../../hooks/useShowTransitionDeprecated';
|
||||||
import useBlurredMediaThumbRef from './hooks/useBlurredMediaThumbRef';
|
import useBlurredMediaThumbRef from './hooks/useBlurredMediaThumbRef';
|
||||||
|
|
||||||
import Icon from '../../common/icons/Icon';
|
import Icon from '../../common/icons/Icon';
|
||||||
@ -101,7 +101,7 @@ const RoundVideo: FC<OwnProps> = ({
|
|||||||
const hasThumb = Boolean(getMessageMediaThumbDataUri(message));
|
const hasThumb = Boolean(getMessageMediaThumbDataUri(message));
|
||||||
const noThumb = !hasThumb || isPlayerReady || shouldRenderSpoiler;
|
const noThumb = !hasThumb || isPlayerReady || shouldRenderSpoiler;
|
||||||
const thumbRef = useBlurredMediaThumbRef(video, noThumb);
|
const thumbRef = useBlurredMediaThumbRef(video, noThumb);
|
||||||
const thumbClassNames = useMediaTransition(!noThumb);
|
const thumbClassNames = useMediaTransitionDeprecated(!noThumb);
|
||||||
const thumbDataUri = getMessageMediaThumbDataUri(message);
|
const thumbDataUri = getMessageMediaThumbDataUri(message);
|
||||||
const isTransferring = (isLoadAllowed && !isPlayerReady) || isDownloading;
|
const isTransferring = (isLoadAllowed && !isPlayerReady) || isDownloading;
|
||||||
const wasLoadDisabled = usePreviousDeprecated(isLoadAllowed) === false;
|
const wasLoadDisabled = usePreviousDeprecated(isLoadAllowed) === false;
|
||||||
@ -109,7 +109,7 @@ const RoundVideo: FC<OwnProps> = ({
|
|||||||
const {
|
const {
|
||||||
shouldRender: shouldSpinnerRender,
|
shouldRender: shouldSpinnerRender,
|
||||||
transitionClassNames: spinnerClassNames,
|
transitionClassNames: spinnerClassNames,
|
||||||
} = useShowTransition(isTransferring, undefined, wasLoadDisabled);
|
} = useShowTransitionDeprecated(isTransferring, undefined, wasLoadDisabled);
|
||||||
|
|
||||||
const [isActivated, setIsActivated] = useState(false);
|
const [isActivated, setIsActivated] = useState(false);
|
||||||
|
|
||||||
|
|||||||
@ -9,7 +9,7 @@ import buildClassName from '../../../util/buildClassName';
|
|||||||
|
|
||||||
import useFlag from '../../../hooks/useFlag';
|
import useFlag from '../../../hooks/useFlag';
|
||||||
import useLastCallback from '../../../hooks/useLastCallback';
|
import useLastCallback from '../../../hooks/useLastCallback';
|
||||||
import useShowTransition from '../../../hooks/useShowTransition';
|
import useShowTransitionDeprecated from '../../../hooks/useShowTransitionDeprecated';
|
||||||
|
|
||||||
import MessageContextMenu from './MessageContextMenu';
|
import MessageContextMenu from './MessageContextMenu';
|
||||||
|
|
||||||
@ -34,7 +34,7 @@ const SponsoredMessageContextMenuContainer: FC<OwnProps> = ({
|
|||||||
const { openPremiumModal, showDialog } = getActions();
|
const { openPremiumModal, showDialog } = getActions();
|
||||||
|
|
||||||
const [isMenuOpen, , closeMenu] = useFlag(true);
|
const [isMenuOpen, , closeMenu] = useFlag(true);
|
||||||
const { transitionClassNames } = useShowTransition(isMenuOpen, onCloseAnimationEnd, undefined, false);
|
const { transitionClassNames } = useShowTransitionDeprecated(isMenuOpen, onCloseAnimationEnd, undefined, false);
|
||||||
|
|
||||||
const handleAboutAdsOpen = useLastCallback(() => {
|
const handleAboutAdsOpen = useLastCallback(() => {
|
||||||
onAboutAdsClick();
|
onAboutAdsClick();
|
||||||
|
|||||||
@ -23,10 +23,10 @@ import useFlag from '../../../hooks/useFlag';
|
|||||||
import { useIsIntersecting } from '../../../hooks/useIntersectionObserver';
|
import { useIsIntersecting } from '../../../hooks/useIntersectionObserver';
|
||||||
import useLastCallback from '../../../hooks/useLastCallback';
|
import useLastCallback from '../../../hooks/useLastCallback';
|
||||||
import useMedia from '../../../hooks/useMedia';
|
import useMedia from '../../../hooks/useMedia';
|
||||||
import useMediaTransition from '../../../hooks/useMediaTransition';
|
import useMediaTransitionDeprecated from '../../../hooks/useMediaTransitionDeprecated';
|
||||||
import useMediaWithLoadProgress from '../../../hooks/useMediaWithLoadProgress';
|
import useMediaWithLoadProgress from '../../../hooks/useMediaWithLoadProgress';
|
||||||
import usePreviousDeprecated from '../../../hooks/usePreviousDeprecated';
|
import usePreviousDeprecated from '../../../hooks/usePreviousDeprecated';
|
||||||
import useShowTransition from '../../../hooks/useShowTransition';
|
import useShowTransitionDeprecated from '../../../hooks/useShowTransitionDeprecated';
|
||||||
import useBlurredMediaThumbRef from './hooks/useBlurredMediaThumbRef';
|
import useBlurredMediaThumbRef from './hooks/useBlurredMediaThumbRef';
|
||||||
|
|
||||||
import MediaSpoiler from '../../common/MediaSpoiler';
|
import MediaSpoiler from '../../common/MediaSpoiler';
|
||||||
@ -130,12 +130,12 @@ const Video = <T,>({
|
|||||||
const [isPreviewPreloaded] = useState(Boolean(previewMediaHash && mediaLoader.getFromMemory(previewMediaHash)));
|
const [isPreviewPreloaded] = useState(Boolean(previewMediaHash && mediaLoader.getFromMemory(previewMediaHash)));
|
||||||
const canLoadPreview = isIntersectingForLoading;
|
const canLoadPreview = isIntersectingForLoading;
|
||||||
const previewBlobUrl = useMedia(previewMediaHash, !canLoadPreview);
|
const previewBlobUrl = useMedia(previewMediaHash, !canLoadPreview);
|
||||||
const previewClassNames = useMediaTransition((hasThumb || previewBlobUrl) && !isPlayerReady);
|
const previewClassNames = useMediaTransitionDeprecated((hasThumb || previewBlobUrl) && !isPlayerReady);
|
||||||
|
|
||||||
const noThumb = Boolean(!hasThumb || previewBlobUrl || isPlayerReady);
|
const noThumb = Boolean(!hasThumb || previewBlobUrl || isPlayerReady);
|
||||||
const thumbRef = useBlurredMediaThumbRef(video, noThumb);
|
const thumbRef = useBlurredMediaThumbRef(video, noThumb);
|
||||||
const blurredBackgroundRef = useBlurredMediaThumbRef(video, !withBlurredBackground);
|
const blurredBackgroundRef = useBlurredMediaThumbRef(video, !withBlurredBackground);
|
||||||
const thumbClassNames = useMediaTransition(!noThumb);
|
const thumbClassNames = useMediaTransitionDeprecated(!noThumb);
|
||||||
|
|
||||||
const isInline = fullMediaData && wasIntersectedRef.current;
|
const isInline = fullMediaData && wasIntersectedRef.current;
|
||||||
|
|
||||||
@ -156,10 +156,10 @@ const Video = <T,>({
|
|||||||
const {
|
const {
|
||||||
shouldRender: shouldRenderSpinner,
|
shouldRender: shouldRenderSpinner,
|
||||||
transitionClassNames: spinnerClassNames,
|
transitionClassNames: spinnerClassNames,
|
||||||
} = useShowTransition(isTransferring && !isUnsupported, undefined, wasLoadDisabled);
|
} = useShowTransitionDeprecated(isTransferring && !isUnsupported, undefined, wasLoadDisabled);
|
||||||
const {
|
const {
|
||||||
transitionClassNames: playButtonClassNames,
|
transitionClassNames: playButtonClassNames,
|
||||||
} = useShowTransition(Boolean((isLoadAllowed || fullMediaData) && !isPlayAllowed && !shouldRenderSpinner));
|
} = useShowTransitionDeprecated(Boolean((isLoadAllowed || fullMediaData) && !isPlayAllowed && !shouldRenderSpinner));
|
||||||
|
|
||||||
const [playProgress, setPlayProgress] = useState<number>(0);
|
const [playProgress, setPlayProgress] = useState<number>(0);
|
||||||
const handleTimeUpdate = useLastCallback((e: React.SyntheticEvent<HTMLVideoElement>) => {
|
const handleTimeUpdate = useLastCallback((e: React.SyntheticEvent<HTMLVideoElement>) => {
|
||||||
|
|||||||
@ -11,7 +11,7 @@ import buildClassName from '../../../util/buildClassName';
|
|||||||
import useCurrentOrPrev from '../../../hooks/useCurrentOrPrev';
|
import useCurrentOrPrev from '../../../hooks/useCurrentOrPrev';
|
||||||
import useLastCallback from '../../../hooks/useLastCallback';
|
import useLastCallback from '../../../hooks/useLastCallback';
|
||||||
import useOldLang from '../../../hooks/useOldLang';
|
import useOldLang from '../../../hooks/useOldLang';
|
||||||
import useShowTransition from '../../../hooks/useShowTransition';
|
import useShowTransitionDeprecated from '../../../hooks/useShowTransitionDeprecated';
|
||||||
|
|
||||||
import Audio from '../../common/Audio';
|
import Audio from '../../common/Audio';
|
||||||
import RoundVideo from '../../middle/message/RoundVideo';
|
import RoundVideo from '../../middle/message/RoundVideo';
|
||||||
@ -36,7 +36,7 @@ const OneTimeMediaModal = ({
|
|||||||
const {
|
const {
|
||||||
shouldRender,
|
shouldRender,
|
||||||
transitionClassNames,
|
transitionClassNames,
|
||||||
} = useShowTransition(Boolean(modal));
|
} = useShowTransitionDeprecated(Boolean(modal));
|
||||||
|
|
||||||
const handlePlayVoice = useLastCallback(() => {
|
const handlePlayVoice = useLastCallback(() => {
|
||||||
return undefined;
|
return undefined;
|
||||||
|
|||||||
@ -43,9 +43,9 @@ import useEffectWithPrevDeps from '../../hooks/useEffectWithPrevDeps';
|
|||||||
import useFlag from '../../hooks/useFlag';
|
import useFlag from '../../hooks/useFlag';
|
||||||
import useLastCallback from '../../hooks/useLastCallback';
|
import useLastCallback from '../../hooks/useLastCallback';
|
||||||
import useLongPress from '../../hooks/useLongPress';
|
import useLongPress from '../../hooks/useLongPress';
|
||||||
import useMediaTransition from '../../hooks/useMediaTransition';
|
import useMediaTransitionDeprecated from '../../hooks/useMediaTransitionDeprecated';
|
||||||
import useOldLang from '../../hooks/useOldLang';
|
import useOldLang from '../../hooks/useOldLang';
|
||||||
import useShowTransition from '../../hooks/useShowTransition';
|
import useShowTransitionDeprecated from '../../hooks/useShowTransitionDeprecated';
|
||||||
import { useStreaming } from '../../hooks/useStreaming';
|
import { useStreaming } from '../../hooks/useStreaming';
|
||||||
import useBackgroundMode from '../../hooks/window/useBackgroundMode';
|
import useBackgroundMode from '../../hooks/window/useBackgroundMode';
|
||||||
import useStoryPreloader from './hooks/useStoryPreloader';
|
import useStoryPreloader from './hooks/useStoryPreloader';
|
||||||
@ -233,30 +233,30 @@ function Story({
|
|||||||
const {
|
const {
|
||||||
shouldRender: shouldRenderSkeleton,
|
shouldRender: shouldRenderSkeleton,
|
||||||
transitionClassNames: skeletonTransitionClassNames,
|
transitionClassNames: skeletonTransitionClassNames,
|
||||||
} = useShowTransition(!hasFullData);
|
} = useShowTransitionDeprecated(!hasFullData);
|
||||||
|
|
||||||
const {
|
const {
|
||||||
transitionClassNames: mediaTransitionClassNames,
|
transitionClassNames: mediaTransitionClassNames,
|
||||||
} = useShowTransition(Boolean(fullMediaData));
|
} = useShowTransitionDeprecated(Boolean(fullMediaData));
|
||||||
|
|
||||||
const thumbRef = useCanvasBlur(thumbnail, !hasThumb);
|
const thumbRef = useCanvasBlur(thumbnail, !hasThumb);
|
||||||
const previewTransitionClassNames = useMediaTransition(previewBlobUrl);
|
const previewTransitionClassNames = useMediaTransitionDeprecated(previewBlobUrl);
|
||||||
|
|
||||||
const {
|
const {
|
||||||
shouldRender: shouldRenderComposer,
|
shouldRender: shouldRenderComposer,
|
||||||
transitionClassNames: composerAppearanceAnimationClassNames,
|
transitionClassNames: composerAppearanceAnimationClassNames,
|
||||||
} = useShowTransition(shouldShowComposer);
|
} = useShowTransitionDeprecated(shouldShowComposer);
|
||||||
|
|
||||||
const {
|
const {
|
||||||
shouldRender: shouldRenderCaptionBackdrop,
|
shouldRender: shouldRenderCaptionBackdrop,
|
||||||
transitionClassNames: captionBackdropTransitionClassNames,
|
transitionClassNames: captionBackdropTransitionClassNames,
|
||||||
} = useShowTransition(hasText && isCaptionExpanded);
|
} = useShowTransitionDeprecated(hasText && isCaptionExpanded);
|
||||||
|
|
||||||
const { transitionClassNames: appearanceAnimationClassNames } = useShowTransition(true);
|
const { transitionClassNames: appearanceAnimationClassNames } = useShowTransitionDeprecated(true);
|
||||||
const {
|
const {
|
||||||
shouldRender: shouldRenderCaption,
|
shouldRender: shouldRenderCaption,
|
||||||
transitionClassNames: captionAppearanceAnimationClassNames,
|
transitionClassNames: captionAppearanceAnimationClassNames,
|
||||||
} = useShowTransition(hasText || hasForwardInfo);
|
} = useShowTransitionDeprecated(hasText || hasForwardInfo);
|
||||||
|
|
||||||
const isStreamingSupported = useStreaming(videoRef, fullMediaData, PRIMARY_VIDEO_MIME);
|
const isStreamingSupported = useStreaming(videoRef, fullMediaData, PRIMARY_VIDEO_MIME);
|
||||||
|
|
||||||
|
|||||||
@ -12,7 +12,7 @@ import calcTextLineHeightAndCount from '../../util/element/calcTextLineHeightAnd
|
|||||||
import useCurrentOrPrev from '../../hooks/useCurrentOrPrev';
|
import useCurrentOrPrev from '../../hooks/useCurrentOrPrev';
|
||||||
import useOldLang from '../../hooks/useOldLang';
|
import useOldLang from '../../hooks/useOldLang';
|
||||||
import usePrevDuringAnimation from '../../hooks/usePrevDuringAnimation';
|
import usePrevDuringAnimation from '../../hooks/usePrevDuringAnimation';
|
||||||
import useShowTransition from '../../hooks/useShowTransition';
|
import useShowTransitionDeprecated from '../../hooks/useShowTransitionDeprecated';
|
||||||
|
|
||||||
import EmbeddedStoryForward from '../common/embedded/EmbeddedStoryForward';
|
import EmbeddedStoryForward from '../common/embedded/EmbeddedStoryForward';
|
||||||
import MessageText from '../common/MessageText';
|
import MessageText from '../common/MessageText';
|
||||||
@ -65,7 +65,7 @@ function StoryCaption({
|
|||||||
}, [isExpanded]);
|
}, [isExpanded]);
|
||||||
|
|
||||||
const canExpand = hasOverflow && !isInExpandedState;
|
const canExpand = hasOverflow && !isInExpandedState;
|
||||||
const { shouldRender: shouldRenderShowMore, transitionClassNames } = useShowTransition(
|
const { shouldRender: shouldRenderShowMore, transitionClassNames } = useShowTransitionDeprecated(
|
||||||
canExpand, undefined, true, 'slow', true,
|
canExpand, undefined, true, 'slow', true,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|||||||
@ -10,7 +10,7 @@ import { animateClosing, animateOpening, ANIMATION_DURATION } from './helpers/ri
|
|||||||
|
|
||||||
import { dispatchHeavyAnimationEvent } from '../../hooks/useHeavyAnimationCheck';
|
import { dispatchHeavyAnimationEvent } from '../../hooks/useHeavyAnimationCheck';
|
||||||
import useOldLang from '../../hooks/useOldLang';
|
import useOldLang from '../../hooks/useOldLang';
|
||||||
import useShowTransition from '../../hooks/useShowTransition';
|
import useShowTransitionDeprecated from '../../hooks/useShowTransitionDeprecated';
|
||||||
import useStoryPreloader from './hooks/useStoryPreloader';
|
import useStoryPreloader from './hooks/useStoryPreloader';
|
||||||
|
|
||||||
import Avatar from '../common/Avatar';
|
import Avatar from '../common/Avatar';
|
||||||
@ -89,7 +89,7 @@ function StoryToggler({
|
|||||||
|
|
||||||
const isVisible = canShow && isShown;
|
const isVisible = canShow && isShown;
|
||||||
// For some reason, setting 'slow' here also fixes scroll freezes on iOS when collapsing Story Ribbon
|
// For some reason, setting 'slow' here also fixes scroll freezes on iOS when collapsing Story Ribbon
|
||||||
const { shouldRender, transitionClassNames } = useShowTransition(isVisible, undefined, undefined, 'slow');
|
const { shouldRender, transitionClassNames } = useShowTransitionDeprecated(isVisible, undefined, undefined, 'slow');
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (!withAnimation || isForumPanelOpen) return;
|
if (!withAnimation || isForumPanelOpen) return;
|
||||||
|
|||||||
@ -115,7 +115,6 @@ const DropdownMenu: FC<OwnProps> = ({
|
|||||||
footer={footer}
|
footer={footer}
|
||||||
autoClose
|
autoClose
|
||||||
onClose={handleClose}
|
onClose={handleClose}
|
||||||
shouldSkipTransition={forceOpen}
|
|
||||||
onCloseAnimationEnd={onHide}
|
onCloseAnimationEnd={onHide}
|
||||||
onMouseEnterBackdrop={onMouseEnterBackdrop}
|
onMouseEnterBackdrop={onMouseEnterBackdrop}
|
||||||
>
|
>
|
||||||
|
|||||||
@ -1,6 +1,4 @@
|
|||||||
import React, {
|
import React, { type FC, memo, useEffect } from '../../lib/teact/teact';
|
||||||
type FC, memo, useEffect, useRef,
|
|
||||||
} from '../../lib/teact/teact';
|
|
||||||
|
|
||||||
import buildClassName from '../../util/buildClassName';
|
import buildClassName from '../../util/buildClassName';
|
||||||
import buildStyle from '../../util/buildStyle';
|
import buildStyle from '../../util/buildStyle';
|
||||||
@ -38,7 +36,6 @@ type OwnProps = {
|
|||||||
positionX?: 'left' | 'right';
|
positionX?: 'left' | 'right';
|
||||||
positionY?: 'top' | 'bottom';
|
positionY?: 'top' | 'bottom';
|
||||||
autoClose?: boolean;
|
autoClose?: boolean;
|
||||||
shouldSkipTransition?: boolean;
|
|
||||||
footer?: string;
|
footer?: string;
|
||||||
noCloseOnBackdrop?: boolean;
|
noCloseOnBackdrop?: boolean;
|
||||||
backdropExcludedSelector?: string;
|
backdropExcludedSelector?: string;
|
||||||
@ -50,13 +47,13 @@ type OwnProps = {
|
|||||||
onMouseEnterBackdrop?: (e: React.MouseEvent<HTMLDivElement, MouseEvent>) => void;
|
onMouseEnterBackdrop?: (e: React.MouseEvent<HTMLDivElement, MouseEvent>) => void;
|
||||||
onMouseLeave?: (e: React.MouseEvent<HTMLDivElement, MouseEvent>) => void;
|
onMouseLeave?: (e: React.MouseEvent<HTMLDivElement, MouseEvent>) => void;
|
||||||
withPortal?: boolean;
|
withPortal?: boolean;
|
||||||
children: React.ReactNode;
|
children?: React.ReactNode;
|
||||||
};
|
};
|
||||||
|
|
||||||
const ANIMATION_DURATION = 200;
|
const ANIMATION_DURATION = 200;
|
||||||
|
|
||||||
const Menu: FC<OwnProps> = ({
|
const Menu: FC<OwnProps> = ({
|
||||||
ref,
|
ref: externalRef,
|
||||||
containerRef,
|
containerRef,
|
||||||
shouldCloseFast,
|
shouldCloseFast,
|
||||||
isOpen,
|
isOpen,
|
||||||
@ -80,27 +77,18 @@ const Menu: FC<OwnProps> = ({
|
|||||||
onClose,
|
onClose,
|
||||||
onMouseEnter,
|
onMouseEnter,
|
||||||
onMouseLeave,
|
onMouseLeave,
|
||||||
shouldSkipTransition,
|
|
||||||
withPortal,
|
withPortal,
|
||||||
onMouseEnterBackdrop,
|
onMouseEnterBackdrop,
|
||||||
}) => {
|
}) => {
|
||||||
// eslint-disable-next-line no-null/no-null
|
|
||||||
let menuRef = useRef<HTMLDivElement>(null);
|
|
||||||
if (ref) {
|
|
||||||
menuRef = ref;
|
|
||||||
}
|
|
||||||
const backdropContainerRef = containerRef || menuRef;
|
|
||||||
const { isTouchScreen } = useAppLayout();
|
const { isTouchScreen } = useAppLayout();
|
||||||
|
|
||||||
const {
|
const { ref: menuRef } = useShowTransition({
|
||||||
transitionClassNames,
|
|
||||||
} = useShowTransition(
|
|
||||||
isOpen,
|
isOpen,
|
||||||
|
ref: externalRef,
|
||||||
onCloseAnimationEnd,
|
onCloseAnimationEnd,
|
||||||
shouldSkipTransition,
|
});
|
||||||
undefined,
|
|
||||||
shouldSkipTransition,
|
const backdropContainerRef = containerRef || menuRef;
|
||||||
);
|
|
||||||
|
|
||||||
useEffect(
|
useEffect(
|
||||||
() => (isOpen ? captureEscKeyListener(onClose) : undefined),
|
() => (isOpen ? captureEscKeyListener(onClose) : undefined),
|
||||||
@ -134,7 +122,6 @@ const Menu: FC<OwnProps> = ({
|
|||||||
positionY,
|
positionY,
|
||||||
positionX,
|
positionX,
|
||||||
footer && 'with-footer',
|
footer && 'with-footer',
|
||||||
transitionClassNames,
|
|
||||||
bubbleClassName,
|
bubbleClassName,
|
||||||
shouldCloseFast && 'close-fast',
|
shouldCloseFast && 'close-fast',
|
||||||
);
|
);
|
||||||
@ -144,7 +131,9 @@ const Menu: FC<OwnProps> = ({
|
|||||||
|
|
||||||
const handleClick = useLastCallback((e: React.MouseEvent<HTMLDivElement>) => {
|
const handleClick = useLastCallback((e: React.MouseEvent<HTMLDivElement>) => {
|
||||||
e.stopPropagation();
|
e.stopPropagation();
|
||||||
if (autoClose) { onClose(); }
|
if (autoClose) {
|
||||||
|
onClose();
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
const menu = (
|
const menu = (
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
import type { FC, TeactNode } from '../../lib/teact/teact';
|
import type { FC, TeactNode } from '../../lib/teact/teact';
|
||||||
import React, { useEffect, useRef } from '../../lib/teact/teact';
|
import React, { useEffect } from '../../lib/teact/teact';
|
||||||
|
|
||||||
import type { TextPart } from '../../types';
|
import type { TextPart } from '../../types';
|
||||||
|
|
||||||
@ -9,6 +9,7 @@ import { disableDirectTextInput, enableDirectTextInput } from '../../util/direct
|
|||||||
import freezeWhenClosed from '../../util/hoc/freezeWhenClosed';
|
import freezeWhenClosed from '../../util/hoc/freezeWhenClosed';
|
||||||
import trapFocus from '../../util/trapFocus';
|
import trapFocus from '../../util/trapFocus';
|
||||||
|
|
||||||
|
import useDerivedState from '../../hooks/useDerivedState';
|
||||||
import { dispatchHeavyAnimationEvent } from '../../hooks/useHeavyAnimationCheck';
|
import { dispatchHeavyAnimationEvent } from '../../hooks/useHeavyAnimationCheck';
|
||||||
import useHistoryBack from '../../hooks/useHistoryBack';
|
import useHistoryBack from '../../hooks/useHistoryBack';
|
||||||
import useLastCallback from '../../hooks/useLastCallback';
|
import useLastCallback from '../../hooks/useLastCallback';
|
||||||
@ -44,11 +45,7 @@ export type OwnProps = {
|
|||||||
onEnter?: () => void;
|
onEnter?: () => void;
|
||||||
};
|
};
|
||||||
|
|
||||||
type StateProps = {
|
const Modal: FC<OwnProps> = ({
|
||||||
shouldSkipHistoryAnimations?: boolean;
|
|
||||||
};
|
|
||||||
|
|
||||||
const Modal: FC<OwnProps & StateProps> = ({
|
|
||||||
dialogRef,
|
dialogRef,
|
||||||
title,
|
title,
|
||||||
className,
|
className,
|
||||||
@ -63,19 +60,19 @@ const Modal: FC<OwnProps & StateProps> = ({
|
|||||||
noBackdropClose,
|
noBackdropClose,
|
||||||
children,
|
children,
|
||||||
style,
|
style,
|
||||||
shouldSkipHistoryAnimations,
|
|
||||||
onClose,
|
onClose,
|
||||||
onCloseAnimationEnd,
|
onCloseAnimationEnd,
|
||||||
onEnter,
|
onEnter,
|
||||||
}) => {
|
}) => {
|
||||||
const {
|
const {
|
||||||
shouldRender,
|
ref: modalRef,
|
||||||
transitionClassNames,
|
getShouldRender,
|
||||||
} = useShowTransition(
|
} = useShowTransition({
|
||||||
isOpen, onCloseAnimationEnd, shouldSkipHistoryAnimations, undefined, shouldSkipHistoryAnimations,
|
isOpen,
|
||||||
);
|
onCloseAnimationEnd,
|
||||||
// eslint-disable-next-line no-null/no-null
|
});
|
||||||
const modalRef = useRef<HTMLDivElement>(null);
|
const shouldRender = useDerivedState(getShouldRender);
|
||||||
|
|
||||||
const withCloseButton = hasCloseButton || hasAbsoluteCloseButton;
|
const withCloseButton = hasCloseButton || hasAbsoluteCloseButton;
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
@ -101,7 +98,7 @@ const Modal: FC<OwnProps & StateProps> = ({
|
|||||||
useEffect(() => (
|
useEffect(() => (
|
||||||
isOpen ? captureKeyboardListeners({ onEsc: onClose, onEnter: handleEnter }) : undefined
|
isOpen ? captureKeyboardListeners({ onEsc: onClose, onEnter: handleEnter }) : undefined
|
||||||
), [isOpen, onClose, handleEnter]);
|
), [isOpen, onClose, handleEnter]);
|
||||||
useEffect(() => (isOpen && modalRef.current ? trapFocus(modalRef.current) : undefined), [isOpen]);
|
useEffect(() => (isOpen && modalRef.current ? trapFocus(modalRef.current) : undefined), [isOpen, modalRef]);
|
||||||
|
|
||||||
useHistoryBack({
|
useHistoryBack({
|
||||||
isActive: isOpen,
|
isActive: isOpen,
|
||||||
@ -155,7 +152,6 @@ const Modal: FC<OwnProps & StateProps> = ({
|
|||||||
const fullClassName = buildClassName(
|
const fullClassName = buildClassName(
|
||||||
'Modal',
|
'Modal',
|
||||||
className,
|
className,
|
||||||
transitionClassNames,
|
|
||||||
noBackdrop && 'transparent-backdrop',
|
noBackdrop && 'transparent-backdrop',
|
||||||
isSlim && 'slim',
|
isSlim && 'slim',
|
||||||
);
|
);
|
||||||
|
|||||||
@ -14,7 +14,7 @@ import { ANIMATION_END_DELAY } from '../../config';
|
|||||||
import buildClassName from '../../util/buildClassName';
|
import buildClassName from '../../util/buildClassName';
|
||||||
import captureEscKeyListener from '../../util/captureEscKeyListener';
|
import captureEscKeyListener from '../../util/captureEscKeyListener';
|
||||||
|
|
||||||
import useShowTransition from '../../hooks/useShowTransition';
|
import useShowTransitionDeprecated from '../../hooks/useShowTransitionDeprecated';
|
||||||
|
|
||||||
import Button from './Button';
|
import Button from './Button';
|
||||||
import Portal from './Portal';
|
import Portal from './Portal';
|
||||||
@ -45,7 +45,7 @@ const Notification: FC<OwnProps> = ({
|
|||||||
const [isOpen, setIsOpen] = useState(true);
|
const [isOpen, setIsOpen] = useState(true);
|
||||||
// eslint-disable-next-line no-null/no-null
|
// eslint-disable-next-line no-null/no-null
|
||||||
const timerRef = useRef<number | undefined>(null);
|
const timerRef = useRef<number | undefined>(null);
|
||||||
const { transitionClassNames } = useShowTransition(isOpen);
|
const { transitionClassNames } = useShowTransitionDeprecated(isOpen);
|
||||||
|
|
||||||
const closeAndDismiss = useCallback(() => {
|
const closeAndDismiss = useCallback(() => {
|
||||||
setIsOpen(false);
|
setIsOpen(false);
|
||||||
|
|||||||
@ -1,8 +1,7 @@
|
|||||||
import type { FC } from '../../lib/teact/teact';
|
import type { FC } from '../../lib/teact/teact';
|
||||||
import React, { useRef } from '../../lib/teact/teact';
|
import React, { useRef } from '../../lib/teact/teact';
|
||||||
|
|
||||||
import buildClassName from '../../util/buildClassName';
|
import useDerivedState from '../../hooks/useDerivedState';
|
||||||
|
|
||||||
import usePreviousDeprecated from '../../hooks/usePreviousDeprecated';
|
import usePreviousDeprecated from '../../hooks/usePreviousDeprecated';
|
||||||
import useShowTransition from '../../hooks/useShowTransition';
|
import useShowTransition from '../../hooks/useShowTransition';
|
||||||
|
|
||||||
@ -17,7 +16,7 @@ type OwnProps = {
|
|||||||
shouldAnimateFirstRender?: boolean;
|
shouldAnimateFirstRender?: boolean;
|
||||||
style?: string;
|
style?: string;
|
||||||
children: React.ReactNode;
|
children: React.ReactNode;
|
||||||
ref?: React.LegacyRef<HTMLDivElement>;
|
ref?: React.RefObject<HTMLDivElement>;
|
||||||
};
|
};
|
||||||
|
|
||||||
const ShowTransition: FC<OwnProps> = ({
|
const ShowTransition: FC<OwnProps> = ({
|
||||||
@ -31,22 +30,21 @@ const ShowTransition: FC<OwnProps> = ({
|
|||||||
noCloseTransition,
|
noCloseTransition,
|
||||||
shouldAnimateFirstRender,
|
shouldAnimateFirstRender,
|
||||||
style,
|
style,
|
||||||
ref,
|
ref: externalRef,
|
||||||
}) => {
|
}) => {
|
||||||
const prevIsOpen = usePreviousDeprecated(isOpen);
|
const prevIsOpen = usePreviousDeprecated(isOpen);
|
||||||
const prevChildren = usePreviousDeprecated(children);
|
const prevChildren = usePreviousDeprecated(children);
|
||||||
const fromChildrenRef = useRef<React.ReactNode>();
|
const fromChildrenRef = useRef<React.ReactNode>();
|
||||||
const isFirstRender = prevIsOpen === undefined;
|
const isFirstRender = prevIsOpen === undefined;
|
||||||
const {
|
|
||||||
shouldRender,
|
const { ref, getShouldRender } = useShowTransition({
|
||||||
transitionClassNames,
|
isOpen: isOpen && !isHidden,
|
||||||
} = useShowTransition(
|
ref: externalRef,
|
||||||
isOpen && !isHidden,
|
noMountTransition: isFirstRender && !shouldAnimateFirstRender,
|
||||||
undefined,
|
className: isCustom ? false : undefined,
|
||||||
isFirstRender && !shouldAnimateFirstRender,
|
|
||||||
isCustom ? false : undefined,
|
|
||||||
noCloseTransition,
|
noCloseTransition,
|
||||||
);
|
});
|
||||||
|
const shouldRender = useDerivedState(getShouldRender);
|
||||||
|
|
||||||
if (prevIsOpen && !isOpen) {
|
if (prevIsOpen && !isOpen) {
|
||||||
fromChildrenRef.current = prevChildren;
|
fromChildrenRef.current = prevChildren;
|
||||||
@ -57,7 +55,7 @@ const ShowTransition: FC<OwnProps> = ({
|
|||||||
<div
|
<div
|
||||||
id={id}
|
id={id}
|
||||||
ref={ref}
|
ref={ref}
|
||||||
className={buildClassName(className, transitionClassNames)}
|
className={className}
|
||||||
onClick={onClick}
|
onClick={onClick}
|
||||||
style={style}
|
style={style}
|
||||||
>
|
>
|
||||||
|
|||||||
@ -1,8 +1,17 @@
|
|||||||
import useShowTransition from './useShowTransition';
|
import useShowTransition from './useShowTransition';
|
||||||
|
|
||||||
export default function useMediaTransition(mediaData?: unknown) {
|
export default function useMediaTransition<RefType extends HTMLElement = HTMLDivElement>(
|
||||||
|
mediaData?: unknown,
|
||||||
|
options?: Partial<Parameters<typeof useShowTransition<RefType>>[0]>,
|
||||||
|
) {
|
||||||
const isMediaReady = Boolean(mediaData);
|
const isMediaReady = Boolean(mediaData);
|
||||||
const { transitionClassNames } = useShowTransition(isMediaReady, undefined, isMediaReady, 'slow');
|
|
||||||
|
|
||||||
return transitionClassNames;
|
const { ref } = useShowTransition<RefType>({
|
||||||
|
isOpen: isMediaReady,
|
||||||
|
noMountTransition: isMediaReady,
|
||||||
|
className: 'slow',
|
||||||
|
...options,
|
||||||
|
});
|
||||||
|
|
||||||
|
return ref;
|
||||||
}
|
}
|
||||||
|
|||||||
8
src/hooks/useMediaTransitionDeprecated.ts
Normal file
8
src/hooks/useMediaTransitionDeprecated.ts
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
import useShowTransitionDeprecated from './useShowTransitionDeprecated';
|
||||||
|
|
||||||
|
export default function useMediaTransitionDeprecated(mediaData?: unknown) {
|
||||||
|
const isMediaReady = Boolean(mediaData);
|
||||||
|
const { transitionClassNames } = useShowTransitionDeprecated(isMediaReady, undefined, isMediaReady, 'slow');
|
||||||
|
|
||||||
|
return transitionClassNames;
|
||||||
|
}
|
||||||
@ -1,75 +1,103 @@
|
|||||||
import { useRef, useState } from '../lib/teact/teact';
|
import type { RefObject } from 'react';
|
||||||
|
import { useLayoutEffect, useRef, useSignal } from '../lib/teact/teact';
|
||||||
|
import { addExtraClass, toggleExtraClass } from '../lib/teact/teact-dom';
|
||||||
|
|
||||||
import buildClassName from '../util/buildClassName';
|
import { requestMeasure } from '../lib/fasterdom/fasterdom';
|
||||||
|
import useDerivedSignal from './useDerivedSignal';
|
||||||
|
import useLastCallback from './useLastCallback';
|
||||||
|
import { useStateRef } from './useStateRef';
|
||||||
|
import useSyncEffectWithPrevDeps from './useSyncEffectWithPrevDeps';
|
||||||
|
|
||||||
const CLOSE_DURATION = 350;
|
const CLOSE_DURATION = 350;
|
||||||
|
|
||||||
const useShowTransition = (
|
type State =
|
||||||
isOpen = false,
|
'closed'
|
||||||
onCloseTransitionEnd?: () => void,
|
| 'scheduled-open'
|
||||||
noFirstOpenTransition = false,
|
| 'open'
|
||||||
className: string | false = 'fast',
|
| 'closing';
|
||||||
|
|
||||||
|
export default function useShowTransition<RefType extends HTMLElement = HTMLDivElement>({
|
||||||
|
isOpen,
|
||||||
|
ref,
|
||||||
|
noMountTransition = false,
|
||||||
|
noOpenTransition = false,
|
||||||
noCloseTransition = false,
|
noCloseTransition = false,
|
||||||
closeDuration = CLOSE_DURATION,
|
closeDuration = CLOSE_DURATION,
|
||||||
noOpenTransition = false,
|
className = 'fast',
|
||||||
) => {
|
prefix = '',
|
||||||
const [isClosed, setIsClosed] = useState(!isOpen);
|
onCloseAnimationEnd,
|
||||||
const closeTimeoutRef = useRef<number>();
|
}: {
|
||||||
// СSS class should be added in a separate tick to turn on CSS transition.
|
isOpen: boolean | undefined;
|
||||||
const [hasOpenClassName, setHasOpenClassName] = useState(isOpen && noFirstOpenTransition);
|
ref?: RefObject<RefType>;
|
||||||
|
noMountTransition?: boolean;
|
||||||
|
noOpenTransition?: boolean;
|
||||||
|
noCloseTransition?: boolean;
|
||||||
|
closeDuration?: number;
|
||||||
|
className?: string | false;
|
||||||
|
prefix?: string;
|
||||||
|
onCloseAnimationEnd?: NoneToVoidFunction;
|
||||||
|
}) {
|
||||||
|
// eslint-disable-next-line no-null/no-null
|
||||||
|
const localRef = useRef<RefType>(null);
|
||||||
|
ref ||= localRef;
|
||||||
|
const closingTimeoutRef = useRef<number>();
|
||||||
|
const [getState, setState] = useSignal<State | undefined>();
|
||||||
|
const optionsRef = useStateRef({
|
||||||
|
closeDuration, noMountTransition, noOpenTransition, noCloseTransition,
|
||||||
|
});
|
||||||
|
const onCloseEndLast = useLastCallback(onCloseAnimationEnd);
|
||||||
|
|
||||||
if (isOpen) {
|
useSyncEffectWithPrevDeps(([prevIsOpen]) => {
|
||||||
setIsClosed(false);
|
const options = optionsRef.current;
|
||||||
setHasOpenClassName(true);
|
|
||||||
|
|
||||||
if (closeTimeoutRef.current) {
|
if (isOpen) {
|
||||||
window.clearTimeout(closeTimeoutRef.current);
|
if (closingTimeoutRef.current) {
|
||||||
|
clearTimeout(closingTimeoutRef.current);
|
||||||
closeTimeoutRef.current = undefined;
|
closingTimeoutRef.current = undefined;
|
||||||
}
|
|
||||||
} else {
|
|
||||||
setHasOpenClassName(false);
|
|
||||||
|
|
||||||
if (!isClosed && !closeTimeoutRef.current) {
|
|
||||||
const exec = () => {
|
|
||||||
setIsClosed(true);
|
|
||||||
|
|
||||||
if (onCloseTransitionEnd) {
|
|
||||||
onCloseTransitionEnd();
|
|
||||||
}
|
|
||||||
|
|
||||||
closeTimeoutRef.current = undefined;
|
|
||||||
};
|
|
||||||
|
|
||||||
if (noCloseTransition) {
|
|
||||||
exec();
|
|
||||||
} else {
|
|
||||||
closeTimeoutRef.current = window.setTimeout(exec, closeDuration);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (options.noOpenTransition || (prevIsOpen === undefined && options.noMountTransition)) {
|
||||||
|
setState('open');
|
||||||
|
} else {
|
||||||
|
setState('scheduled-open');
|
||||||
|
requestMeasure(() => {
|
||||||
|
setState('open');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
} else if (prevIsOpen === undefined || options.noCloseTransition) {
|
||||||
|
setState('closed');
|
||||||
|
} else {
|
||||||
|
setState('closing');
|
||||||
|
|
||||||
|
closingTimeoutRef.current = window.setTimeout(() => {
|
||||||
|
setState('closed');
|
||||||
|
onCloseEndLast();
|
||||||
|
}, options.closeDuration);
|
||||||
}
|
}
|
||||||
}
|
}, [isOpen]);
|
||||||
|
|
||||||
// `noCloseTransition`, when set to true, should remove the open class immediately
|
useLayoutEffect(() => {
|
||||||
const shouldHaveOpenClassName = (hasOpenClassName && !(noCloseTransition && !isOpen)) || (noOpenTransition && isOpen);
|
const element = ref.current;
|
||||||
const isClosing = Boolean(closeTimeoutRef.current);
|
if (!element) return;
|
||||||
const shouldRender = isOpen || isClosing;
|
|
||||||
const transitionClassNames = buildClassName(
|
|
||||||
className && 'opacity-transition',
|
|
||||||
className,
|
|
||||||
shouldHaveOpenClassName && 'open',
|
|
||||||
!shouldHaveOpenClassName && 'not-open',
|
|
||||||
shouldRender && 'shown',
|
|
||||||
!shouldRender && 'not-shown',
|
|
||||||
isClosing && 'closing',
|
|
||||||
);
|
|
||||||
|
|
||||||
return {
|
addExtraClass(element, 'opacity-transition');
|
||||||
shouldRender,
|
if (className !== false) {
|
||||||
transitionClassNames,
|
addExtraClass(element, className);
|
||||||
hasShownClass: shouldRender,
|
}
|
||||||
hasOpenClass: shouldHaveOpenClassName,
|
|
||||||
isClosing,
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
export default useShowTransition;
|
const state = getState();
|
||||||
|
const shouldRender = state !== 'closed';
|
||||||
|
const hasOpenClass = state === 'open';
|
||||||
|
const isClosing = state === 'closing';
|
||||||
|
|
||||||
|
toggleExtraClass(element, `${prefix}shown`, shouldRender);
|
||||||
|
toggleExtraClass(element, `${prefix}not-shown`, !shouldRender);
|
||||||
|
toggleExtraClass(element, `${prefix}open`, hasOpenClass);
|
||||||
|
toggleExtraClass(element, `${prefix}not-open`, !hasOpenClass);
|
||||||
|
toggleExtraClass(element, `${prefix}closing`, isClosing);
|
||||||
|
}, [className, getState, prefix, ref]);
|
||||||
|
|
||||||
|
const getShouldRender = useDerivedSignal(() => getState() !== 'closed', [getState]);
|
||||||
|
|
||||||
|
return { ref, getShouldRender };
|
||||||
|
}
|
||||||
|
|||||||
75
src/hooks/useShowTransitionDeprecated.ts
Normal file
75
src/hooks/useShowTransitionDeprecated.ts
Normal file
@ -0,0 +1,75 @@
|
|||||||
|
import { useRef, useState } from '../lib/teact/teact';
|
||||||
|
|
||||||
|
import buildClassName from '../util/buildClassName';
|
||||||
|
|
||||||
|
const CLOSE_DURATION = 350;
|
||||||
|
|
||||||
|
const useShowTransitionDeprecated = (
|
||||||
|
isOpen = false,
|
||||||
|
onCloseTransitionEnd?: () => void,
|
||||||
|
noFirstOpenTransition = false,
|
||||||
|
className: string | false = 'fast',
|
||||||
|
noCloseTransition = false,
|
||||||
|
closeDuration = CLOSE_DURATION,
|
||||||
|
noOpenTransition = false,
|
||||||
|
) => {
|
||||||
|
const [isClosed, setIsClosed] = useState(!isOpen);
|
||||||
|
const closeTimeoutRef = useRef<number>();
|
||||||
|
// СSS class should be added in a separate tick to turn on CSS transition.
|
||||||
|
const [hasOpenClassName, setHasOpenClassName] = useState(isOpen && noFirstOpenTransition);
|
||||||
|
|
||||||
|
if (isOpen) {
|
||||||
|
setIsClosed(false);
|
||||||
|
setHasOpenClassName(true);
|
||||||
|
|
||||||
|
if (closeTimeoutRef.current) {
|
||||||
|
window.clearTimeout(closeTimeoutRef.current);
|
||||||
|
|
||||||
|
closeTimeoutRef.current = undefined;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
setHasOpenClassName(false);
|
||||||
|
|
||||||
|
if (!isClosed && !closeTimeoutRef.current) {
|
||||||
|
const exec = () => {
|
||||||
|
setIsClosed(true);
|
||||||
|
|
||||||
|
if (onCloseTransitionEnd) {
|
||||||
|
onCloseTransitionEnd();
|
||||||
|
}
|
||||||
|
|
||||||
|
closeTimeoutRef.current = undefined;
|
||||||
|
};
|
||||||
|
|
||||||
|
if (noCloseTransition) {
|
||||||
|
exec();
|
||||||
|
} else {
|
||||||
|
closeTimeoutRef.current = window.setTimeout(exec, closeDuration);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// `noCloseTransition`, when set to true, should remove the open class immediately
|
||||||
|
const shouldHaveOpenClassName = (hasOpenClassName && !(noCloseTransition && !isOpen)) || (noOpenTransition && isOpen);
|
||||||
|
const isClosing = Boolean(closeTimeoutRef.current);
|
||||||
|
const shouldRender = isOpen || isClosing;
|
||||||
|
const transitionClassNames = buildClassName(
|
||||||
|
className && 'opacity-transition',
|
||||||
|
className,
|
||||||
|
shouldHaveOpenClassName && 'open',
|
||||||
|
!shouldHaveOpenClassName && 'not-open',
|
||||||
|
shouldRender && 'shown',
|
||||||
|
!shouldRender && 'not-shown',
|
||||||
|
isClosing && 'closing',
|
||||||
|
);
|
||||||
|
|
||||||
|
return {
|
||||||
|
shouldRender,
|
||||||
|
transitionClassNames,
|
||||||
|
hasShownClass: shouldRender,
|
||||||
|
hasOpenClass: shouldHaveOpenClassName,
|
||||||
|
isClosing,
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
export default useShowTransitionDeprecated;
|
||||||
19
src/hooks/useSyncEffectWithPrevDeps.ts
Normal file
19
src/hooks/useSyncEffectWithPrevDeps.ts
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
import { useRef } from '../lib/teact/teact';
|
||||||
|
|
||||||
|
import useSyncEffect from './useSyncEffect';
|
||||||
|
|
||||||
|
const useLayoutEffectWithPrevDeps = <const T extends readonly any[]>(
|
||||||
|
cb: (args: T | readonly []) => void, dependencies: T,
|
||||||
|
) => {
|
||||||
|
const prevDepsRef = useRef<T>();
|
||||||
|
|
||||||
|
return useSyncEffect(() => {
|
||||||
|
const prevDeps = prevDepsRef.current;
|
||||||
|
prevDepsRef.current = dependencies;
|
||||||
|
|
||||||
|
return cb(prevDeps || []);
|
||||||
|
// eslint-disable-next-line react-hooks-static-deps/exhaustive-deps
|
||||||
|
}, dependencies);
|
||||||
|
};
|
||||||
|
|
||||||
|
export default useLayoutEffectWithPrevDeps;
|
||||||
Loading…
x
Reference in New Issue
Block a user