-
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
Refactor AttachmentModal to function component #20365
Refactor AttachmentModal to function component #20365
Conversation
@marcochavezf @rushatgabhane One of you needs to copy/paste the Reviewer Checklist from here into a new comment on this PR and complete it. If you have the K2 extension, you can simply click: [this button] |
CLA Assistant Lite bot All contributors have signed the CLA ✍️ ✅ |
I have read the CLA Document and I hereby sign the CLA |
fd6026f
to
dda2164
Compare
@marcochavezf @rushatgabhane please review this PR |
Hi @rayane-djouah thank you for the bumps. @rushatgabhane (Contributor+ team member) will review the PR first🙂 |
@marcochavezf Can you please assign this to me as @rushatgabhane has too much on his plate ATM? |
Thanks @allroundexperts! |
Sure! |
@rayane-djouah Can you please upload screen recordings on all platforms? |
Reviewer Checklist
Screenshots/VideosWebScreen.Recording.2023-06-13.at.4.08.30.AM.movMobile Web - ChromeScreen.Recording.2023-06-13.at.4.13.02.AM.movMobile Web - SafariScreen.Recording.2023-06-13.at.4.10.26.AM.movDesktopScreen.Recording.2023-06-13.at.4.09.39.AM.moviOSScreen.Recording.2023-06-13.at.4.12.10.AM.movAndroidScreen.Recording.2023-06-13.at.4.13.58.AM.mov |
@rayane-djouah Can you please also change your commit messages so that they are more meaningful? Messages like |
d4c51ce
to
b982e8a
Compare
@rayane-djouah The screen recordings are still missing. Can you please add them? |
b982e8a
to
66cb6c3
Compare
@allroundexperts I added the screen recordings. can you please review? |
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.
LGTM!
cc @marcochavezf
66cb6c3
to
7caaad3
Compare
@marcochavezf PR ready for merge. |
@marcochavezf please review this PR |
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.
Thanks @rayane-djouah! LGTM
✋ This PR was not deployed to staging yet because QA is ongoing. It will be automatically deployed to staging after the next production release. |
🚀 Deployed to staging by https://github.com/marcochavezf in version: 1.3.30-0 🚀
|
🚀 Deployed to production by https://github.com/luacmartins in version: 1.3.30-5 🚀
|
onNavigate(attachment) { | ||
this.setState(attachment); | ||
} | ||
const onNavigate = useCallback((attachment) => { | ||
setSource(attachment.source); | ||
setFile(attachment.file); | ||
}, []); |
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.
@Julesssss
This is the change that caused #22133
Previously this.setState(attachment)
saved source
, file
and isAuthTokenRequired
to state
Now isAuthTokenRequired
is no longer set
The flag isAuthTokenRequired
is used in the download logic to create the URL needed for downloading attachments
To fix the issue we'd need to also update the isAuthTokenRequired
like so:
const onNavigate = useCallback((attachment) => {
setSource(attachment.source);
setFile(attachment.file);
setIsAuthTokenRequired(attachment.isAuthTokenRequired);
}, []);
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.
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.
Thank you for your input, @allroundexperts. I appreciate your vigilance and the tests you performed before merging the PR. However, I'd like to highlight the way fileDownload
operates. It relies heavily on the isAuthTokenRequired
as detailed in my comment #22133 (comment)
It's plausible that during the tests, downloading the initial image worked as expected, which could be misleading. The issue arises when attempting to download any subsequent image after scrolling through the carousel. This is due to the isAuthTokenRequired
state not updating accordingly.
Moreover, with the transition of the carousel to its own route, the onNavigate
function gets invoked immediately to set the initial state for the modal, further highlighting the need for an updated isAuthTokenRequired
state. I hope this clarification helps!
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.
That does make sense. This is a clear oversight. However, it might be worth checking what actually caused the issue since this was merged 3 weeks ago and we tested the downloads again with this PR which got merged 4 days ago 🤔
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'll try to pinpoint the exact change which caused this. We would surely want to fix this as well though.
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.
Pull Request #20167, which moved the carousel, depended on the proper functioning of the onNavigate
function. This function is invoked when the carousel mounts and sets the correct value of isAuthTokenRequired
. While we diligently resolved several merge conflicts when syncing main
with #20167, it's conceivable that this particular modification related to isAuthTokenRequired
may have been overlooked. Notably, this PR had received approval a while back, but the merging process was delayed due to a code freeze, which could have further contributed to the oversight.
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.
Yea, that makes sense. I reverted back to 50c16acc83
and it seemed to work fine. Now we have a clearer picture. Thanks @kidroca!
modalType: CONST.MODAL.MODAL_TYPE.CENTERED_UNSWIPEABLE, | ||
isConfirmButtonDisabled: false, | ||
confirmButtonFadeAnimation: new Animated.Value(1), | ||
file: props.originalFileName |
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.
Coming from #28036:
We could have updated file
state value whenever originalFileName
prop changes in useEffect.
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.
The root cause is here
Details
Fixed Issues
$ #16114
PROPOSAL: #16114 (comment)
Tests
Offline tests
QA Steps
PR Author Checklist
### Fixed Issues
section aboveTests
sectionOffline steps
sectionQA steps
sectiontoggleReport
and notonIconClick
)myBool && <MyComponent />
.src/languages/*
files and using the translation methodWaiting for Copy
label for a copy review on the original GH to get the correct copy.STYLE.md
) were followedAvatar
, I verified the components usingAvatar
are working as expected)/** comment above it */
this
properly so there are no scoping issues (i.e. foronClick={this.submit}
the methodthis.submit
should be bound tothis
in the constructor)this
are necessary to be bound (i.e. avoidthis.submit = this.submit.bind(this);
ifthis.submit
is never passed to a component event handler likeonClick
)StyleUtils.getBackgroundAndBorderStyle(themeColors.componentBG)
)Avatar
is modified, I verified thatAvatar
is working as expected in all cases)ScrollView
component to make it scrollable when more elements are added to the page.main
branch was merged into this PR after a review, I tested again and verified the outcome was still expected according to theTest
steps.Screenshots/Videos
Web
attachement_modal.mp4
Mobile Web - Chrome
chrome.mp4
Mobile Web - Safari
safari.mp4
Desktop
mac.mp4
iOS
ios.mp4
Android
android.mp4