-
Notifications
You must be signed in to change notification settings - Fork 3.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: incorrect page is displayed when refreshing the page #54680
Merged
Merged
Changes from 13 commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
025c78b
fix: incorrect page is displayed when refreshing the page
truph01 c98a3a5
fix: lint
truph01 7a83b03
merge main
truph01 13d0c65
fix: disable modal animation after refreshing page
truph01 d70595e
merge main
truph01 4ed9e5a
merge maiin
truph01 ca4b1e7
fix: use useState instead of useRef
truph01 728ac39
fix: lint
truph01 e49143e
fix: lint
truph01 f429543
merge main
truph01 15c3b56
fix: add comment
truph01 669eb15
merge main
truph01 c986d69
fix: add comment
truph01 f44a299
merge main
truph01 c0ad5d2
merge main
truph01 45c2e9e
fix: Show loading indicator when the magic modal is showing
truph01 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
import React, {useState} from 'react'; | ||
import React, {useEffect, useState} from 'react'; | ||
import type {ValueOf} from 'type-fest'; | ||
import Button from '@components/Button'; | ||
import DelegateNoAccessWrapper from '@components/DelegateNoAccessWrapper'; | ||
|
@@ -15,26 +15,30 @@ import {formatPhoneNumber} from '@libs/LocalePhoneNumber'; | |
import Navigation from '@libs/Navigation/Navigation'; | ||
import type {PlatformStackScreenProps} from '@libs/Navigation/PlatformStackNavigation/types'; | ||
import type {SettingsNavigatorParamList} from '@libs/Navigation/types'; | ||
import * as PersonalDetailsUtils from '@libs/PersonalDetailsUtils'; | ||
import {getPersonalDetailByEmail} from '@libs/PersonalDetailsUtils'; | ||
import CONST from '@src/CONST'; | ||
import ROUTES from '@src/ROUTES'; | ||
import type SCREENS from '@src/SCREENS'; | ||
import DelegateMagicCodeModal from './DelegateMagicCodeModal'; | ||
|
||
type ConfirmDelegatePageProps = PlatformStackScreenProps<SettingsNavigatorParamList, typeof SCREENS.SETTINGS.DELEGATE.DELEGATE_CONFIRM>; | ||
|
||
function ConfirmDelegatePage({route}: ConfirmDelegatePageProps) { | ||
function ConfirmDelegatePage({route, navigation}: ConfirmDelegatePageProps) { | ||
const {translate} = useLocalize(); | ||
|
||
const styles = useThemeStyles(); | ||
const login = route.params.login; | ||
const role = route.params.role as ValueOf<typeof CONST.DELEGATE_ROLE>; | ||
const showValidateActionModal = route.params.showValidateActionModal === 'true'; | ||
const {isOffline} = useNetwork(); | ||
const [shouldDisableModalAnimation, setShouldDisableModalAnimation] = useState(true); | ||
|
||
const [isValidateCodeActionModalVisible, setIsValidateCodeActionModalVisible] = useState(showValidateActionModal ?? false); | ||
useEffect(() => { | ||
navigation.setParams({showValidateActionModal: String(isValidateCodeActionModalVisible)}); | ||
}, [isValidateCodeActionModalVisible, navigation]); | ||
|
||
const personalDetails = PersonalDetailsUtils.getPersonalDetailByEmail(login); | ||
const personalDetails = getPersonalDetailByEmail(login); | ||
const avatarIcon = personalDetails?.avatar ?? FallbackAvatar; | ||
const formattedLogin = formatPhoneNumber(login ?? ''); | ||
const displayName = personalDetails?.displayName ?? formattedLogin; | ||
|
@@ -49,7 +53,10 @@ function ConfirmDelegatePage({route}: ConfirmDelegatePageProps) { | |
text={translate('delegate.addCopilot')} | ||
style={styles.mt6} | ||
pressOnEnter | ||
onPress={() => setIsValidateCodeActionModalVisible(true)} | ||
onPress={() => { | ||
setShouldDisableModalAnimation(false); | ||
setIsValidateCodeActionModalVisible(true); | ||
}} | ||
/> | ||
); | ||
|
||
|
@@ -65,7 +72,7 @@ function ConfirmDelegatePage({route}: ConfirmDelegatePageProps) { | |
<DelegateNoAccessWrapper accessDeniedVariants={[CONST.DELEGATE.DENIED_ACCESS_VARIANTS.DELEGATE]}> | ||
<Text style={[styles.ph5]}>{translate('delegate.confirmCopilot')}</Text> | ||
<MenuItem | ||
avatarID={personalDetails?.accountID ?? -1} | ||
avatarID={personalDetails?.accountID ?? CONST.DEFAULT_NUMBER_ID} | ||
iconType={CONST.ICON_TYPE_AVATAR} | ||
icon={avatarIcon} | ||
title={displayName} | ||
|
@@ -80,6 +87,9 @@ function ConfirmDelegatePage({route}: ConfirmDelegatePageProps) { | |
shouldShowRightIcon | ||
/> | ||
<DelegateMagicCodeModal | ||
// We should disable the animation initially and only enable it when the user manually opens the modal | ||
// to ensure it appears immediately when refreshing the page. | ||
disableAnimation={shouldDisableModalAnimation} | ||
shouldHandleNavigationBack | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. makes a lot of sense to anyone reading this in the future, thanks for this ❤️ |
||
login={login} | ||
role={role} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@truph01 can you please put a comment here explaining why this is needed ? the git blame will not explain to others why we needed this
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I just added comment