[Refactoring] usePrevious2 → usePrevious, usePrevious → usePreviousDeprecated
This commit is contained in:
parent
45b81c104a
commit
2136302d52
@ -20,7 +20,7 @@ import { updateSizes } from '../util/windowSize';
|
|||||||
|
|
||||||
import useAppLayout from '../hooks/useAppLayout';
|
import useAppLayout from '../hooks/useAppLayout';
|
||||||
import useFlag from '../hooks/useFlag';
|
import useFlag from '../hooks/useFlag';
|
||||||
import usePrevious from '../hooks/usePrevious';
|
import usePreviousDeprecated from '../hooks/usePreviousDeprecated';
|
||||||
|
|
||||||
// import Test from './test/TestLocale';
|
// import Test from './test/TestLocale';
|
||||||
import Auth from './auth/Auth';
|
import Auth from './auth/Auth';
|
||||||
@ -180,7 +180,7 @@ const App: FC<StateProps> = ({
|
|||||||
}
|
}
|
||||||
}, [isInactiveAuth, markInactive, unmarkInactive]);
|
}, [isInactiveAuth, markInactive, unmarkInactive]);
|
||||||
|
|
||||||
const prevActiveKey = usePrevious(activeKey);
|
const prevActiveKey = usePreviousDeprecated(activeKey);
|
||||||
|
|
||||||
// eslint-disable-next-line consistent-return
|
// eslint-disable-next-line consistent-return
|
||||||
function renderContent() {
|
function renderContent() {
|
||||||
|
|||||||
@ -12,7 +12,7 @@ import { vibrateShort } from '../../../util/vibrate';
|
|||||||
import { LOCAL_TGS_URLS } from '../../common/helpers/animatedAssets';
|
import { LOCAL_TGS_URLS } from '../../common/helpers/animatedAssets';
|
||||||
|
|
||||||
import useOldLang from '../../../hooks/useOldLang';
|
import useOldLang from '../../../hooks/useOldLang';
|
||||||
import usePrevious from '../../../hooks/usePrevious';
|
import usePreviousDeprecated from '../../../hooks/usePreviousDeprecated';
|
||||||
|
|
||||||
import AnimatedIcon from '../../common/AnimatedIcon';
|
import AnimatedIcon from '../../common/AnimatedIcon';
|
||||||
import Button from '../../ui/Button';
|
import Button from '../../ui/Button';
|
||||||
@ -57,7 +57,7 @@ const MicrophoneButton: FC<OwnProps & StateProps> = ({
|
|||||||
const [isRequestingToSpeak, setIsRequestingToSpeak] = useState(false);
|
const [isRequestingToSpeak, setIsRequestingToSpeak] = useState(false);
|
||||||
const isConnecting = connectionState !== 'connected';
|
const isConnecting = connectionState !== 'connected';
|
||||||
const shouldRaiseHand = !canSelfUnmute && isMuted;
|
const shouldRaiseHand = !canSelfUnmute && isMuted;
|
||||||
const prevShouldRaiseHand = usePrevious(shouldRaiseHand);
|
const prevShouldRaiseHand = usePreviousDeprecated(shouldRaiseHand);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (prevShouldRaiseHand && !shouldRaiseHand) {
|
if (prevShouldRaiseHand && !shouldRaiseHand) {
|
||||||
|
|||||||
@ -6,7 +6,7 @@ import type { GroupCallParticipant } from '../../../lib/secret-sauce';
|
|||||||
import { THRESHOLD } from '../../../lib/secret-sauce';
|
import { THRESHOLD } from '../../../lib/secret-sauce';
|
||||||
import { LOCAL_TGS_URLS } from '../../common/helpers/animatedAssets';
|
import { LOCAL_TGS_URLS } from '../../common/helpers/animatedAssets';
|
||||||
|
|
||||||
import usePrevious from '../../../hooks/usePrevious';
|
import usePreviousDeprecated from '../../../hooks/usePreviousDeprecated';
|
||||||
|
|
||||||
import AnimatedIcon from '../../common/AnimatedIcon';
|
import AnimatedIcon from '../../common/AnimatedIcon';
|
||||||
|
|
||||||
@ -24,10 +24,10 @@ const OutlinedMicrophoneIcon: FC<OwnProps> = ({
|
|||||||
const { isMuted, isMutedByMe } = participant;
|
const { isMuted, isMutedByMe } = participant;
|
||||||
const isSpeaking = (participant.amplitude || 0) > THRESHOLD;
|
const isSpeaking = (participant.amplitude || 0) > THRESHOLD;
|
||||||
const isRaiseHand = Boolean(participant.raiseHandRating);
|
const isRaiseHand = Boolean(participant.raiseHandRating);
|
||||||
const prevIsRaiseHand = usePrevious(isRaiseHand);
|
const prevIsRaiseHand = usePreviousDeprecated(isRaiseHand);
|
||||||
const canSelfUnmute = Boolean(participant?.canSelfUnmute);
|
const canSelfUnmute = Boolean(participant?.canSelfUnmute);
|
||||||
const shouldRaiseHand = !canSelfUnmute && isMuted;
|
const shouldRaiseHand = !canSelfUnmute && isMuted;
|
||||||
const prevIsMuted = usePrevious(isMuted);
|
const prevIsMuted = usePreviousDeprecated(isMuted);
|
||||||
|
|
||||||
const playSegment: [number, number] = useMemo(() => {
|
const playSegment: [number, number] = useMemo(() => {
|
||||||
if (isMuted && !prevIsMuted) {
|
if (isMuted && !prevIsMuted) {
|
||||||
|
|||||||
@ -4,7 +4,7 @@ import {
|
|||||||
} from '../../../../lib/teact/teact';
|
} from '../../../../lib/teact/teact';
|
||||||
|
|
||||||
import useLastCallback from '../../../../hooks/useLastCallback';
|
import useLastCallback from '../../../../hooks/useLastCallback';
|
||||||
import usePrevious from '../../../../hooks/usePrevious';
|
import usePreviousDeprecated from '../../../../hooks/usePreviousDeprecated';
|
||||||
import useResizeObserver from '../../../../hooks/useResizeObserver';
|
import useResizeObserver from '../../../../hooks/useResizeObserver';
|
||||||
|
|
||||||
const PADDING_HORIZONTAL = 10;
|
const PADDING_HORIZONTAL = 10;
|
||||||
@ -46,8 +46,8 @@ export default function useGroupCallVideoLayout({
|
|||||||
const [videoLayout, setVideoLayout] = useState<VideoLayout[]>([]);
|
const [videoLayout, setVideoLayout] = useState<VideoLayout[]>([]);
|
||||||
const [panelOffset, setPanelOffset] = useState(0);
|
const [panelOffset, setPanelOffset] = useState(0);
|
||||||
const videosCount = videoParticipants.length;
|
const videosCount = videoParticipants.length;
|
||||||
const prevVideosCount = usePrevious(videosCount);
|
const prevVideosCount = usePreviousDeprecated(videosCount);
|
||||||
const prevVideoParticipants = usePrevious(videoParticipants);
|
const prevVideoParticipants = usePreviousDeprecated(videoParticipants);
|
||||||
const removedVideoParticipants = useMemo(() => {
|
const removedVideoParticipants = useMemo(() => {
|
||||||
return prevVideoParticipants?.filter(
|
return prevVideoParticipants?.filter(
|
||||||
({ id, type }) => !videoParticipants.some((p) => p.id === id && p.type === type),
|
({ id, type }) => !videoParticipants.some((p) => p.id === id && p.type === type),
|
||||||
|
|||||||
@ -8,7 +8,7 @@ import { throttleWithTickEnd } from '../../util/schedulers';
|
|||||||
|
|
||||||
import useForceUpdate from '../../hooks/useForceUpdate';
|
import useForceUpdate from '../../hooks/useForceUpdate';
|
||||||
import useLang from '../../hooks/useLang';
|
import useLang from '../../hooks/useLang';
|
||||||
import usePrevious from '../../hooks/usePrevious';
|
import usePreviousDeprecated from '../../hooks/usePreviousDeprecated';
|
||||||
|
|
||||||
import styles from './AnimatedCounter.module.scss';
|
import styles from './AnimatedCounter.module.scss';
|
||||||
|
|
||||||
@ -34,7 +34,7 @@ const AnimatedCounter: FC<OwnProps> = ({
|
|||||||
}) => {
|
}) => {
|
||||||
const { isRtl } = useLang();
|
const { isRtl } = useLang();
|
||||||
|
|
||||||
const prevText = usePrevious(text);
|
const prevText = usePreviousDeprecated(text);
|
||||||
const forceUpdate = useForceUpdate();
|
const forceUpdate = useForceUpdate();
|
||||||
|
|
||||||
const shouldAnimate = scheduleAnimation(
|
const shouldAnimate = scheduleAnimation(
|
||||||
|
|||||||
@ -11,7 +11,7 @@ import { formatDateToString, formatTime, getDayStart } from '../../util/dates/da
|
|||||||
|
|
||||||
import useFlag from '../../hooks/useFlag';
|
import useFlag from '../../hooks/useFlag';
|
||||||
import useOldLang from '../../hooks/useOldLang';
|
import useOldLang from '../../hooks/useOldLang';
|
||||||
import usePrevious from '../../hooks/usePrevious';
|
import usePreviousDeprecated from '../../hooks/usePreviousDeprecated';
|
||||||
|
|
||||||
import Button from '../ui/Button';
|
import Button from '../ui/Button';
|
||||||
import Modal from '../ui/Modal';
|
import Modal from '../ui/Modal';
|
||||||
@ -73,7 +73,7 @@ const CalendarModal: FC<OwnProps> = ({
|
|||||||
}, [isPastMode, maxAt]);
|
}, [isPastMode, maxAt]);
|
||||||
|
|
||||||
const passedSelectedDate = useMemo(() => (selectedAt ? new Date(selectedAt) : new Date()), [selectedAt]);
|
const passedSelectedDate = useMemo(() => (selectedAt ? new Date(selectedAt) : new Date()), [selectedAt]);
|
||||||
const prevIsOpen = usePrevious(isOpen);
|
const prevIsOpen = usePreviousDeprecated(isOpen);
|
||||||
const [isTimeInputFocused, markTimeInputAsFocused] = useFlag(false);
|
const [isTimeInputFocused, markTimeInputAsFocused] = useFlag(false);
|
||||||
|
|
||||||
const [selectedDate, setSelectedDate] = useState<Date>(passedSelectedDate);
|
const [selectedDate, setSelectedDate] = useState<Date>(passedSelectedDate);
|
||||||
|
|||||||
@ -121,7 +121,7 @@ import useFlag from '../../hooks/useFlag';
|
|||||||
import useGetSelectionRange from '../../hooks/useGetSelectionRange';
|
import useGetSelectionRange from '../../hooks/useGetSelectionRange';
|
||||||
import useLastCallback from '../../hooks/useLastCallback';
|
import useLastCallback from '../../hooks/useLastCallback';
|
||||||
import useOldLang from '../../hooks/useOldLang';
|
import useOldLang from '../../hooks/useOldLang';
|
||||||
import usePrevious from '../../hooks/usePrevious';
|
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 useShowTransition from '../../hooks/useShowTransition';
|
||||||
@ -418,7 +418,7 @@ const Composer: FC<OwnProps & StateProps> = ({
|
|||||||
const [isMounted, setIsMounted] = useState(false);
|
const [isMounted, setIsMounted] = useState(false);
|
||||||
const getSelectionRange = useGetSelectionRange(editableInputCssSelector);
|
const getSelectionRange = useGetSelectionRange(editableInputCssSelector);
|
||||||
const lastMessageSendTimeSeconds = useRef<number>();
|
const lastMessageSendTimeSeconds = useRef<number>();
|
||||||
const prevDropAreaState = usePrevious(dropAreaState);
|
const prevDropAreaState = usePreviousDeprecated(dropAreaState);
|
||||||
const { width: windowWidth } = windowSize.get();
|
const { width: windowWidth } = windowSize.get();
|
||||||
|
|
||||||
const isInMessageList = type === 'messageList';
|
const isInMessageList = type === 'messageList';
|
||||||
|
|||||||
@ -10,7 +10,7 @@ import buildClassName from '../../util/buildClassName';
|
|||||||
|
|
||||||
import useLastCallback from '../../hooks/useLastCallback';
|
import useLastCallback from '../../hooks/useLastCallback';
|
||||||
import useOldLang from '../../hooks/useOldLang';
|
import useOldLang from '../../hooks/useOldLang';
|
||||||
import usePrevious from '../../hooks/usePrevious';
|
import usePreviousDeprecated from '../../hooks/usePreviousDeprecated';
|
||||||
|
|
||||||
import Button from '../ui/Button';
|
import Button from '../ui/Button';
|
||||||
import Modal from '../ui/Modal';
|
import Modal from '../ui/Modal';
|
||||||
@ -39,7 +39,7 @@ const CountryPickerModal: FC<OwnProps> = ({
|
|||||||
const lang = useOldLang();
|
const lang = useOldLang();
|
||||||
|
|
||||||
const [selectedCountryIds, setSelectedCountryIds] = useState<string[]>([]);
|
const [selectedCountryIds, setSelectedCountryIds] = useState<string[]>([]);
|
||||||
const prevSelectedCountryIds = usePrevious(selectedCountryIds);
|
const prevSelectedCountryIds = usePreviousDeprecated(selectedCountryIds);
|
||||||
const noPickerScrollRestore = prevSelectedCountryIds === selectedCountryIds;
|
const noPickerScrollRestore = prevSelectedCountryIds === selectedCountryIds;
|
||||||
|
|
||||||
const displayedIds = useMemo(() => {
|
const displayedIds = useMemo(() => {
|
||||||
|
|||||||
@ -15,7 +15,7 @@ import buildClassName from '../../util/buildClassName';
|
|||||||
import { useIntersectionObserver } from '../../hooks/useIntersectionObserver';
|
import { useIntersectionObserver } from '../../hooks/useIntersectionObserver';
|
||||||
import useLastCallback from '../../hooks/useLastCallback';
|
import useLastCallback from '../../hooks/useLastCallback';
|
||||||
import useOldLang from '../../hooks/useOldLang';
|
import useOldLang from '../../hooks/useOldLang';
|
||||||
import usePrevious from '../../hooks/usePrevious';
|
import usePreviousDeprecated from '../../hooks/usePreviousDeprecated';
|
||||||
|
|
||||||
import Modal from '../ui/Modal';
|
import Modal from '../ui/Modal';
|
||||||
import StickerSetCard from './StickerSetCard';
|
import StickerSetCard from './StickerSetCard';
|
||||||
@ -49,7 +49,7 @@ const CustomEmojiSetsModal: FC<OwnProps & StateProps> = ({
|
|||||||
rootRef: customEmojiModalRef, isDisabled: !customEmojiSets,
|
rootRef: customEmojiModalRef, isDisabled: !customEmojiSets,
|
||||||
});
|
});
|
||||||
|
|
||||||
const prevCustomEmojiSets = usePrevious(customEmojiSets);
|
const prevCustomEmojiSets = usePreviousDeprecated(customEmojiSets);
|
||||||
const renderingCustomEmojiSets = customEmojiSets || prevCustomEmojiSets;
|
const renderingCustomEmojiSets = customEmojiSets || prevCustomEmojiSets;
|
||||||
|
|
||||||
const handleSetClick = useLastCallback((sticker: ApiSticker) => {
|
const handleSetClick = useLastCallback((sticker: ApiSticker) => {
|
||||||
|
|||||||
@ -33,7 +33,7 @@ import renderText from './helpers/renderText';
|
|||||||
|
|
||||||
import useLastCallback from '../../hooks/useLastCallback';
|
import useLastCallback from '../../hooks/useLastCallback';
|
||||||
import useOldLang from '../../hooks/useOldLang';
|
import useOldLang from '../../hooks/useOldLang';
|
||||||
import usePrevious from '../../hooks/usePrevious';
|
import usePreviousDeprecated from '../../hooks/usePreviousDeprecated';
|
||||||
import useManagePermissions from '../right/hooks/useManagePermissions';
|
import useManagePermissions from '../right/hooks/useManagePermissions';
|
||||||
|
|
||||||
import PermissionCheckboxList from '../main/PermissionCheckboxList';
|
import PermissionCheckboxList from '../main/PermissionCheckboxList';
|
||||||
@ -101,7 +101,7 @@ const DeleteMessageModal: FC<OwnProps & StateProps> = ({
|
|||||||
closeDeleteMessageModal,
|
closeDeleteMessageModal,
|
||||||
} = getActions();
|
} = getActions();
|
||||||
|
|
||||||
const prevIsOpen = usePrevious(isOpen);
|
const prevIsOpen = usePreviousDeprecated(isOpen);
|
||||||
|
|
||||||
const lang = useOldLang();
|
const lang = useOldLang();
|
||||||
|
|
||||||
|
|||||||
@ -11,7 +11,7 @@ import { copyTextToClipboard } from '../../util/clipboard';
|
|||||||
import { isBetween } from '../../util/math';
|
import { isBetween } from '../../util/math';
|
||||||
|
|
||||||
import useOldLang from '../../hooks/useOldLang';
|
import useOldLang from '../../hooks/useOldLang';
|
||||||
import usePrevious from '../../hooks/usePrevious';
|
import usePreviousDeprecated from '../../hooks/usePreviousDeprecated';
|
||||||
|
|
||||||
import ConfirmDialog from '../ui/ConfirmDialog';
|
import ConfirmDialog from '../ui/ConfirmDialog';
|
||||||
import Draggable from '../ui/Draggable';
|
import Draggable from '../ui/Draggable';
|
||||||
@ -49,7 +49,7 @@ const ManageUsernames: FC<OwnProps> = ({
|
|||||||
const [usernameForConfirm, setUsernameForConfirm] = useState<ApiUsername | undefined>();
|
const [usernameForConfirm, setUsernameForConfirm] = useState<ApiUsername | undefined>();
|
||||||
|
|
||||||
const usernameList = useMemo(() => usernames.map(({ username }) => username), [usernames]);
|
const usernameList = useMemo(() => usernames.map(({ username }) => username), [usernames]);
|
||||||
const prevUsernameList = usePrevious(usernameList);
|
const prevUsernameList = usePreviousDeprecated(usernameList);
|
||||||
|
|
||||||
const [state, setState] = useState<SortState>({
|
const [state, setState] = useState<SortState>({
|
||||||
orderedUsernames: usernameList,
|
orderedUsernames: usernameList,
|
||||||
|
|||||||
@ -26,7 +26,7 @@ import renderText from './helpers/renderText';
|
|||||||
|
|
||||||
import useLastCallback from '../../hooks/useLastCallback';
|
import useLastCallback from '../../hooks/useLastCallback';
|
||||||
import useOldLang from '../../hooks/useOldLang';
|
import useOldLang from '../../hooks/useOldLang';
|
||||||
import usePrevious from '../../hooks/usePrevious';
|
import usePreviousDeprecated from '../../hooks/usePreviousDeprecated';
|
||||||
import usePhotosPreload from './hooks/usePhotosPreload';
|
import usePhotosPreload from './hooks/usePhotosPreload';
|
||||||
|
|
||||||
import Transition from '../ui/Transition';
|
import Transition from '../ui/Transition';
|
||||||
@ -87,8 +87,8 @@ const ProfileInfo: FC<OwnProps & StateProps> = ({
|
|||||||
const userProfilePhotos = user?.profilePhotos;
|
const userProfilePhotos = user?.profilePhotos;
|
||||||
const chatProfilePhotos = chat?.profilePhotos;
|
const chatProfilePhotos = chat?.profilePhotos;
|
||||||
const photos = userProfilePhotos?.photos || chatProfilePhotos?.photos || MEMO_EMPTY_ARRAY;
|
const photos = userProfilePhotos?.photos || chatProfilePhotos?.photos || MEMO_EMPTY_ARRAY;
|
||||||
const prevMediaIndex = usePrevious(mediaIndex);
|
const prevMediaIndex = usePreviousDeprecated(mediaIndex);
|
||||||
const prevAvatarOwnerId = usePrevious(avatarOwnerId);
|
const prevAvatarOwnerId = usePreviousDeprecated(avatarOwnerId);
|
||||||
const [hasSlideAnimation, setHasSlideAnimation] = useState(true);
|
const [hasSlideAnimation, setHasSlideAnimation] = useState(true);
|
||||||
// slideOptimized doesn't work well when animation is dynamically disabled
|
// slideOptimized doesn't work well when animation is dynamically disabled
|
||||||
const slideAnimation = hasSlideAnimation ? (lang.isRtl ? 'slideRtl' : 'slide') : 'none';
|
const slideAnimation = hasSlideAnimation ? (lang.isRtl ? 'slideRtl' : 'slide') : 'none';
|
||||||
|
|||||||
@ -27,7 +27,7 @@ import renderText from './helpers/renderText';
|
|||||||
import useAppLayout from '../../hooks/useAppLayout';
|
import useAppLayout from '../../hooks/useAppLayout';
|
||||||
import { useIntersectionObserver } from '../../hooks/useIntersectionObserver';
|
import { useIntersectionObserver } from '../../hooks/useIntersectionObserver';
|
||||||
import useOldLang from '../../hooks/useOldLang';
|
import useOldLang from '../../hooks/useOldLang';
|
||||||
import usePrevious from '../../hooks/usePrevious';
|
import usePreviousDeprecated from '../../hooks/usePreviousDeprecated';
|
||||||
import useSchedule from '../../hooks/useSchedule';
|
import useSchedule from '../../hooks/useSchedule';
|
||||||
import useScrolledState from '../../hooks/useScrolledState';
|
import useScrolledState from '../../hooks/useScrolledState';
|
||||||
|
|
||||||
@ -90,7 +90,7 @@ const StickerSetModal: FC<OwnProps & StateProps> = ({
|
|||||||
|
|
||||||
const { isMobile } = useAppLayout();
|
const { isMobile } = useAppLayout();
|
||||||
|
|
||||||
const prevStickerSet = usePrevious(stickerSet);
|
const prevStickerSet = usePreviousDeprecated(stickerSet);
|
||||||
const renderingStickerSet = stickerSet || prevStickerSet;
|
const renderingStickerSet = stickerSet || prevStickerSet;
|
||||||
|
|
||||||
const isAdded = Boolean(!renderingStickerSet?.isArchived && renderingStickerSet?.installedDate);
|
const isAdded = Boolean(!renderingStickerSet?.isArchived && renderingStickerSet?.installedDate);
|
||||||
|
|||||||
@ -11,7 +11,7 @@ import {
|
|||||||
} from '../../util/username';
|
} from '../../util/username';
|
||||||
|
|
||||||
import useOldLang from '../../hooks/useOldLang';
|
import useOldLang from '../../hooks/useOldLang';
|
||||||
import usePrevious from '../../hooks/usePrevious';
|
import usePreviousDeprecated from '../../hooks/usePreviousDeprecated';
|
||||||
|
|
||||||
import InputText from '../ui/InputText';
|
import InputText from '../ui/InputText';
|
||||||
|
|
||||||
@ -43,7 +43,7 @@ const UsernameInput: FC<OwnProps> = ({
|
|||||||
const langPrefix = asLink ? 'SetUrl' : 'Username';
|
const langPrefix = asLink ? 'SetUrl' : 'Username';
|
||||||
const label = asLink ? lang('SetUrlPlaceholder') : lang('Username');
|
const label = asLink ? lang('SetUrlPlaceholder') : lang('Username');
|
||||||
|
|
||||||
const previousIsUsernameAvailable = usePrevious(isUsernameAvailable);
|
const previousIsUsernameAvailable = usePreviousDeprecated(isUsernameAvailable);
|
||||||
const renderingIsUsernameAvailable = currentUsername !== username
|
const renderingIsUsernameAvailable = currentUsername !== username
|
||||||
? (isUsernameAvailable ?? previousIsUsernameAvailable) : undefined;
|
? (isUsernameAvailable ?? previousIsUsernameAvailable) : undefined;
|
||||||
const isChecking = username && currentUsername !== username && checkedUsername !== username;
|
const isChecking = username && currentUsername !== username && checkedUsername !== username;
|
||||||
|
|||||||
@ -17,7 +17,7 @@ import {
|
|||||||
import useFoldersReducer from '../../hooks/reducers/useFoldersReducer';
|
import useFoldersReducer from '../../hooks/reducers/useFoldersReducer';
|
||||||
import { useHotkeys } from '../../hooks/useHotkeys';
|
import { useHotkeys } from '../../hooks/useHotkeys';
|
||||||
import useLastCallback from '../../hooks/useLastCallback';
|
import useLastCallback from '../../hooks/useLastCallback';
|
||||||
import usePrevious2 from '../../hooks/usePrevious2';
|
import usePrevious from '../../hooks/usePrevious';
|
||||||
import { useStateRef } from '../../hooks/useStateRef';
|
import { useStateRef } from '../../hooks/useStateRef';
|
||||||
import useSyncEffect from '../../hooks/useSyncEffect';
|
import useSyncEffect from '../../hooks/useSyncEffect';
|
||||||
|
|
||||||
@ -448,7 +448,7 @@ function LeftColumn({
|
|||||||
setSettingsScreen(screen);
|
setSettingsScreen(screen);
|
||||||
});
|
});
|
||||||
|
|
||||||
const prevSettingsScreenRef = useStateRef(usePrevious2(contentType === ContentType.Settings ? settingsScreen : -1));
|
const prevSettingsScreenRef = useStateRef(usePrevious(contentType === ContentType.Settings ? settingsScreen : -1));
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (!IS_TOUCH_ENV) {
|
if (!IS_TOUCH_ENV) {
|
||||||
|
|||||||
@ -28,7 +28,7 @@ import useInfiniteScroll from '../../../hooks/useInfiniteScroll';
|
|||||||
import { useIntersectionObserver, useOnIntersect } from '../../../hooks/useIntersectionObserver';
|
import { useIntersectionObserver, useOnIntersect } from '../../../hooks/useIntersectionObserver';
|
||||||
import useLastCallback from '../../../hooks/useLastCallback';
|
import useLastCallback from '../../../hooks/useLastCallback';
|
||||||
import useOldLang from '../../../hooks/useOldLang';
|
import useOldLang from '../../../hooks/useOldLang';
|
||||||
import usePrevious from '../../../hooks/usePrevious';
|
import usePreviousDeprecated from '../../../hooks/usePreviousDeprecated';
|
||||||
import useOrderDiff from './hooks/useOrderDiff';
|
import useOrderDiff from './hooks/useOrderDiff';
|
||||||
|
|
||||||
import GroupCallTopPane from '../../calls/group/GroupCallTopPane';
|
import GroupCallTopPane from '../../calls/group/GroupCallTopPane';
|
||||||
@ -129,7 +129,7 @@ const ForumPanel: FC<OwnProps & StateProps> = ({
|
|||||||
|
|
||||||
const shouldRenderRef = useRef(false);
|
const shouldRenderRef = useRef(false);
|
||||||
const isVisible = isOpen && !isHidden;
|
const isVisible = isOpen && !isHidden;
|
||||||
const prevIsVisible = usePrevious(isVisible);
|
const prevIsVisible = usePreviousDeprecated(isVisible);
|
||||||
|
|
||||||
if (prevIsVisible !== isVisible) {
|
if (prevIsVisible !== isVisible) {
|
||||||
shouldRenderRef.current = false;
|
shouldRenderRef.current = false;
|
||||||
|
|||||||
@ -1,12 +1,12 @@
|
|||||||
import { useRef } from '../../../../lib/teact/teact';
|
import { useRef } from '../../../../lib/teact/teact';
|
||||||
|
|
||||||
import useForceUpdate from '../../../../hooks/useForceUpdate';
|
import useForceUpdate from '../../../../hooks/useForceUpdate';
|
||||||
import usePrevious from '../../../../hooks/usePrevious';
|
import usePreviousDeprecated from '../../../../hooks/usePreviousDeprecated';
|
||||||
|
|
||||||
export default function useLeftHeaderButtonRtlForumTransition(shouldHideSearch?: boolean) {
|
export default function useLeftHeaderButtonRtlForumTransition(shouldHideSearch?: boolean) {
|
||||||
const forceUpdate = useForceUpdate();
|
const forceUpdate = useForceUpdate();
|
||||||
const shouldDisableDropdownMenuTransitionRef = useRef(shouldHideSearch);
|
const shouldDisableDropdownMenuTransitionRef = useRef(shouldHideSearch);
|
||||||
const prevShouldHideSearch = usePrevious(shouldHideSearch);
|
const prevShouldHideSearch = usePreviousDeprecated(shouldHideSearch);
|
||||||
|
|
||||||
function handleDropdownMenuTransitionEnd() {
|
function handleDropdownMenuTransitionEnd() {
|
||||||
shouldDisableDropdownMenuTransitionRef.current = Boolean(shouldHideSearch);
|
shouldDisableDropdownMenuTransitionRef.current = Boolean(shouldHideSearch);
|
||||||
|
|||||||
@ -3,7 +3,7 @@ import { useMemo } from '../../../../lib/teact/teact';
|
|||||||
import { mapValues } from '../../../../util/iteratees';
|
import { mapValues } from '../../../../util/iteratees';
|
||||||
import { useChatAnimationType } from './useChatAnimationType';
|
import { useChatAnimationType } from './useChatAnimationType';
|
||||||
|
|
||||||
import usePrevious from '../../../../hooks/usePrevious';
|
import usePreviousDeprecated from '../../../../hooks/usePreviousDeprecated';
|
||||||
|
|
||||||
export default function useOrderDiff(orderedIds: (string | number)[] | undefined, key?: string) {
|
export default function useOrderDiff(orderedIds: (string | number)[] | undefined, key?: string) {
|
||||||
const orderById = useMemo(() => {
|
const orderById = useMemo(() => {
|
||||||
@ -17,8 +17,8 @@ export default function useOrderDiff(orderedIds: (string | number)[] | undefined
|
|||||||
}, {} as Record<string, number>);
|
}, {} as Record<string, number>);
|
||||||
}, [orderedIds]);
|
}, [orderedIds]);
|
||||||
|
|
||||||
const prevOrderById = usePrevious(orderById);
|
const prevOrderById = usePreviousDeprecated(orderById);
|
||||||
const prevChatId = usePrevious(key);
|
const prevChatId = usePreviousDeprecated(key);
|
||||||
|
|
||||||
const orderDiffById = useMemo(() => {
|
const orderDiffById = useMemo(() => {
|
||||||
if (!orderById || !prevOrderById || key !== prevChatId) {
|
if (!orderById || !prevOrderById || key !== prevChatId) {
|
||||||
|
|||||||
@ -20,7 +20,7 @@ import renderText from '../../common/helpers/renderText';
|
|||||||
import useHistoryBack from '../../../hooks/useHistoryBack';
|
import useHistoryBack from '../../../hooks/useHistoryBack';
|
||||||
import useMedia from '../../../hooks/useMedia';
|
import useMedia from '../../../hooks/useMedia';
|
||||||
import useOldLang from '../../../hooks/useOldLang';
|
import useOldLang from '../../../hooks/useOldLang';
|
||||||
import usePrevious from '../../../hooks/usePrevious';
|
import usePreviousDeprecated from '../../../hooks/usePreviousDeprecated';
|
||||||
|
|
||||||
import ManageUsernames from '../../common/ManageUsernames';
|
import ManageUsernames from '../../common/ManageUsernames';
|
||||||
import SafeLink from '../../common/SafeLink';
|
import SafeLink from '../../common/SafeLink';
|
||||||
@ -91,7 +91,7 @@ const SettingsEditProfile: FC<OwnProps & StateProps> = ({
|
|||||||
const isLoading = progress === ProfileEditProgress.InProgress;
|
const isLoading = progress === ProfileEditProgress.InProgress;
|
||||||
const isUsernameError = editableUsername === false;
|
const isUsernameError = editableUsername === false;
|
||||||
|
|
||||||
const previousIsUsernameAvailable = usePrevious(isUsernameAvailable);
|
const previousIsUsernameAvailable = usePreviousDeprecated(isUsernameAvailable);
|
||||||
const renderingIsUsernameAvailable = isUsernameAvailable ?? previousIsUsernameAvailable;
|
const renderingIsUsernameAvailable = isUsernameAvailable ?? previousIsUsernameAvailable;
|
||||||
const shouldRenderUsernamesManage = usernames && usernames.length > 1;
|
const shouldRenderUsernamesManage = usernames && usernames.length > 1;
|
||||||
|
|
||||||
|
|||||||
@ -16,7 +16,7 @@ import { fetchBlob } from '../../../util/files';
|
|||||||
import useCanvasBlur from '../../../hooks/useCanvasBlur';
|
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 usePrevious from '../../../hooks/usePrevious';
|
import usePreviousDeprecated from '../../../hooks/usePreviousDeprecated';
|
||||||
import useShowTransition from '../../../hooks/useShowTransition';
|
import useShowTransition from '../../../hooks/useShowTransition';
|
||||||
|
|
||||||
import ProgressSpinner from '../../ui/ProgressSpinner';
|
import ProgressSpinner from '../../ui/ProgressSpinner';
|
||||||
@ -52,7 +52,7 @@ const WallpaperTile: FC<OwnProps> = ({
|
|||||||
const {
|
const {
|
||||||
mediaData: fullMedia, loadProgress,
|
mediaData: fullMedia, loadProgress,
|
||||||
} = useMediaWithLoadProgress(localMediaHash, !isLoadAllowed);
|
} = useMediaWithLoadProgress(localMediaHash, !isLoadAllowed);
|
||||||
const wasLoadDisabled = usePrevious(isLoadAllowed) === false;
|
const wasLoadDisabled = usePreviousDeprecated(isLoadAllowed) === false;
|
||||||
const { shouldRender: shouldRenderSpinner, transitionClassNames: spinnerClassNames } = useShowTransition(
|
const { shouldRender: shouldRenderSpinner, transitionClassNames: spinnerClassNames } = useShowTransition(
|
||||||
(isLoadAllowed && !fullMedia) || slug === UPLOADING_WALLPAPER_SLUG,
|
(isLoadAllowed && !fullMedia) || slug === UPLOADING_WALLPAPER_SLUG,
|
||||||
undefined,
|
undefined,
|
||||||
|
|||||||
@ -19,7 +19,7 @@ import renderText from '../../../common/helpers/renderText';
|
|||||||
import { useFolderManagerForChatsCount } from '../../../../hooks/useFolderManager';
|
import { useFolderManagerForChatsCount } from '../../../../hooks/useFolderManager';
|
||||||
import useHistoryBack from '../../../../hooks/useHistoryBack';
|
import useHistoryBack from '../../../../hooks/useHistoryBack';
|
||||||
import useOldLang from '../../../../hooks/useOldLang';
|
import useOldLang from '../../../../hooks/useOldLang';
|
||||||
import usePrevious from '../../../../hooks/usePrevious';
|
import usePreviousDeprecated from '../../../../hooks/usePreviousDeprecated';
|
||||||
|
|
||||||
import AnimatedIcon from '../../../common/AnimatedIcon';
|
import AnimatedIcon from '../../../common/AnimatedIcon';
|
||||||
import Button from '../../../ui/Button';
|
import Button from '../../../ui/Button';
|
||||||
@ -76,7 +76,7 @@ const SettingsFoldersMain: FC<OwnProps & StateProps> = ({
|
|||||||
draggedIndex: undefined,
|
draggedIndex: undefined,
|
||||||
});
|
});
|
||||||
|
|
||||||
const prevFolderIds = usePrevious(folderIds);
|
const prevFolderIds = usePreviousDeprecated(folderIds);
|
||||||
|
|
||||||
// Sync folders state after changing folders in other clients
|
// Sync folders state after changing folders in other clients
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
|
|||||||
@ -5,7 +5,7 @@ import { getActions } from '../../global';
|
|||||||
import type { ApiChatFolder } from '../../api/types';
|
import type { ApiChatFolder } from '../../api/types';
|
||||||
|
|
||||||
import useOldLang from '../../hooks/useOldLang';
|
import useOldLang from '../../hooks/useOldLang';
|
||||||
import usePrevious from '../../hooks/usePrevious';
|
import usePreviousDeprecated from '../../hooks/usePreviousDeprecated';
|
||||||
|
|
||||||
import ConfirmDialog from '../ui/ConfirmDialog';
|
import ConfirmDialog from '../ui/ConfirmDialog';
|
||||||
|
|
||||||
@ -21,7 +21,7 @@ const DeleteFolderDialog: FC<OwnProps> = ({
|
|||||||
|
|
||||||
const isOpen = Boolean(folder);
|
const isOpen = Boolean(folder);
|
||||||
|
|
||||||
const renderingFolder = usePrevious(folder) || folder;
|
const renderingFolder = usePreviousDeprecated(folder) || folder;
|
||||||
const isMyChatlist = renderingFolder?.hasMyInvites;
|
const isMyChatlist = renderingFolder?.hasMyInvites;
|
||||||
|
|
||||||
const handleDeleteFolderMessage = useCallback(() => {
|
const handleDeleteFolderMessage = useCallback(() => {
|
||||||
|
|||||||
@ -15,7 +15,7 @@ import {
|
|||||||
|
|
||||||
import useFlag from '../../hooks/useFlag';
|
import useFlag from '../../hooks/useFlag';
|
||||||
import useOldLang from '../../hooks/useOldLang';
|
import useOldLang from '../../hooks/useOldLang';
|
||||||
import usePrevious from '../../hooks/usePrevious';
|
import usePreviousDeprecated from '../../hooks/usePreviousDeprecated';
|
||||||
|
|
||||||
import RecipientPicker from '../common/RecipientPicker';
|
import RecipientPicker from '../common/RecipientPicker';
|
||||||
|
|
||||||
@ -48,7 +48,7 @@ const ForwardRecipientPicker: FC<OwnProps & StateProps> = ({
|
|||||||
|
|
||||||
const lang = useOldLang();
|
const lang = useOldLang();
|
||||||
|
|
||||||
const renderingIsStory = usePrevious(isStory, true);
|
const renderingIsStory = usePreviousDeprecated(isStory, true);
|
||||||
const [isShown, markIsShown, unmarkIsShown] = useFlag();
|
const [isShown, markIsShown, unmarkIsShown] = useFlag();
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (isOpen) {
|
if (isOpen) {
|
||||||
|
|||||||
@ -17,7 +17,7 @@ import renderText from '../../common/helpers/renderText';
|
|||||||
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 usePrevious from '../../../hooks/usePrevious';
|
import usePreviousDeprecated from '../../../hooks/usePreviousDeprecated';
|
||||||
|
|
||||||
import SliderDots from '../../common/SliderDots';
|
import SliderDots from '../../common/SliderDots';
|
||||||
import Button from '../../ui/Button';
|
import Button from '../../ui/Button';
|
||||||
@ -129,7 +129,7 @@ const PremiumFeatureModal: FC<OwnProps> = ({
|
|||||||
const [isScrolledToTop, setIsScrolledToTop] = useState(true);
|
const [isScrolledToTop, setIsScrolledToTop] = useState(true);
|
||||||
const [isScrolledToBottom, setIsScrolledToBottom] = useState(false);
|
const [isScrolledToBottom, setIsScrolledToBottom] = useState(false);
|
||||||
|
|
||||||
const prevInitialSection = usePrevious(initialSection);
|
const prevInitialSection = usePreviousDeprecated(initialSection);
|
||||||
|
|
||||||
const filteredSections = useMemo(() => {
|
const filteredSections = useMemo(() => {
|
||||||
if (!premiumPromoOrder) return PREMIUM_FEATURE_SECTIONS;
|
if (!premiumPromoOrder) return PREMIUM_FEATURE_SECTIONS;
|
||||||
|
|||||||
@ -44,7 +44,7 @@ import { dispatchHeavyAnimationEvent } from '../../hooks/useHeavyAnimationCheck'
|
|||||||
import useLastCallback from '../../hooks/useLastCallback';
|
import useLastCallback from '../../hooks/useLastCallback';
|
||||||
import useOldLang from '../../hooks/useOldLang';
|
import useOldLang from '../../hooks/useOldLang';
|
||||||
import { exitPictureInPictureIfNeeded, usePictureInPictureSignal } from '../../hooks/usePictureInPicture';
|
import { exitPictureInPictureIfNeeded, usePictureInPictureSignal } from '../../hooks/usePictureInPicture';
|
||||||
import usePrevious from '../../hooks/usePrevious';
|
import usePreviousDeprecated from '../../hooks/usePreviousDeprecated';
|
||||||
import { dispatchPriorityPlaybackEvent } from '../../hooks/usePriorityPlaybackCheck';
|
import { dispatchPriorityPlaybackEvent } from '../../hooks/usePriorityPlaybackCheck';
|
||||||
import { useMediaProps } from './hooks/useMediaProps';
|
import { useMediaProps } from './hooks/useMediaProps';
|
||||||
|
|
||||||
@ -120,7 +120,7 @@ const MediaViewer = ({
|
|||||||
/* Animation */
|
/* Animation */
|
||||||
const animationKey = useRef<number>();
|
const animationKey = useRef<number>();
|
||||||
const senderId = message?.senderId || avatarOwner?.id;
|
const senderId = message?.senderId || avatarOwner?.id;
|
||||||
const prevSenderId = usePrevious<string | undefined>(senderId);
|
const prevSenderId = usePreviousDeprecated<string | undefined>(senderId);
|
||||||
const headerAnimation = withAnimation ? 'slideFade' : 'none';
|
const headerAnimation = withAnimation ? 'slideFade' : 'none';
|
||||||
const isGhostAnimation = Boolean(withAnimation && !shouldSkipHistoryAnimations);
|
const isGhostAnimation = Boolean(withAnimation && !shouldSkipHistoryAnimations);
|
||||||
|
|
||||||
@ -201,11 +201,11 @@ const MediaViewer = ({
|
|||||||
};
|
};
|
||||||
}, [forceUpdate]);
|
}, [forceUpdate]);
|
||||||
|
|
||||||
const prevMessage = usePrevious<ApiMessage | undefined>(message);
|
const prevMessage = usePreviousDeprecated<ApiMessage | undefined>(message);
|
||||||
const prevIsHidden = usePrevious<boolean | undefined>(isHidden);
|
const prevIsHidden = usePreviousDeprecated<boolean | undefined>(isHidden);
|
||||||
const prevOrigin = usePrevious(origin);
|
const prevOrigin = usePreviousDeprecated(origin);
|
||||||
const prevItem = usePrevious(currentItem);
|
const prevItem = usePreviousDeprecated(currentItem);
|
||||||
const prevBestImageData = usePrevious(bestImageData);
|
const prevBestImageData = usePreviousDeprecated(bestImageData);
|
||||||
const textParts = message ? renderMessageText({ message, forcePlayback: true, isForMediaViewer: true }) : undefined;
|
const textParts = message ? renderMessageText({ message, forcePlayback: true, isForMediaViewer: true }) : undefined;
|
||||||
const hasFooter = Boolean(textParts);
|
const hasFooter = Boolean(textParts);
|
||||||
const shouldAnimateOpening = prevIsHidden && prevItem !== currentItem;
|
const shouldAnimateOpening = prevIsHidden && prevItem !== currentItem;
|
||||||
|
|||||||
@ -37,7 +37,7 @@ import renderText from '../common/helpers/renderText';
|
|||||||
import useLang from '../../hooks/useLang';
|
import useLang from '../../hooks/useLang';
|
||||||
import useLastCallback from '../../hooks/useLastCallback';
|
import useLastCallback from '../../hooks/useLastCallback';
|
||||||
import useOldLang from '../../hooks/useOldLang';
|
import useOldLang from '../../hooks/useOldLang';
|
||||||
import usePrevious from '../../hooks/usePrevious';
|
import usePreviousDeprecated from '../../hooks/usePreviousDeprecated';
|
||||||
import useManagePermissions from '../right/hooks/useManagePermissions';
|
import useManagePermissions from '../right/hooks/useManagePermissions';
|
||||||
|
|
||||||
import Avatar from '../common/Avatar';
|
import Avatar from '../common/Avatar';
|
||||||
@ -100,7 +100,7 @@ const DeleteSelectedMessageModal: FC<OwnProps & StateProps> = ({
|
|||||||
updateChatMemberBannedRights,
|
updateChatMemberBannedRights,
|
||||||
} = getActions();
|
} = getActions();
|
||||||
|
|
||||||
const prevIsOpen = usePrevious(isOpen);
|
const prevIsOpen = usePreviousDeprecated(isOpen);
|
||||||
|
|
||||||
const oldLang = useOldLang();
|
const oldLang = useOldLang();
|
||||||
const lang = useLang();
|
const lang = useLang();
|
||||||
|
|||||||
@ -27,7 +27,7 @@ import { preventMessageInputBlur } from './helpers/preventMessageInputBlur';
|
|||||||
import useDerivedSignal from '../../hooks/useDerivedSignal';
|
import useDerivedSignal from '../../hooks/useDerivedSignal';
|
||||||
import { getIsHeavyAnimating } from '../../hooks/useHeavyAnimationCheck';
|
import { getIsHeavyAnimating } from '../../hooks/useHeavyAnimationCheck';
|
||||||
import useOldLang from '../../hooks/useOldLang';
|
import useOldLang from '../../hooks/useOldLang';
|
||||||
import usePrevious from '../../hooks/usePrevious';
|
import usePreviousDeprecated from '../../hooks/usePreviousDeprecated';
|
||||||
import useMessageObservers from './hooks/useMessageObservers';
|
import useMessageObservers from './hooks/useMessageObservers';
|
||||||
import useScrollHooks from './hooks/useScrollHooks';
|
import useScrollHooks from './hooks/useScrollHooks';
|
||||||
|
|
||||||
@ -139,7 +139,7 @@ const MessageListContent: FC<OwnProps> = ({
|
|||||||
}, 0);
|
}, 0);
|
||||||
let appearanceIndex = 0;
|
let appearanceIndex = 0;
|
||||||
|
|
||||||
const prevMessageIds = usePrevious(messageIds);
|
const prevMessageIds = usePreviousDeprecated(messageIds);
|
||||||
const isNewMessage = Boolean(
|
const isNewMessage = Boolean(
|
||||||
messageIds && prevMessageIds && messageIds[messageIds.length - 2] === prevMessageIds[prevMessageIds.length - 1],
|
messageIds && prevMessageIds && messageIds[messageIds.length - 2] === prevMessageIds[prevMessageIds.length - 1],
|
||||||
);
|
);
|
||||||
|
|||||||
@ -20,7 +20,7 @@ import captureKeyboardListeners from '../../util/captureKeyboardListeners';
|
|||||||
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 usePrevious from '../../hooks/usePrevious';
|
import usePreviousDeprecated from '../../hooks/usePreviousDeprecated';
|
||||||
import useCopySelectedMessages from './hooks/useCopySelectedMessages';
|
import useCopySelectedMessages from './hooks/useCopySelectedMessages';
|
||||||
|
|
||||||
import ReportModal from '../common/ReportModal';
|
import ReportModal from '../common/ReportModal';
|
||||||
@ -105,7 +105,7 @@ const MessageSelectToolbar: FC<OwnProps & StateProps> = ({
|
|||||||
exitMessageSelectMode();
|
exitMessageSelectMode();
|
||||||
});
|
});
|
||||||
|
|
||||||
const prevSelectedMessagesCount = usePrevious(selectedMessagesCount || undefined, true);
|
const prevSelectedMessagesCount = usePreviousDeprecated(selectedMessagesCount || undefined, true);
|
||||||
const renderingSelectedMessagesCount = isActive ? selectedMessagesCount : prevSelectedMessagesCount;
|
const renderingSelectedMessagesCount = isActive ? selectedMessagesCount : prevSelectedMessagesCount;
|
||||||
|
|
||||||
const formattedMessagesCount = lang('VoiceOver.Chat.MessagesSelected', renderingSelectedMessagesCount, 'i');
|
const formattedMessagesCount = lang('VoiceOver.Chat.MessagesSelected', renderingSelectedMessagesCount, 'i');
|
||||||
|
|||||||
@ -72,7 +72,7 @@ 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 usePrevDuringAnimation from '../../hooks/usePrevDuringAnimation';
|
import usePrevDuringAnimation from '../../hooks/usePrevDuringAnimation';
|
||||||
import usePrevious from '../../hooks/usePrevious';
|
import usePreviousDeprecated from '../../hooks/usePreviousDeprecated';
|
||||||
import { useResize } from '../../hooks/useResize';
|
import { useResize } from '../../hooks/useResize';
|
||||||
import useSyncEffect from '../../hooks/useSyncEffect';
|
import useSyncEffect from '../../hooks/useSyncEffect';
|
||||||
import useWindowSize from '../../hooks/window/useWindowSize';
|
import useWindowSize from '../../hooks/window/useWindowSize';
|
||||||
@ -286,7 +286,7 @@ function MiddleColumn({
|
|||||||
closeAnimationDuration,
|
closeAnimationDuration,
|
||||||
);
|
);
|
||||||
|
|
||||||
const prevTransitionKey = usePrevious(currentTransitionKey);
|
const prevTransitionKey = usePreviousDeprecated(currentTransitionKey);
|
||||||
|
|
||||||
const cleanupExceptionKey = (
|
const cleanupExceptionKey = (
|
||||||
prevTransitionKey !== undefined && prevTransitionKey < currentTransitionKey ? prevTransitionKey : undefined
|
prevTransitionKey !== undefined && prevTransitionKey < currentTransitionKey ? prevTransitionKey : undefined
|
||||||
|
|||||||
@ -62,7 +62,7 @@ import useEnsureMessage from '../../hooks/useEnsureMessage';
|
|||||||
import useLastCallback from '../../hooks/useLastCallback';
|
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 usePrevious from '../../hooks/usePrevious';
|
import usePreviousDeprecated from '../../hooks/usePreviousDeprecated';
|
||||||
import useShowTransition from '../../hooks/useShowTransition';
|
import useShowTransition from '../../hooks/useShowTransition';
|
||||||
import useWindowSize from '../../hooks/window/useWindowSize';
|
import useWindowSize from '../../hooks/window/useWindowSize';
|
||||||
|
|
||||||
@ -330,7 +330,7 @@ const MiddleHeader: FC<OwnProps & StateProps> = ({
|
|||||||
const renderingCanUnpin = useCurrentOrPrev(canUnpin, true);
|
const renderingCanUnpin = useCurrentOrPrev(canUnpin, true);
|
||||||
const renderingPinnedMessageTitle = useCurrentOrPrev(topMessageTitle);
|
const renderingPinnedMessageTitle = useCurrentOrPrev(topMessageTitle);
|
||||||
|
|
||||||
const prevTransitionKey = usePrevious(currentTransitionKey);
|
const prevTransitionKey = usePreviousDeprecated(currentTransitionKey);
|
||||||
const cleanupExceptionKey = (
|
const cleanupExceptionKey = (
|
||||||
prevTransitionKey !== undefined && prevTransitionKey < currentTransitionKey ? prevTransitionKey : undefined
|
prevTransitionKey !== undefined && prevTransitionKey < currentTransitionKey ? prevTransitionKey : undefined
|
||||||
);
|
);
|
||||||
|
|||||||
@ -37,7 +37,7 @@ import useFlag from '../../../hooks/useFlag';
|
|||||||
import useGetSelectionRange from '../../../hooks/useGetSelectionRange';
|
import useGetSelectionRange from '../../../hooks/useGetSelectionRange';
|
||||||
import useLastCallback from '../../../hooks/useLastCallback';
|
import useLastCallback from '../../../hooks/useLastCallback';
|
||||||
import useOldLang from '../../../hooks/useOldLang';
|
import useOldLang from '../../../hooks/useOldLang';
|
||||||
import usePrevious from '../../../hooks/usePrevious';
|
import usePreviousDeprecated from '../../../hooks/usePreviousDeprecated';
|
||||||
import useScrolledState from '../../../hooks/useScrolledState';
|
import useScrolledState from '../../../hooks/useScrolledState';
|
||||||
import useCustomEmojiTooltip from './hooks/useCustomEmojiTooltip';
|
import useCustomEmojiTooltip from './hooks/useCustomEmojiTooltip';
|
||||||
import useEmojiTooltip from './hooks/useEmojiTooltip';
|
import useEmojiTooltip from './hooks/useEmojiTooltip';
|
||||||
@ -149,7 +149,7 @@ const AttachmentModal: FC<OwnProps & StateProps> = ({
|
|||||||
const inputRef = useRef<HTMLDivElement>(null);
|
const inputRef = useRef<HTMLDivElement>(null);
|
||||||
|
|
||||||
const hideTimeoutRef = useRef<number>();
|
const hideTimeoutRef = useRef<number>();
|
||||||
const prevAttachments = usePrevious(attachments);
|
const prevAttachments = usePreviousDeprecated(attachments);
|
||||||
const renderingAttachments = attachments.length ? attachments : prevAttachments;
|
const renderingAttachments = attachments.length ? attachments : prevAttachments;
|
||||||
const { isMobile } = useAppLayout();
|
const { isMobile } = useAppLayout();
|
||||||
|
|
||||||
|
|||||||
@ -13,7 +13,7 @@ import captureEscKeyListener from '../../../util/captureEscKeyListener';
|
|||||||
import useHorizontalScroll from '../../../hooks/useHorizontalScroll';
|
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 usePrevious from '../../../hooks/usePrevious';
|
import usePreviousDeprecated from '../../../hooks/usePreviousDeprecated';
|
||||||
import useShowTransition from '../../../hooks/useShowTransition';
|
import useShowTransition from '../../../hooks/useShowTransition';
|
||||||
|
|
||||||
import StickerButton from '../../common/StickerButton';
|
import StickerButton from '../../common/StickerButton';
|
||||||
@ -53,7 +53,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 } = useShowTransition(isOpen, undefined, undefined, false);
|
||||||
const prevStickers = usePrevious(customEmoji, true);
|
const prevStickers = usePreviousDeprecated(customEmoji, true);
|
||||||
const displayedStickers = customEmoji || prevStickers;
|
const displayedStickers = customEmoji || prevStickers;
|
||||||
|
|
||||||
useHorizontalScroll(containerRef);
|
useHorizontalScroll(containerRef);
|
||||||
|
|||||||
@ -12,7 +12,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 usePrevious from '../../../hooks/usePrevious';
|
import usePreviousDeprecated from '../../../hooks/usePreviousDeprecated';
|
||||||
import useShowTransition from '../../../hooks/useShowTransition';
|
import useShowTransition from '../../../hooks/useShowTransition';
|
||||||
|
|
||||||
import Portal from '../../ui/Portal';
|
import Portal from '../../ui/Portal';
|
||||||
@ -43,7 +43,7 @@ const DropArea: FC<OwnProps> = ({
|
|||||||
const { showNotification } = getActions();
|
const { showNotification } = getActions();
|
||||||
// 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 = usePrevious(withQuick);
|
const prevWithQuick = usePreviousDeprecated(withQuick);
|
||||||
const { shouldRender, transitionClassNames } = useShowTransition(isOpen);
|
const { shouldRender, transitionClassNames } = useShowTransition(isOpen);
|
||||||
const isInAlbum = editingMessage && editingMessage?.groupedId;
|
const isInAlbum = editingMessage && editingMessage?.groupedId;
|
||||||
|
|
||||||
|
|||||||
@ -16,7 +16,7 @@ import { IS_TOUCH_ENV } from '../../../util/windowEnvironment';
|
|||||||
import useCurrentOrPrev from '../../../hooks/useCurrentOrPrev';
|
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 usePrevious from '../../../hooks/usePrevious';
|
import usePreviousDeprecated from '../../../hooks/usePreviousDeprecated';
|
||||||
import useShowTransition from '../../../hooks/useShowTransition';
|
import useShowTransition from '../../../hooks/useShowTransition';
|
||||||
import { useKeyboardNavigation } from './hooks/useKeyboardNavigation';
|
import { useKeyboardNavigation } from './hooks/useKeyboardNavigation';
|
||||||
|
|
||||||
@ -117,7 +117,7 @@ const InlineBotTooltip: FC<OwnProps> = ({
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
const prevInlineBotResults = usePrevious(
|
const prevInlineBotResults = usePreviousDeprecated(
|
||||||
inlineBotResults?.length
|
inlineBotResults?.length
|
||||||
? inlineBotResults
|
? inlineBotResults
|
||||||
: undefined,
|
: undefined,
|
||||||
|
|||||||
@ -8,7 +8,7 @@ import buildClassName from '../../../util/buildClassName';
|
|||||||
import setTooltipItemVisible from '../../../util/setTooltipItemVisible';
|
import setTooltipItemVisible from '../../../util/setTooltipItemVisible';
|
||||||
|
|
||||||
import useLastCallback from '../../../hooks/useLastCallback';
|
import useLastCallback from '../../../hooks/useLastCallback';
|
||||||
import usePrevious from '../../../hooks/usePrevious';
|
import usePreviousDeprecated from '../../../hooks/usePreviousDeprecated';
|
||||||
import useShowTransition from '../../../hooks/useShowTransition';
|
import useShowTransition from '../../../hooks/useShowTransition';
|
||||||
import { useKeyboardNavigation } from './hooks/useKeyboardNavigation';
|
import { useKeyboardNavigation } from './hooks/useKeyboardNavigation';
|
||||||
|
|
||||||
@ -74,7 +74,7 @@ const MentionTooltip: FC<OwnProps> = ({
|
|||||||
}
|
}
|
||||||
}, [filteredUsers, onClose]);
|
}, [filteredUsers, onClose]);
|
||||||
|
|
||||||
const prevChatMembers = usePrevious(
|
const prevChatMembers = usePreviousDeprecated(
|
||||||
filteredUsers?.length
|
filteredUsers?.length
|
||||||
? filteredUsers
|
? filteredUsers
|
||||||
: undefined,
|
: undefined,
|
||||||
|
|||||||
@ -11,7 +11,7 @@ import buildClassName from '../../../util/buildClassName';
|
|||||||
import captureEscKeyListener from '../../../util/captureEscKeyListener';
|
import captureEscKeyListener from '../../../util/captureEscKeyListener';
|
||||||
|
|
||||||
import { useIntersectionObserver } from '../../../hooks/useIntersectionObserver';
|
import { useIntersectionObserver } from '../../../hooks/useIntersectionObserver';
|
||||||
import usePrevious from '../../../hooks/usePrevious';
|
import usePreviousDeprecated from '../../../hooks/usePreviousDeprecated';
|
||||||
import useSendMessageAction from '../../../hooks/useSendMessageAction';
|
import useSendMessageAction from '../../../hooks/useSendMessageAction';
|
||||||
import useShowTransition from '../../../hooks/useShowTransition';
|
import useShowTransition from '../../../hooks/useShowTransition';
|
||||||
|
|
||||||
@ -49,7 +49,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 } = useShowTransition(isOpen, undefined, undefined, false);
|
||||||
const prevStickers = usePrevious(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);
|
||||||
|
|
||||||
|
|||||||
@ -26,7 +26,7 @@ import useForceUpdate from '../../../hooks/useForceUpdate';
|
|||||||
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 usePrevious from '../../../hooks/usePrevious';
|
import usePreviousDeprecated from '../../../hooks/usePreviousDeprecated';
|
||||||
import useDevicePixelRatio from '../../../hooks/window/useDevicePixelRatio';
|
import useDevicePixelRatio from '../../../hooks/window/useDevicePixelRatio';
|
||||||
|
|
||||||
import Avatar from '../../common/Avatar';
|
import Avatar from '../../common/Avatar';
|
||||||
@ -81,7 +81,7 @@ const Location: FC<OwnProps> = ({
|
|||||||
|
|
||||||
const mediaHash = buildStaticMapHash(point, width, height, zoom, dpr);
|
const mediaHash = buildStaticMapHash(point, width, height, zoom, dpr);
|
||||||
const mediaBlobUrl = useMedia(mediaHash);
|
const mediaBlobUrl = useMedia(mediaHash);
|
||||||
const prevMediaBlobUrl = usePrevious(mediaBlobUrl, true);
|
const prevMediaBlobUrl = usePreviousDeprecated(mediaBlobUrl, true);
|
||||||
const mapBlobUrl = mediaBlobUrl || prevMediaBlobUrl;
|
const mapBlobUrl = mediaBlobUrl || prevMediaBlobUrl;
|
||||||
|
|
||||||
const accuracyRadiusPx = useMemo(() => {
|
const accuracyRadiusPx = useMemo(() => {
|
||||||
|
|||||||
@ -130,7 +130,7 @@ import { dispatchHeavyAnimationEvent } from '../../../hooks/useHeavyAnimationChe
|
|||||||
import { useOnIntersect } from '../../../hooks/useIntersectionObserver';
|
import { useOnIntersect } from '../../../hooks/useIntersectionObserver';
|
||||||
import useLastCallback from '../../../hooks/useLastCallback';
|
import useLastCallback from '../../../hooks/useLastCallback';
|
||||||
import useOldLang from '../../../hooks/useOldLang';
|
import useOldLang from '../../../hooks/useOldLang';
|
||||||
import usePrevious from '../../../hooks/usePrevious';
|
import usePreviousDeprecated from '../../../hooks/usePreviousDeprecated';
|
||||||
import useResizeObserver from '../../../hooks/useResizeObserver';
|
import useResizeObserver from '../../../hooks/useResizeObserver';
|
||||||
import useShowTransition from '../../../hooks/useShowTransition';
|
import useShowTransition from '../../../hooks/useShowTransition';
|
||||||
import useTextLanguage from '../../../hooks/useTextLanguage';
|
import useTextLanguage from '../../../hooks/useTextLanguage';
|
||||||
@ -720,7 +720,7 @@ const Message: FC<OwnProps & StateProps> = ({
|
|||||||
chatTranslations, chatId, shouldTranslate ? messageId : undefined, requestedTranslationLanguage,
|
chatTranslations, chatId, shouldTranslate ? messageId : undefined, requestedTranslationLanguage,
|
||||||
);
|
);
|
||||||
// Used to display previous result while new one is loading
|
// Used to display previous result while new one is loading
|
||||||
const previousTranslatedText = usePrevious(translatedText, Boolean(shouldTranslate));
|
const previousTranslatedText = usePreviousDeprecated(translatedText, Boolean(shouldTranslate));
|
||||||
|
|
||||||
const currentTranslatedText = translatedText || previousTranslatedText;
|
const currentTranslatedText = translatedText || previousTranslatedText;
|
||||||
|
|
||||||
|
|||||||
@ -24,7 +24,7 @@ import useLastCallback from '../../../hooks/useLastCallback';
|
|||||||
import useLayoutEffectWithPrevDeps from '../../../hooks/useLayoutEffectWithPrevDeps';
|
import useLayoutEffectWithPrevDeps from '../../../hooks/useLayoutEffectWithPrevDeps';
|
||||||
import useMediaTransition from '../../../hooks/useMediaTransition';
|
import useMediaTransition from '../../../hooks/useMediaTransition';
|
||||||
import useMediaWithLoadProgress from '../../../hooks/useMediaWithLoadProgress';
|
import useMediaWithLoadProgress from '../../../hooks/useMediaWithLoadProgress';
|
||||||
import usePrevious from '../../../hooks/usePrevious';
|
import usePreviousDeprecated from '../../../hooks/usePreviousDeprecated';
|
||||||
import useShowTransition from '../../../hooks/useShowTransition';
|
import useShowTransition from '../../../hooks/useShowTransition';
|
||||||
import useBlurredMediaThumbRef from './hooks/useBlurredMediaThumbRef';
|
import useBlurredMediaThumbRef from './hooks/useBlurredMediaThumbRef';
|
||||||
|
|
||||||
@ -134,7 +134,7 @@ const Photo = <T,>({
|
|||||||
shouldLoad && !fullMediaData,
|
shouldLoad && !fullMediaData,
|
||||||
uploadProgress !== undefined,
|
uploadProgress !== undefined,
|
||||||
);
|
);
|
||||||
const wasLoadDisabled = usePrevious(isLoadAllowed) === false;
|
const wasLoadDisabled = usePreviousDeprecated(isLoadAllowed) === false;
|
||||||
|
|
||||||
const {
|
const {
|
||||||
shouldRender: shouldRenderSpinner,
|
shouldRender: shouldRenderSpinner,
|
||||||
|
|||||||
@ -27,7 +27,7 @@ import { useIsIntersecting } from '../../../hooks/useIntersectionObserver';
|
|||||||
import useLastCallback from '../../../hooks/useLastCallback';
|
import useLastCallback from '../../../hooks/useLastCallback';
|
||||||
import useMediaTransition from '../../../hooks/useMediaTransition';
|
import useMediaTransition from '../../../hooks/useMediaTransition';
|
||||||
import useMediaWithLoadProgress from '../../../hooks/useMediaWithLoadProgress';
|
import useMediaWithLoadProgress from '../../../hooks/useMediaWithLoadProgress';
|
||||||
import usePrevious from '../../../hooks/usePrevious';
|
import usePreviousDeprecated from '../../../hooks/usePreviousDeprecated';
|
||||||
import useShowTransition from '../../../hooks/useShowTransition';
|
import useShowTransition from '../../../hooks/useShowTransition';
|
||||||
import useBlurredMediaThumbRef from './hooks/useBlurredMediaThumbRef';
|
import useBlurredMediaThumbRef from './hooks/useBlurredMediaThumbRef';
|
||||||
|
|
||||||
@ -104,7 +104,7 @@ const RoundVideo: FC<OwnProps> = ({
|
|||||||
const thumbClassNames = useMediaTransition(!noThumb);
|
const thumbClassNames = useMediaTransition(!noThumb);
|
||||||
const thumbDataUri = getMessageMediaThumbDataUri(message);
|
const thumbDataUri = getMessageMediaThumbDataUri(message);
|
||||||
const isTransferring = (isLoadAllowed && !isPlayerReady) || isDownloading;
|
const isTransferring = (isLoadAllowed && !isPlayerReady) || isDownloading;
|
||||||
const wasLoadDisabled = usePrevious(isLoadAllowed) === false;
|
const wasLoadDisabled = usePreviousDeprecated(isLoadAllowed) === false;
|
||||||
|
|
||||||
const {
|
const {
|
||||||
shouldRender: shouldSpinnerRender,
|
shouldRender: shouldSpinnerRender,
|
||||||
|
|||||||
@ -25,7 +25,7 @@ import useLastCallback from '../../../hooks/useLastCallback';
|
|||||||
import useMedia from '../../../hooks/useMedia';
|
import useMedia from '../../../hooks/useMedia';
|
||||||
import useMediaTransition from '../../../hooks/useMediaTransition';
|
import useMediaTransition from '../../../hooks/useMediaTransition';
|
||||||
import useMediaWithLoadProgress from '../../../hooks/useMediaWithLoadProgress';
|
import useMediaWithLoadProgress from '../../../hooks/useMediaWithLoadProgress';
|
||||||
import usePrevious from '../../../hooks/usePrevious';
|
import usePreviousDeprecated from '../../../hooks/usePreviousDeprecated';
|
||||||
import useShowTransition from '../../../hooks/useShowTransition';
|
import useShowTransition from '../../../hooks/useShowTransition';
|
||||||
import useBlurredMediaThumbRef from './hooks/useBlurredMediaThumbRef';
|
import useBlurredMediaThumbRef from './hooks/useBlurredMediaThumbRef';
|
||||||
|
|
||||||
@ -152,7 +152,7 @@ const Video = <T,>({
|
|||||||
uploadProgress !== undefined,
|
uploadProgress !== undefined,
|
||||||
);
|
);
|
||||||
|
|
||||||
const wasLoadDisabled = usePrevious(isLoadAllowed) === false;
|
const wasLoadDisabled = usePreviousDeprecated(isLoadAllowed) === false;
|
||||||
const {
|
const {
|
||||||
shouldRender: shouldRenderSpinner,
|
shouldRender: shouldRenderSpinner,
|
||||||
transitionClassNames: spinnerClassNames,
|
transitionClassNames: spinnerClassNames,
|
||||||
|
|||||||
@ -8,7 +8,7 @@ import type { TabState } from '../../../global/types';
|
|||||||
import { selectChatFolder } from '../../../global/selectors';
|
import { selectChatFolder } from '../../../global/selectors';
|
||||||
|
|
||||||
import useOldLang from '../../../hooks/useOldLang';
|
import useOldLang from '../../../hooks/useOldLang';
|
||||||
import usePrevious from '../../../hooks/usePrevious';
|
import usePreviousDeprecated from '../../../hooks/usePreviousDeprecated';
|
||||||
|
|
||||||
import Modal from '../../ui/Modal';
|
import Modal from '../../ui/Modal';
|
||||||
import Tab from '../../ui/Tab';
|
import Tab from '../../ui/Tab';
|
||||||
@ -35,8 +35,8 @@ const ChatlistInviteModal: FC<OwnProps & StateProps> = ({
|
|||||||
const lang = useOldLang();
|
const lang = useOldLang();
|
||||||
|
|
||||||
const isOpen = Boolean(modal);
|
const isOpen = Boolean(modal);
|
||||||
const renderingInfo = usePrevious(modal) || modal;
|
const renderingInfo = usePreviousDeprecated(modal) || modal;
|
||||||
const renderingFolder = usePrevious(folder) || folder;
|
const renderingFolder = usePreviousDeprecated(folder) || folder;
|
||||||
|
|
||||||
const title = useMemo(() => {
|
const title = useMemo(() => {
|
||||||
if (!renderingInfo) return undefined;
|
if (!renderingInfo) return undefined;
|
||||||
|
|||||||
@ -24,7 +24,7 @@ import renderText from '../../../common/helpers/renderText';
|
|||||||
import useLang from '../../../../hooks/useLang';
|
import useLang from '../../../../hooks/useLang';
|
||||||
import useLastCallback from '../../../../hooks/useLastCallback';
|
import useLastCallback from '../../../../hooks/useLastCallback';
|
||||||
import useOldLang from '../../../../hooks/useOldLang';
|
import useOldLang from '../../../../hooks/useOldLang';
|
||||||
import usePrevious from '../../../../hooks/usePrevious';
|
import usePreviousDeprecated from '../../../../hooks/usePreviousDeprecated';
|
||||||
|
|
||||||
import AnimatedIconFromSticker from '../../../common/AnimatedIconFromSticker';
|
import AnimatedIconFromSticker from '../../../common/AnimatedIconFromSticker';
|
||||||
import Icon from '../../../common/icons/Icon';
|
import Icon from '../../../common/icons/Icon';
|
||||||
@ -243,7 +243,7 @@ const StarsTransactionModal: FC<OwnProps & StateProps> = ({
|
|||||||
};
|
};
|
||||||
}, [transaction, oldLang, peer, isGift, animatedStickerData, giftOutAboutText, giftEntryAboutText]);
|
}, [transaction, oldLang, peer, isGift, animatedStickerData, giftOutAboutText, giftEntryAboutText]);
|
||||||
|
|
||||||
const prevModalData = usePrevious(starModalData);
|
const prevModalData = usePreviousDeprecated(starModalData);
|
||||||
const renderingModalData = prevModalData || starModalData;
|
const renderingModalData = prevModalData || starModalData;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|||||||
@ -27,7 +27,7 @@ import useAppLayout from '../../../hooks/useAppLayout';
|
|||||||
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 usePrevious from '../../../hooks/usePrevious';
|
import usePreviousDeprecated from '../../../hooks/usePreviousDeprecated';
|
||||||
import useSyncEffect from '../../../hooks/useSyncEffect';
|
import useSyncEffect from '../../../hooks/useSyncEffect';
|
||||||
import usePopupLimit from './hooks/usePopupLimit';
|
import usePopupLimit from './hooks/usePopupLimit';
|
||||||
import useWebAppFrame from './hooks/useWebAppFrame';
|
import useWebAppFrame from './hooks/useWebAppFrame';
|
||||||
@ -561,10 +561,10 @@ const WebAppModal: FC<OwnProps & StateProps> = ({
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
const prevMainButtonColor = usePrevious(mainButton?.color, true);
|
const prevMainButtonColor = usePreviousDeprecated(mainButton?.color, true);
|
||||||
const prevMainButtonTextColor = usePrevious(mainButton?.textColor, true);
|
const prevMainButtonTextColor = usePreviousDeprecated(mainButton?.textColor, true);
|
||||||
const prevMainButtonIsActive = usePrevious(mainButton && Boolean(mainButton.isActive), true);
|
const prevMainButtonIsActive = usePreviousDeprecated(mainButton && Boolean(mainButton.isActive), true);
|
||||||
const prevMainButtonText = usePrevious(mainButton?.text, true);
|
const prevMainButtonText = usePreviousDeprecated(mainButton?.text, true);
|
||||||
|
|
||||||
const mainButtonCurrentColor = mainButton?.color || prevMainButtonColor;
|
const mainButtonCurrentColor = mainButton?.color || prevMainButtonColor;
|
||||||
const mainButtonCurrentTextColor = mainButton?.textColor || prevMainButtonTextColor;
|
const mainButtonCurrentTextColor = mainButton?.textColor || prevMainButtonTextColor;
|
||||||
|
|||||||
@ -22,7 +22,7 @@ import usePaymentReducer from '../../hooks/reducers/usePaymentReducer';
|
|||||||
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 usePrevious from '../../hooks/usePrevious';
|
import usePreviousDeprecated from '../../hooks/usePreviousDeprecated';
|
||||||
|
|
||||||
import Button from '../ui/Button';
|
import Button from '../ui/Button';
|
||||||
import Modal from '../ui/Modal';
|
import Modal from '../ui/Modal';
|
||||||
@ -135,8 +135,8 @@ const PaymentModal: FC<OwnProps & StateProps & GlobalStateProps> = ({
|
|||||||
const [isLoading, setIsLoading] = useState(false);
|
const [isLoading, setIsLoading] = useState(false);
|
||||||
const [isTosAccepted, setIsTosAccepted] = useState(false);
|
const [isTosAccepted, setIsTosAccepted] = useState(false);
|
||||||
const [twoFaPassword, setTwoFaPassword] = useState('');
|
const [twoFaPassword, setTwoFaPassword] = useState('');
|
||||||
const prevStep = usePrevious(step, true);
|
const prevStep = usePreviousDeprecated(step, true);
|
||||||
const prevRequestId = usePrevious(requestId);
|
const prevRequestId = usePreviousDeprecated(requestId);
|
||||||
const canRenderFooter = step !== PaymentStep.ConfirmPayment;
|
const canRenderFooter = step !== PaymentStep.ConfirmPayment;
|
||||||
|
|
||||||
const setStep = useCallback((nextStep) => {
|
const setStep = useCallback((nextStep) => {
|
||||||
|
|||||||
@ -18,7 +18,7 @@ import sortChatIds from '../common/helpers/sortChatIds';
|
|||||||
|
|
||||||
import useHistoryBack from '../../hooks/useHistoryBack';
|
import useHistoryBack from '../../hooks/useHistoryBack';
|
||||||
import useOldLang from '../../hooks/useOldLang';
|
import useOldLang from '../../hooks/useOldLang';
|
||||||
import usePrevious from '../../hooks/usePrevious';
|
import usePreviousDeprecated from '../../hooks/usePreviousDeprecated';
|
||||||
|
|
||||||
import PeerPicker from '../common/pickers/PeerPicker';
|
import PeerPicker from '../common/pickers/PeerPicker';
|
||||||
import FloatingActionButton from '../ui/FloatingActionButton';
|
import FloatingActionButton from '../ui/FloatingActionButton';
|
||||||
@ -63,7 +63,7 @@ const AddChatMembers: FC<OwnProps & StateProps> = ({
|
|||||||
|
|
||||||
const lang = useOldLang();
|
const lang = useOldLang();
|
||||||
const [selectedMemberIds, setSelectedMemberIds] = useState<string[]>([]);
|
const [selectedMemberIds, setSelectedMemberIds] = useState<string[]>([]);
|
||||||
const prevSelectedMemberIds = usePrevious(selectedMemberIds);
|
const prevSelectedMemberIds = usePreviousDeprecated(selectedMemberIds);
|
||||||
const noPickerScrollRestore = prevSelectedMemberIds === selectedMemberIds;
|
const noPickerScrollRestore = prevSelectedMemberIds === selectedMemberIds;
|
||||||
|
|
||||||
useHistoryBack({
|
useHistoryBack({
|
||||||
|
|||||||
@ -17,7 +17,7 @@ import { selectTabState } from '../../global/selectors';
|
|||||||
import { renderTextWithEntities } from '../common/helpers/renderTextWithEntities';
|
import { renderTextWithEntities } from '../common/helpers/renderTextWithEntities';
|
||||||
|
|
||||||
import useOldLang from '../../hooks/useOldLang';
|
import useOldLang from '../../hooks/useOldLang';
|
||||||
import usePrevious from '../../hooks/usePrevious';
|
import usePreviousDeprecated from '../../hooks/usePreviousDeprecated';
|
||||||
|
|
||||||
import GroupChatInfo from '../common/GroupChatInfo';
|
import GroupChatInfo from '../common/GroupChatInfo';
|
||||||
import PrivateChatInfo from '../common/PrivateChatInfo';
|
import PrivateChatInfo from '../common/PrivateChatInfo';
|
||||||
@ -58,7 +58,7 @@ const PollAnswerResults: FC<OwnProps & StateProps> = ({
|
|||||||
closePollResults,
|
closePollResults,
|
||||||
} = getActions();
|
} = getActions();
|
||||||
|
|
||||||
const prevVotersCount = usePrevious<number>(answerVote.votersCount);
|
const prevVotersCount = usePreviousDeprecated<number>(answerVote.votersCount);
|
||||||
const [isLoading, setIsLoading] = useState<boolean>(true);
|
const [isLoading, setIsLoading] = useState<boolean>(true);
|
||||||
const areVotersLoaded = Boolean(voters);
|
const areVotersLoaded = Boolean(voters);
|
||||||
const { option, text } = answer;
|
const { option, text } = answer;
|
||||||
|
|||||||
@ -19,7 +19,7 @@ import { selectCurrentLimit } from '../../../global/selectors/limits';
|
|||||||
import useFlag from '../../../hooks/useFlag';
|
import useFlag from '../../../hooks/useFlag';
|
||||||
import useHistoryBack from '../../../hooks/useHistoryBack';
|
import useHistoryBack from '../../../hooks/useHistoryBack';
|
||||||
import useOldLang from '../../../hooks/useOldLang';
|
import useOldLang from '../../../hooks/useOldLang';
|
||||||
import usePrevious from '../../../hooks/usePrevious';
|
import usePreviousDeprecated from '../../../hooks/usePreviousDeprecated';
|
||||||
|
|
||||||
import ManageUsernames from '../../common/ManageUsernames';
|
import ManageUsernames from '../../common/ManageUsernames';
|
||||||
import SafeLink from '../../common/SafeLink';
|
import SafeLink from '../../common/SafeLink';
|
||||||
@ -82,7 +82,7 @@ const ManageChatPrivacyType: FC<OwnProps & StateProps> = ({
|
|||||||
const [isRevokeConfirmDialogOpen, openRevokeConfirmDialog, closeRevokeConfirmDialog] = useFlag();
|
const [isRevokeConfirmDialogOpen, openRevokeConfirmDialog, closeRevokeConfirmDialog] = useFlag();
|
||||||
const [isUsernameLostDialogOpen, openUsernameLostDialog, closeUsernameLostDialog] = useFlag();
|
const [isUsernameLostDialogOpen, openUsernameLostDialog, closeUsernameLostDialog] = useFlag();
|
||||||
|
|
||||||
const previousIsUsernameAvailable = usePrevious(isUsernameAvailable);
|
const previousIsUsernameAvailable = usePreviousDeprecated(isUsernameAvailable);
|
||||||
const renderingIsUsernameAvailable = isUsernameAvailable ?? previousIsUsernameAvailable;
|
const renderingIsUsernameAvailable = isUsernameAvailable ?? previousIsUsernameAvailable;
|
||||||
|
|
||||||
const canUpdate = isProfileFieldsTouched && Boolean(
|
const canUpdate = isProfileFieldsTouched && Boolean(
|
||||||
|
|||||||
@ -32,7 +32,7 @@ import useAppLayout from '../../hooks/useAppLayout';
|
|||||||
import useCurrentOrPrev from '../../hooks/useCurrentOrPrev';
|
import useCurrentOrPrev from '../../hooks/useCurrentOrPrev';
|
||||||
import useHistoryBack from '../../hooks/useHistoryBack';
|
import useHistoryBack from '../../hooks/useHistoryBack';
|
||||||
import useLastCallback from '../../hooks/useLastCallback';
|
import useLastCallback from '../../hooks/useLastCallback';
|
||||||
import usePrevious from '../../hooks/usePrevious';
|
import usePreviousDeprecated from '../../hooks/usePreviousDeprecated';
|
||||||
import useWindowSize from '../../hooks/window/useWindowSize';
|
import useWindowSize from '../../hooks/window/useWindowSize';
|
||||||
import useSlideSizes from './hooks/useSlideSizes';
|
import useSlideSizes from './hooks/useSlideSizes';
|
||||||
|
|
||||||
@ -91,7 +91,7 @@ function StorySlides({
|
|||||||
const containerRef = useRef<HTMLDivElement>(null);
|
const containerRef = useRef<HTMLDivElement>(null);
|
||||||
const [renderingPeerId, setRenderingPeerId] = useState(currentPeerId);
|
const [renderingPeerId, setRenderingPeerId] = useState(currentPeerId);
|
||||||
const [renderingStoryId, setRenderingStoryId] = useState(currentStoryId);
|
const [renderingStoryId, setRenderingStoryId] = useState(currentStoryId);
|
||||||
const prevPeerId = usePrevious(currentPeerId);
|
const prevPeerId = usePreviousDeprecated(currentPeerId);
|
||||||
const renderingIsArchive = useCurrentOrPrev(isArchive, true);
|
const renderingIsArchive = useCurrentOrPrev(isArchive, true);
|
||||||
const renderingIsPrivate = useCurrentOrPrev(isPrivate, true);
|
const renderingIsPrivate = useCurrentOrPrev(isPrivate, true);
|
||||||
const renderingIsSinglePeer = useCurrentOrPrev(isSinglePeer, true);
|
const renderingIsSinglePeer = useCurrentOrPrev(isSinglePeer, true);
|
||||||
|
|||||||
@ -21,7 +21,7 @@ import { animateClosing, animateOpening } from './helpers/ghostAnimation';
|
|||||||
import useFlag from '../../hooks/useFlag';
|
import useFlag from '../../hooks/useFlag';
|
||||||
import { dispatchHeavyAnimationEvent } from '../../hooks/useHeavyAnimationCheck';
|
import { dispatchHeavyAnimationEvent } from '../../hooks/useHeavyAnimationCheck';
|
||||||
import useOldLang from '../../hooks/useOldLang';
|
import useOldLang from '../../hooks/useOldLang';
|
||||||
import usePrevious from '../../hooks/usePrevious';
|
import usePreviousDeprecated from '../../hooks/usePreviousDeprecated';
|
||||||
import { dispatchPriorityPlaybackEvent } from '../../hooks/usePriorityPlaybackCheck';
|
import { dispatchPriorityPlaybackEvent } from '../../hooks/usePriorityPlaybackCheck';
|
||||||
import useSlideSizes from './hooks/useSlideSizes';
|
import useSlideSizes from './hooks/useSlideSizes';
|
||||||
import useStoryProps from './hooks/useStoryProps';
|
import useStoryProps from './hooks/useStoryProps';
|
||||||
@ -69,10 +69,10 @@ function StoryViewer({
|
|||||||
|
|
||||||
const { bestImageData, thumbnail } = useStoryProps(story);
|
const { bestImageData, thumbnail } = useStoryProps(story);
|
||||||
const slideSizes = useSlideSizes();
|
const slideSizes = useSlideSizes();
|
||||||
const isPrevOpen = usePrevious(isOpen);
|
const isPrevOpen = usePreviousDeprecated(isOpen);
|
||||||
const prevBestImageData = usePrevious(bestImageData);
|
const prevBestImageData = usePreviousDeprecated(bestImageData);
|
||||||
const prevPeerId = usePrevious(peerId);
|
const prevPeerId = usePreviousDeprecated(peerId);
|
||||||
const prevOrigin = usePrevious(origin);
|
const prevOrigin = usePreviousDeprecated(origin);
|
||||||
const isGhostAnimation = Boolean(withAnimation && !shouldSkipHistoryAnimations);
|
const isGhostAnimation = Boolean(withAnimation && !shouldSkipHistoryAnimations);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
|
|||||||
@ -3,7 +3,7 @@ import React, { useRef } from '../../lib/teact/teact';
|
|||||||
|
|
||||||
import buildClassName from '../../util/buildClassName';
|
import buildClassName from '../../util/buildClassName';
|
||||||
|
|
||||||
import usePrevious from '../../hooks/usePrevious';
|
import usePreviousDeprecated from '../../hooks/usePreviousDeprecated';
|
||||||
import useShowTransition from '../../hooks/useShowTransition';
|
import useShowTransition from '../../hooks/useShowTransition';
|
||||||
|
|
||||||
type OwnProps = {
|
type OwnProps = {
|
||||||
@ -33,8 +33,8 @@ const ShowTransition: FC<OwnProps> = ({
|
|||||||
style,
|
style,
|
||||||
ref,
|
ref,
|
||||||
}) => {
|
}) => {
|
||||||
const prevIsOpen = usePrevious(isOpen);
|
const prevIsOpen = usePreviousDeprecated(isOpen);
|
||||||
const prevChildren = usePrevious(children);
|
const prevChildren = usePreviousDeprecated(children);
|
||||||
const fromChildrenRef = useRef<React.ReactNode>();
|
const fromChildrenRef = useRef<React.ReactNode>();
|
||||||
const isFirstRender = prevIsOpen === undefined;
|
const isFirstRender = prevIsOpen === undefined;
|
||||||
const {
|
const {
|
||||||
|
|||||||
@ -10,7 +10,7 @@ import { IS_ANDROID, IS_IOS } from '../../util/windowEnvironment';
|
|||||||
|
|
||||||
import useHorizontalScroll from '../../hooks/useHorizontalScroll';
|
import useHorizontalScroll from '../../hooks/useHorizontalScroll';
|
||||||
import useOldLang from '../../hooks/useOldLang';
|
import useOldLang from '../../hooks/useOldLang';
|
||||||
import usePrevious from '../../hooks/usePrevious';
|
import usePreviousDeprecated from '../../hooks/usePreviousDeprecated';
|
||||||
|
|
||||||
import Tab from './Tab';
|
import Tab from './Tab';
|
||||||
|
|
||||||
@ -45,7 +45,7 @@ const TabList: 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 previousActiveTab = usePrevious(activeTab);
|
const previousActiveTab = usePreviousDeprecated(activeTab);
|
||||||
|
|
||||||
useHorizontalScroll(containerRef, undefined, true);
|
useHorizontalScroll(containerRef, undefined, true);
|
||||||
|
|
||||||
|
|||||||
@ -15,7 +15,7 @@ import { allowSwipeControlForTransition } from '../../util/swipeController';
|
|||||||
|
|
||||||
import useForceUpdate from '../../hooks/useForceUpdate';
|
import useForceUpdate from '../../hooks/useForceUpdate';
|
||||||
import { dispatchHeavyAnimationEvent } from '../../hooks/useHeavyAnimationCheck';
|
import { dispatchHeavyAnimationEvent } from '../../hooks/useHeavyAnimationCheck';
|
||||||
import usePrevious from '../../hooks/usePrevious';
|
import usePreviousDeprecated from '../../hooks/usePreviousDeprecated';
|
||||||
|
|
||||||
import './Transition.scss';
|
import './Transition.scss';
|
||||||
|
|
||||||
@ -98,7 +98,7 @@ function Transition({
|
|||||||
}
|
}
|
||||||
|
|
||||||
const rendersRef = useRef<Record<number, React.ReactNode | ChildrenFn>>({});
|
const rendersRef = useRef<Record<number, React.ReactNode | ChildrenFn>>({});
|
||||||
const prevActiveKey = usePrevious<any>(activeKey);
|
const prevActiveKey = usePreviousDeprecated<any>(activeKey);
|
||||||
const forceUpdate = useForceUpdate();
|
const forceUpdate = useForceUpdate();
|
||||||
const isAnimatingRef = useRef(false);
|
const isAnimatingRef = useRef(false);
|
||||||
const isSwipeJustCancelledRef = useRef(false);
|
const isSwipeJustCancelledRef = useRef(false);
|
||||||
|
|||||||
@ -1,9 +1,9 @@
|
|||||||
import usePrevious from './usePrevious';
|
import usePreviousDeprecated from './usePreviousDeprecated';
|
||||||
|
|
||||||
export default function useCurrentOrPrev<T extends any>(
|
export default function useCurrentOrPrev<T extends any>(
|
||||||
current: T, shouldSkipUndefined = false, shouldForceCurrent = false,
|
current: T, shouldSkipUndefined = false, shouldForceCurrent = false,
|
||||||
): T | undefined {
|
): T | undefined {
|
||||||
const prev = usePrevious(current, shouldSkipUndefined);
|
const prev = usePreviousDeprecated(current, shouldSkipUndefined);
|
||||||
|
|
||||||
// eslint-disable-next-line no-null/no-null
|
// eslint-disable-next-line no-null/no-null
|
||||||
return shouldForceCurrent || (current !== null && current !== undefined) ? current : prev;
|
return shouldForceCurrent || (current !== null && current !== undefined) ? current : prev;
|
||||||
|
|||||||
@ -5,7 +5,7 @@ import { LoadMoreDirection } from '../types';
|
|||||||
import { areSortedArraysEqual } from '../util/iteratees';
|
import { areSortedArraysEqual } from '../util/iteratees';
|
||||||
import useForceUpdate from './useForceUpdate';
|
import useForceUpdate from './useForceUpdate';
|
||||||
import useLastCallback from './useLastCallback';
|
import useLastCallback from './useLastCallback';
|
||||||
import usePrevious from './usePrevious';
|
import usePreviousDeprecated from './usePreviousDeprecated';
|
||||||
|
|
||||||
type GetMore = (args: { direction: LoadMoreDirection }) => void;
|
type GetMore = (args: { direction: LoadMoreDirection }) => void;
|
||||||
type LoadMoreBackwards = (args: { offsetId?: string | number }) => void;
|
type LoadMoreBackwards = (args: { offsetId?: string | number }) => void;
|
||||||
@ -39,8 +39,8 @@ const useInfiniteScroll = <ListId extends string | number>(
|
|||||||
requestParamsRef.current = {};
|
requestParamsRef.current = {};
|
||||||
}
|
}
|
||||||
|
|
||||||
const prevListIds = usePrevious(listIds);
|
const prevListIds = usePreviousDeprecated(listIds);
|
||||||
const prevIsDisabled = usePrevious(isDisabled);
|
const prevIsDisabled = usePreviousDeprecated(isDisabled);
|
||||||
if (listIds && !isDisabled && (listIds !== prevListIds || isDisabled !== prevIsDisabled)) {
|
if (listIds && !isDisabled && (listIds !== prevListIds || isDisabled !== prevIsDisabled)) {
|
||||||
const { viewportIds, isOnTop } = currentStateRef.current || {};
|
const { viewportIds, isOnTop } = currentStateRef.current || {};
|
||||||
const currentMiddleId = viewportIds && !isOnTop ? viewportIds[Math.round(viewportIds.length / 2)] : undefined;
|
const currentMiddleId = viewportIds && !isOnTop ? viewportIds[Math.round(viewportIds.length / 2)] : undefined;
|
||||||
|
|||||||
@ -1,11 +1,11 @@
|
|||||||
import { useRef } from '../lib/teact/teact';
|
import { useRef } from '../lib/teact/teact';
|
||||||
|
|
||||||
import useForceUpdate from './useForceUpdate';
|
import useForceUpdate from './useForceUpdate';
|
||||||
import usePrevious from './usePrevious';
|
import usePreviousDeprecated from './usePreviousDeprecated';
|
||||||
import useSyncEffect from './useSyncEffect';
|
import useSyncEffect from './useSyncEffect';
|
||||||
|
|
||||||
export default function usePrevDuringAnimation<T>(current: T, duration?: number): T {
|
export default function usePrevDuringAnimation<T>(current: T, duration?: number): T {
|
||||||
const prev = usePrevious(current, true);
|
const prev = usePreviousDeprecated(current, true);
|
||||||
const timeoutRef = useRef<number>();
|
const timeoutRef = useRef<number>();
|
||||||
const forceUpdate = useForceUpdate();
|
const forceUpdate = useForceUpdate();
|
||||||
// eslint-disable-next-line no-null/no-null
|
// eslint-disable-next-line no-null/no-null
|
||||||
|
|||||||
@ -1,17 +1,15 @@
|
|||||||
import { useRef } from '../lib/teact/teact';
|
import { useRef } from '../lib/teact/teact';
|
||||||
|
|
||||||
// Deprecated. Use `usePrevious2` instead
|
// This is not render-dependent and will never allow previous to match current
|
||||||
function usePrevious<T extends any>(next: T): T | undefined;
|
export default function usePrevious<T extends any>(current: T) {
|
||||||
function usePrevious<T extends any>(next: T, shouldSkipUndefined: true): Exclude<T, undefined> | undefined;
|
const prevRef = useRef<T>();
|
||||||
function usePrevious<T extends any>(next: T, shouldSkipUndefined?: boolean): Exclude<T, undefined> | undefined;
|
const lastRef = useRef<T>();
|
||||||
function usePrevious<T extends any>(next: T, shouldSkipUndefined?: boolean) {
|
|
||||||
const ref = useRef<T>();
|
if (lastRef.current !== current) {
|
||||||
const { current } = ref;
|
prevRef.current = lastRef.current;
|
||||||
if (!shouldSkipUndefined || next !== undefined) {
|
|
||||||
ref.current = next;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return current;
|
lastRef.current = current;
|
||||||
}
|
|
||||||
|
|
||||||
export default usePrevious;
|
return prevRef.current;
|
||||||
|
}
|
||||||
|
|||||||
@ -1,15 +0,0 @@
|
|||||||
import { useRef } from '../lib/teact/teact';
|
|
||||||
|
|
||||||
// This is not render-dependent and will never allow previous to match current
|
|
||||||
export default function usePrevious2<T extends any>(current: T) {
|
|
||||||
const prevRef = useRef<T>();
|
|
||||||
const lastRef = useRef<T>();
|
|
||||||
|
|
||||||
if (lastRef.current !== current) {
|
|
||||||
prevRef.current = lastRef.current;
|
|
||||||
}
|
|
||||||
|
|
||||||
lastRef.current = current;
|
|
||||||
|
|
||||||
return prevRef.current;
|
|
||||||
}
|
|
||||||
20
src/hooks/usePreviousDeprecated.ts
Normal file
20
src/hooks/usePreviousDeprecated.ts
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
import { useRef } from '../lib/teact/teact';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @deprecated
|
||||||
|
*/
|
||||||
|
function usePreviousDeprecated<T extends any>(next: T): T | undefined;
|
||||||
|
function usePreviousDeprecated<T extends any>(next: T, shouldSkipUndefined: true): Exclude<T, undefined> | undefined;
|
||||||
|
// eslint-disable-next-line max-len
|
||||||
|
function usePreviousDeprecated<T extends any>(next: T, shouldSkipUndefined?: boolean): Exclude<T, undefined> | undefined;
|
||||||
|
function usePreviousDeprecated<T extends any>(next: T, shouldSkipUndefined?: boolean) {
|
||||||
|
const ref = useRef<T>();
|
||||||
|
const { current } = ref;
|
||||||
|
if (!shouldSkipUndefined || next !== undefined) {
|
||||||
|
ref.current = next;
|
||||||
|
}
|
||||||
|
|
||||||
|
return current;
|
||||||
|
}
|
||||||
|
|
||||||
|
export default usePreviousDeprecated;
|
||||||
@ -1,13 +1,13 @@
|
|||||||
import { useRef } from '../lib/teact/teact';
|
import { useRef } from '../lib/teact/teact';
|
||||||
|
|
||||||
import useEffectOnce from './useEffectOnce';
|
import useEffectOnce from './useEffectOnce';
|
||||||
import usePrevious from './usePrevious';
|
import usePreviousDeprecated from './usePreviousDeprecated';
|
||||||
|
|
||||||
export default function useSyncEffect<const T extends readonly any[]>(
|
export default function useSyncEffect<const T extends readonly any[]>(
|
||||||
effect: (args: T | readonly []) => NoneToVoidFunction | void,
|
effect: (args: T | readonly []) => NoneToVoidFunction | void,
|
||||||
dependencies: T,
|
dependencies: T,
|
||||||
) {
|
) {
|
||||||
const prevDeps = usePrevious<T>(dependencies);
|
const prevDeps = usePreviousDeprecated<T>(dependencies);
|
||||||
const cleanupRef = useRef<NoneToVoidFunction>();
|
const cleanupRef = useRef<NoneToVoidFunction>();
|
||||||
|
|
||||||
if (!prevDeps || dependencies.some((d, i) => d !== prevDeps[i])) {
|
if (!prevDeps || dependencies.some((d, i) => d !== prevDeps[i])) {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user