-
Notifications
You must be signed in to change notification settings - Fork 3.2k
Fix attachment modal for broken images #61459
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 attachment modal for broken images #61459
Conversation
1de62f0
to
9a1634e
Compare
b3599a2
to
a4f9ae0
Compare
This eslint check error is unrelated to the linked issue, I think there should be (if there is not already) a separate issue and PR for it as I think it can break some things if done incorrectly. The download button is fixed, but I am not sure if I should remove the ability to "move" the image if the attachment is broken. We can do that when we have a single attachment chat on Native (but not on m-web, web etc.), so to keep consistency I didn't touch that, see below: Compare.mp4I also found another bug which is reproducible on main and is important to know that this PR didn't cause it. NewProblem.mp4Please, confirm expectations, so I can adjust the code/open for a review. |
src/components/Attachments/AttachmentView/useAttachmentErrors.ts
Outdated
Show resolved
Hide resolved
src/components/Attachments/AttachmentView/useAttachmentErrors.ts
Outdated
Show resolved
Hide resolved
src/components/Attachments/AttachmentView/useAttachmentErrors.ts
Outdated
Show resolved
Hide resolved
a0ebae3
to
1c360aa
Compare
@hungvu193 Please 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] |
On it 👀 |
@JakubKorytko From my understanding, you will hide the download button if attachment is error, that's also a solution but I'm curious that we didn't resolve the RCA here. In fact, we still see the error modal if we click the download button but it took 2,3 minutes, so I think we should fix this from the library (react-native-blob-util) 🤔 . Wdyt? |
I don't think that's enough. See my comment above. There are other problems with firing attachments in native:
I'm pretty sure the native version of this logic is deprecated and needs to be thoroughly investigated, but that's a separate topic. I would suggest fixing this by hiding the button for now, and raising a "bigger" issue for fixing the native version - maybe even a solid refractor, we have a lot of states in the attachment modal that don't make much sense. For example Another thing is that we have 3 context values for
Doesn't seem like a good use of context to me. I think another simple fix for this is okay for now, but at this point this component ( |
Discussing in Slack |
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.
Looks good to me!
The first attachment never seems to load for me; it always renders empty content: Screen.Recording.2025-05-12.at.14.54.21.mov |
I also found an console error while testing but not sure how to reproduce. fixed.PR.mov |
I'm aware of the missing attachment not found text - mentioned here - but this PR fixes the download button not appearing when attachment is invalid, your recording can be reproduced on the main and that, I believe, is one of the reasons @chrispader is refractoring this component logic in his PR. See discussion in the original issue for full context. |
Cool. That was pretty weird that I couldn't reproduce it on main but I can reproduce it now 😅. The last thing is, can you take a look at the console error I found here? |
That's interesting. Let me look into this and I'll get back to you. |
All these conditional statements make it easy to forget to wrap the state updates with |
Reviewer Checklist
Screenshots/VideosAndroid: HybridAppAndroid.movAndroid: mWeb ChromeAndroidChrome.moviOS: HybridAppScreen.Recording.2025-05-13.at.09.37.53.moviOS: mWeb Safarisafariz.movsafari.movMacOS: Chrome / SafariChrome.movMacOS: DesktopDesk.mov |
nice, lets try to wrap this one up |
Note for QAs: |
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
@mountiny looks like this was merged without a test passing. Please add a note explaining why this was done and remove the |
The eslint issue on this file should be handled in a separate issue to avoid regressions |
✋ 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 production by https://github.com/mountiny in version: 9.1.46-12 🚀
|
Explanation of Change
The linked issue is caused by the fact that if the attachment is not loaded correctly because it is missing, it does not give any update to the modal, so it does not update things that depend on the success of loading, such as the download button.
I've created a hook to store the status of errors indexed by serialized image sources and attached it to both the native & normal versions of the modal and its children. It is called when there is a problem with loading image and hides download button.
As for swiping left/right on broken attachments in Native and failing ESLint check, see the first comment in this PR thread.
Fixed Issues
$ #60554
PROPOSAL: N/A
Tests
Do steps below for mweb & mobile Expensify app:
Offline tests
Same as test
QA Steps
Same as test
PR Author Checklist
### Fixed Issues
section aboveTests
sectionOffline steps
sectionQA steps
sectiontoggleReport
and notonIconClick
)src/languages/*
files and using the translation methodSTYLE.md
) were followedAvatar
, I verified the components usingAvatar
are working as expected)StyleUtils.getBackgroundAndBorderStyle(theme.componentBG)
)Avatar
is modified, I verified thatAvatar
is working as expected in all cases)Design
label and/or tagged@Expensify/design
so the design team can review the changes.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
Android: Native
Compare.mp4
Android: mWeb Chrome
Video for both m-web & native in
Android: Native
iOS: Native
iOS: mWeb Safari
MacOS: Chrome / Safari
MacOS: Desktop