Skip to content

Commit

Permalink
Merge pull request #53784 from ishpaul777/revert-53475-@chrispader/fi…
Browse files Browse the repository at this point in the history
…x-attachment-modal-screens-open-animation

Revert "fix: ProfileAvatar (modal) page has no slide in animation"

(cherry picked from commit 06abff8)

(CP triggered by luacmartins)
  • Loading branch information
luacmartins authored and OSBotify committed Dec 9, 2024
1 parent 63fcb12 commit e2b3659
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 28 deletions.
18 changes: 3 additions & 15 deletions src/components/Modal/BaseModal.tsx
Original file line number Diff line number Diff line change
@@ -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';
Expand All @@ -24,7 +24,7 @@ import type BaseModalProps from './types';

function BaseModal(
{
isVisible: isVisibleProp,
isVisible,
onClose,
shouldSetModalVisibility = true,
onModalHide = () => {},
Expand Down Expand Up @@ -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);

Expand Down
37 changes: 24 additions & 13 deletions src/pages/settings/Profile/ProfileAvatar.tsx
Original file line number Diff line number Diff line change
@@ -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';
Expand All @@ -8,39 +9,39 @@ 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<AuthScreensParamList, typeof SCREENS.PROFILE_AVATAR>;
type ProfileAvatarOnyxProps = {
personalDetails: OnyxEntry<PersonalDetailsList>;
personalDetailsMetadata: OnyxEntry<Record<string, PersonalDetailsMetadata>>;
isLoadingApp: OnyxEntry<boolean>;
};

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<AuthScreensParamList, typeof SCREENS.PROFILE_AVATAR>;

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');
const isLoading = personalDetailsMetadata?.[accountID]?.isLoading ?? (isLoadingApp && !Object.keys(personalDetail ?? {}).length);
const displayName = PersonalDetailsUtils.getDisplayNameOrDefault(personalDetail);

useEffect(() => {
if (!ValidationUtils.isValidAccountRoute(Number(accountID)) || !!avatarURL) {
if (!ValidationUtils.isValidAccountRoute(Number(accountID)) ?? !!avatarURL) {
return;
}
PersonalDetails.openPublicProfilePage(accountID);
}, [accountID, avatarURL]);

return (
<AttachmentModal
defaultOpen
headerTitle={displayName}
defaultOpen
source={UserUtils.getFullSizeAvatar(avatarURL, accountID)}
onModalClose={() => {
setTimeout(() => {
Navigation.goBack();
}, CONST.ANIMATED_TRANSITION);
Navigation.goBack();
}}
originalFileName={personalDetail?.originalFileName ?? ''}
isLoading={!!isLoading}
Expand All @@ -51,4 +52,14 @@ function ProfileAvatar({route}: ProfileAvatarProps) {

ProfileAvatar.displayName = 'ProfileAvatar';

export default ProfileAvatar;
export default withOnyx<ProfileAvatarProps, ProfileAvatarOnyxProps>({
personalDetails: {
key: ONYXKEYS.PERSONAL_DETAILS_LIST,
},
personalDetailsMetadata: {
key: ONYXKEYS.PERSONAL_DETAILS_METADATA,
},
isLoadingApp: {
key: ONYXKEYS.IS_LOADING_APP,
},
})(ProfileAvatar);

0 comments on commit e2b3659

Please sign in to comment.