-
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
Fix: Attachment Carousel not displaying images from Concierge #19724
Fix: Attachment Carousel not displaying images from Concierge #19724
Conversation
It looks like `isAuthTokenRequired` was removed by mistake during a merge Reverts a change from: edd1455
9b3bd20
to
ec0445b
Compare
I'll add Android samples on Monday In the meantime this PR is ready for review ✅ |
@hayata-suenaga @eVoloshchak 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] |
Refactors AttachmentCarousel to work with images from all origins. The previous implementation was restrictive and only allowed attachments originating from Expensify. With these changes, attachments from any origin can be displayed in the carousel. This fix ensures that all Concierge attachments, regardless of their origin, will appear as expected. The parsing logic has been improved to use `htmlparser2` for accuracy and efficiency.
Enhances error handling in AttachmentCarousel to provide a clearer user experience when an image cannot be mapped to available content. Previously, if the carousel failed to find the correct image to display, it defaulted to showing the first image. This behaviour lead to user confusion as the displayed image did not correspond to the selected one. With this change, if a user tries to open an image that cannot be mapped, an error is thrown and an error page is displayed. This explicit error handling helps users understand when there's a problem opening an image, prompting them to contact support or attempt to view another image.
No longer needed
This commit refactors the handling of attachment downloads for a more robust and consistent experience. Previously, auth-related parameters were appended to every attachment, regardless of whether they were required. The logic was also improperly placed within the carousel component, which the attachment modal relied upon to set sources correctly. This implementation could create bugs, especially since not all attachments are rendered using the carousel. This commit addresses these issues by: The AttachmentModal now manages the state of the source and isAuthTokenRequired attributes of the attachment, ensuring that they're in sync with the attachment displayed in the carousel. The AttachmentModal now determines whether to append auth-related parameters to an attachment source during download, based on the isAuthTokenRequired flag. The responsibility of appending auth parameters has been removed from the AttachmentCarousel component, making it more reusable and focused on its core functionality. These changes ensure a more reliable and consistent attachment downloading experience, and avoid scattering logic across components.
ec0445b
to
fbbeddb
Compare
This comment was marked as outdated.
This comment was marked as outdated.
Reviewer Checklist
Screenshots/VideosWebScreen.Recording.2023-05-31.at.16.08.19.movMobile Web - Chromescreen-20230531-163237.mp4Mobile Web - SafariScreen.Recording.2023-05-31.at.16.22.21.movDesktopScreen.Recording.2023-05-31.at.16.17.54.moviOSScreen.Recording.2023-05-31.at.16.20.52.movAndroidscreen-20230531-162958.mp4 |
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.
Found an issue on Android. I couldn't get Concierge to send me a bunch of images, so just hardcoded your sample message as the last message from Concierge
Sample message
Lorem ipsum<br />
<br />
More lorem<br />
<br />
This lorem is only more lorem<br />
<br />
Lorem ipsum attachment sit<br />
<br />
<img src="https://2.img-dpreview.com/files/p/E~C1000x0S4000x4000T1200x1200~articles/3925134721/0266554465.jpeg"
style="width:300px;" class="fr-fic fr-dib" alt="uploads%2sample-sample.png" /><br />
<img src="https://media.istockphoto.com/id/1096052566/vector/stamprsimp2red.jpg?s=612x612&w=0&k=20&c=KVu0nVz7ZLbZsRsx81VBZcuXZ1MlEmLk9IQabO2GkYo="
style="width:300px;" class="fr-fic fr-dib" alt="uploads%2sample-sample2.png" />
This tests well on all of the platforms except Android.
- Open an image in the Concierge conversation
- Navigate to the next image
- Notice the infinite loading spinner
It starts/stops working each time you close/open the carousel
screen-20230530-160658.mp4
Thank you for the context on this issue. I've noticed a similar problem with infinite loading on Android, but I thought it was some problem in the local environment and the emulator not having full internet access If this bug doesn't occur on mWeb Android, then it could likely be related to the Fast Image library that's being utilized internally for image loading. I've found a potential correlation with this existing issue: Although in your case, the problem doesn't involve cycling between image and PDF formats. Considering the fact that I haven't made any modifications to the loading code, and the attachment does occasionally display correctly, we can infer that the issue hasn't arisen as a result of changes made by me. Here are my reasons:
|
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 and tests well
cc: @hayata-suenaga
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!
🚀 Deployed to staging by https://github.com/hayata-suenaga in version: 1.3.21-1 🚀
|
QA'ing this one: Test 1: Verify Existing Functionality is Unaltered Test 2: Concierge Attachments Blocker, or expected? |
@trjExpensify @kidroca - Can you please look at this in a follow up? We decided internally it's not a blocker, but we should make this work. |
🚀 Deployed to production by https://github.com/AndrewGable in version: 1.3.21-2 🚀
|
Hi @AndrewGable, It appears from your message that you would like me to make a follow-up Pull Request, however, I need some clarification regarding what "this" pertains to in your message. From the issues Tom discovered, none of them seem to be regressions from this PR. I hope you confirmed that the message, "Your browser does not support HTML5 video," was present even before merging any of my changes to production. I've also done a brief review and concluded that we're looking at three separate issues:
Out of these, only the third can be directly linked as follow-up work on my end. I suggest we create separate tickets for each issue to manage them effectively. I'll promptly verify the Android issue as soon as I can. While I'm happy to assist with resolving the remaining issues, I should mention that I'm not a full-time employee on this project. Thus, if it's essential that I handle these personally, it may take longer than usual to resolve them all. Your understanding and guidance would be highly appreciated. |
Hey man, hope you're good!
If you could focus on confirming this one, as it seems like a potential regression on Android native from this PR.
Just to confirm, I don't think this is a problem with thumbnails. Rather if you receive a mp4 file from Concierge, it just shows "Your browser does not support HTML5 video." in written text. Still might not be related to this PR for sure, but did want to confirm that it's not a thumbnail issue I don't think. |
@kidroca thank you so much for your detailed explanation @trjExpensify Could you report the first two issues discovered in the #expensify-open-source channel so that GH issues are created for them and triaged there? I believe other contributors can handle them |
@trjExpensify ah I didn't see your previous message |
I confirm this, I can post a fix about it tomorrow
I haven't changed logic receiving attachments from Concierge either. My theory is that there's a |
Awesome, thanks!
understood!
👍 Thanks for jumping into that other issue to look at repro'ing it. |
Details
This Pull Request introduces a series of changes to improve the handling and downloading of attachments in our application. The main changes focus on the
AttachmentCarousel
andAttachmentModal
components.Here are the main changes:
Expanded compatibility of
AttachmentCarousel
with images originating from various sources, not only Expensify-related ones. This was done by updating the component's attachment parsing and state creation logic. This change fixes the issue where some attachments (for instance, Concierge ones) were not appearing in the carousel.Updated error handling in the
AttachmentCarousel
component. If a user tries to open an image that cannot be mapped to available content, the application now shows an error page instead of a different image. This change enhances user experience by clearly indicating when there's a problem opening an image.Refactored the
AttachmentModal
to manage the state of thesource
andisAuthTokenRequired
attributes of the attachment, ensuring that they're in sync with the attachment displayed in the carousel.Modified the
AttachmentModal
to decide whether to append auth-related parameters to an attachment source during download, based on theisAuthTokenRequired
flag.Removed the responsibility of appending auth parameters from the
AttachmentCarousel
component. This change makes the component more reusable and focused on its core functionality.Overall, these changes should provide a more reliable and consistent attachment downloading experience, and avoid scattering logic across components.
Fixed Issues
$ #18150
PROPOSAL: #18150 (comment)
Tests
Test 1: Verify Existing Functionality is Unaltered
Objective: To ensure that the implemented changes haven't affected the existing functionality.
Expected Outcomes:
Note: This PR does not address existing known issues such as the carousel occasionally displaying the wrong image (as detailed in #18150 (comment)).
Test 2: Concierge Attachments
Objective: To verify that attachments originating from Concierge are correctly identified and displayed.
Navigate to a chat with Concierge.
Request sample attachments for testing. Ask for multiple images in a single message, another message with a single image, and a third message with multiple attachments.
Sample message from Concierge feature an attachments
Expected Outcomes:
Test 3: Error Handling When Carousel Fails to Locate Selected Attachment Source
Objective: To verify that when the Carousel fails to initialize correctly, it handles the error in a predictable manner, displaying an error page instead of an incorrect image.
This test involves programmatically forcing incorrect data into the attachment carousel.
ImageRenderer
and set an arbitrary string as the modal source (seeApp/src/components/HTMLEngineProvider/HTMLRenderers/ImageRenderer.js
Line 57 in 2a786a7
Expected Outcomes:
Offline tests
The offline functionality should be unaffected by the changes introduced in this PR.
QA Steps
These steps are applicable to all platforms and both the staging and the production environments
Test 1: Verify Existing Functionality is Unaltered
Objective: To ensure that the implemented changes haven't affected the existing functionality.
Expected Outcomes:
Note: This PR does not address existing known issues such as the carousel occasionally displaying the wrong image (as detailed in #18150 (comment)).
Test 2: Concierge Attachments
Objective: To verify that attachments originating from Concierge are correctly identified and displayed.
Expected Outcomes:
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
Screen.Recording.2023-05-28.at.15.56.25.mov
Mobile Web - Chrome
Studio_Project_V1.mp4
Mobile Web - Safari
Studio_Project_V1.mp4
Desktop
Screen.Recording.2023-05-28.at.16.22.19.mov
iOS
Android