From e2b365924a665fc7aef5c939d01d90183eebcd68 Mon Sep 17 00:00:00 2001 From: Carlos Martins Date: Mon, 9 Dec 2024 14:31:55 -0700 Subject: [PATCH] Merge pull request #53784 from ishpaul777/revert-53475-@chrispader/fix-attachment-modal-screens-open-animation Revert "fix: ProfileAvatar (modal) page has no slide in animation" (cherry picked from commit 06abff8e6291205e609e594e0308c3ea2e371218) (CP triggered by luacmartins) --- src/components/Modal/BaseModal.tsx | 18 ++-------- src/pages/settings/Profile/ProfileAvatar.tsx | 37 +++++++++++++------- 2 files changed, 27 insertions(+), 28 deletions(-) diff --git a/src/components/Modal/BaseModal.tsx b/src/components/Modal/BaseModal.tsx index 00830e0dd51c..e1c5a7c48b86 100644 --- a/src/components/Modal/BaseModal.tsx +++ b/src/components/Modal/BaseModal.tsx @@ -1,6 +1,6 @@ import {PortalHost} from '@gorhom/portal'; -import React, {forwardRef, useCallback, useEffect, useMemo, useRef, useState} from 'react'; -import {InteractionManager, View} from 'react-native'; +import React, {forwardRef, useCallback, useEffect, useMemo, useRef} from 'react'; +import {View} from 'react-native'; import ReactNativeModal from 'react-native-modal'; import ColorSchemeWrapper from '@components/ColorSchemeWrapper'; import FocusTrapForModal from '@components/FocusTrap/FocusTrapForModal'; @@ -24,7 +24,7 @@ import type BaseModalProps from './types'; function BaseModal( { - isVisible: isVisibleProp, + isVisible, onClose, shouldSetModalVisibility = true, onModalHide = () => {}, @@ -68,18 +68,6 @@ function BaseModal( const safeAreaInsets = useSafeAreaInsets(); - const [isVisible, setIsVisible] = useState(false); - useEffect(() => { - if (isVisibleProp) { - InteractionManager.runAfterInteractions(() => { - setIsVisible(true); - }); - return; - } - - setIsVisible(false); - }, [isVisibleProp]); - const isVisibleRef = useRef(isVisible); const wasVisible = usePrevious(isVisible); diff --git a/src/pages/settings/Profile/ProfileAvatar.tsx b/src/pages/settings/Profile/ProfileAvatar.tsx index f2f43b9cdc0d..a80db51580ba 100644 --- a/src/pages/settings/Profile/ProfileAvatar.tsx +++ b/src/pages/settings/Profile/ProfileAvatar.tsx @@ -1,5 +1,6 @@ import React, {useEffect} from 'react'; -import {useOnyx} from 'react-native-onyx'; +import type {OnyxEntry} from 'react-native-onyx'; +import {withOnyx} from 'react-native-onyx'; import AttachmentModal from '@components/AttachmentModal'; import Navigation from '@libs/Navigation/Navigation'; import type {PlatformStackScreenProps} from '@libs/Navigation/PlatformStackNavigation/types'; @@ -8,17 +9,19 @@ import * as PersonalDetailsUtils from '@libs/PersonalDetailsUtils'; import * as UserUtils from '@libs/UserUtils'; import * as ValidationUtils from '@libs/ValidationUtils'; import * as PersonalDetails from '@userActions/PersonalDetails'; -import CONST from '@src/CONST'; import ONYXKEYS from '@src/ONYXKEYS'; import type SCREENS from '@src/SCREENS'; +import type {PersonalDetailsList, PersonalDetailsMetadata} from '@src/types/onyx'; -type ProfileAvatarProps = PlatformStackScreenProps; +type ProfileAvatarOnyxProps = { + personalDetails: OnyxEntry; + personalDetailsMetadata: OnyxEntry>; + isLoadingApp: OnyxEntry; +}; -function ProfileAvatar({route}: ProfileAvatarProps) { - const [personalDetails] = useOnyx(ONYXKEYS.PERSONAL_DETAILS_LIST); - const [personalDetailsMetadata] = useOnyx(ONYXKEYS.PERSONAL_DETAILS_METADATA); - const [isLoadingApp = true] = useOnyx(ONYXKEYS.IS_LOADING_APP); +type ProfileAvatarProps = ProfileAvatarOnyxProps & PlatformStackScreenProps; +function ProfileAvatar({route, personalDetails, personalDetailsMetadata, isLoadingApp = true}: ProfileAvatarProps) { const personalDetail = personalDetails?.[route.params.accountID]; const avatarURL = personalDetail?.avatar ?? ''; const accountID = Number(route.params.accountID ?? '-1'); @@ -26,7 +29,7 @@ function ProfileAvatar({route}: ProfileAvatarProps) { const displayName = PersonalDetailsUtils.getDisplayNameOrDefault(personalDetail); useEffect(() => { - if (!ValidationUtils.isValidAccountRoute(Number(accountID)) || !!avatarURL) { + if (!ValidationUtils.isValidAccountRoute(Number(accountID)) ?? !!avatarURL) { return; } PersonalDetails.openPublicProfilePage(accountID); @@ -34,13 +37,11 @@ function ProfileAvatar({route}: ProfileAvatarProps) { return ( { - setTimeout(() => { - Navigation.goBack(); - }, CONST.ANIMATED_TRANSITION); + Navigation.goBack(); }} originalFileName={personalDetail?.originalFileName ?? ''} isLoading={!!isLoading} @@ -51,4 +52,14 @@ function ProfileAvatar({route}: ProfileAvatarProps) { ProfileAvatar.displayName = 'ProfileAvatar'; -export default ProfileAvatar; +export default withOnyx({ + personalDetails: { + key: ONYXKEYS.PERSONAL_DETAILS_LIST, + }, + personalDetailsMetadata: { + key: ONYXKEYS.PERSONAL_DETAILS_METADATA, + }, + isLoadingApp: { + key: ONYXKEYS.IS_LOADING_APP, + }, +})(ProfileAvatar);