-
Notifications
You must be signed in to change notification settings - Fork 2.9k
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
display the not found page when attachment is deleted. #23143
Changes from 3 commits
1feeb80
c9e86db
1974052
8cf2cdb
9419385
0d20879
2a7b2e5
533a553
4aff8e2
2fa9a37
b4c04b9
0dad55b
5f2b425
b9af016
a0962d1
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -98,6 +98,7 @@ function AttachmentModal(props) { | |
const [modalType, setModalType] = useState(CONST.MODAL.MODAL_TYPE.CENTERED_UNSWIPEABLE); | ||
const [isConfirmButtonDisabled, setIsConfirmButtonDisabled] = useState(false); | ||
const [confirmButtonFadeAnimation] = useState(new Animated.Value(1)); | ||
const [shouldShowDownloadButton, setShouldShowDownloadButton] = React.useState(true); | ||
const [file, setFile] = useState( | ||
props.originalFileName | ||
? { | ||
|
@@ -136,6 +137,20 @@ function AttachmentModal(props) { | |
// eslint-disable-next-line react-hooks/exhaustive-deps | ||
[props.translate], | ||
); | ||
|
||
/** | ||
* set the visibility of the download button | ||
* @param {Boolean} shouldShowButton | ||
*/ | ||
const setDownloadButtonVisibility = useCallback( | ||
(shouldShowButton) => { | ||
if (shouldShowDownloadButton === shouldShowButton) { | ||
return; | ||
} | ||
setShouldShowDownloadButton(shouldShowButton); | ||
}, | ||
[shouldShowDownloadButton], | ||
); | ||
/** | ||
* Download the currently viewed attachment. | ||
*/ | ||
|
@@ -310,7 +325,7 @@ function AttachmentModal(props) { | |
<HeaderWithBackButton | ||
title={props.headerTitle || props.translate('common.attachment')} | ||
shouldShowBorderBottom | ||
shouldShowDownloadButton={props.allowDownload} | ||
shouldShowDownloadButton={props.allowDownload && shouldShowDownloadButton} | ||
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. I am wondering if this can be just replaced with 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. I think using but we can use it in useEffect. const [shouldShowDownloadButton, setShouldShowDownloadButton] = React.useState(props.allowDownload);
useEffect(() => {
if (shouldShowDownloadButton === props.allowDownload) {
return;
}
setShouldShowDownloadButton(props.allowDownload);
}, [props.allowDownload]); what do you think? @mananjadhav 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. I think we can ignore this change. |
||
onDownloadButtonPress={() => downloadAttachment(source)} | ||
shouldShowCloseButton={!props.isSmallScreenWidth} | ||
shouldShowBackButton={props.isSmallScreenWidth} | ||
|
@@ -324,6 +339,7 @@ function AttachmentModal(props) { | |
onNavigate={onNavigate} | ||
source={props.source} | ||
onToggleKeyboard={updateConfirmButtonVisibility} | ||
setDownloadButtonVisibility={setDownloadButtonVisibility} | ||
/> | ||
) : ( | ||
Boolean(sourceForAttachmentView) && | ||
|
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.
nab, I don't think we need this comment.