Open Krishna2323 opened 4 weeks ago
@jayeshmangwani 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]
@jayeshmangwani, when selecting a corrupt pdf file on native devices we don't get error and empty white background is shown. I'm looking for a solution for that.
@Krishna2323 When you push the changes for native devices, please ping me.
@jayeshmangwani, I have updated the code for native devices, can you pls check and let me know, I haven't updated the recordings for native yet.
Demo for for native devices:
https://github.com/Expensify/App/assets/85894871/11a1d222-d8fb-47d3-82c8-e40e1af20b28
@Expensify/design Please confirm the styling of the Failed to load PDF file.
text?
I would think instead of showing text like we are, we'd show our default fallback receipt view, something like this that @dannymcclain had suggested previously:
Though I think I would change out the icon to use some kind of broken image icon, something like this but in our brand style:
@shawnborton I thought in a different issue we had settled on not allowing someone to upload a corrupted image/PDF? We show the standard modal that says "Error uploading attachment..." This was the mock for that:
Am I misremembering something?
You are definitely right. So yeah, that begs the question, how did we trigger this particular "Failed to load PDF" scenario?
@shawnborton @dannymcclain To reproduce this issue, I am following this steps:
https://github.com/Expensify/App/assets/35371050/1ca7f71b-8b01-4981-9923-150f29d21817
@dannymcclain @shawnborton, Yep, you're correct here. I worked on preventing corrupted images from being uploaded, but that was specifically for images. There might be another GitHub issue addressing prevention of corrupt PDFs from being uploaded. PR.
Here is the issue for preventing corrupted pdf's from being uploaded.
Yeah, I feel like a much better solution is to prevent a corrupted PDF from being uploaded in the first place.
@hayata-suenaga @shawnborton If we are going to prevent a corrupted PDF from being uploaded, then we can close this PR and close/hold the issue in favor of https://github.com/Expensify/App/issues/34032
That's where my head is at... it seems like we won't ever be able to get to this scenario once we prevent corrupted images/files from being uploaded.
it seems like we won't ever be able to get to this scenario once we prevent corrupted images/files from being uploaded.
I don't think we know the image/file is corrupt purely on the client, so isn't it possible you'll run into this when uploading a corrupt file offline?
Hmm good question, who can confirm that?
If that's the case, I like doing something like my suggestion here.
If that's the case, I like doing something like my suggestion https://github.com/Expensify/App/pull/40607#issuecomment-2070156624.
Yeah I agree. @shawnborton do you think any of these icons would work for that? (Receipt Slash and Document Slash are already in the system—Image Slash is one that I just made based off of the Image icon and Receipt Slash icon.)
Yeah I think any of these would be great! I think I like doing something super generic in case this is a pattern we'd repeat not only for PDF-specific receipts but for all receipts in general that are corrupt. So that being said, I lean towards the first option?
Yeah first option makes sense to me—that way we could use it for any file type of receipt that borked.
I don't think we know the image/file is corrupt purely on the client, so isn't it possible you'll run into this when uploading a corrupt file offline?
I'm not familiar with how we're handling the PDF upload on the client side, but we try to display a preview of the PDF before the user attempts to send it. If the PDF is corrupted, we know that when we try to display the preview.
@Krishna2323, could you confirm that you seem to be working on the issue to prevent the corrupt PDF from being uploaded?
Regardless, I think it's a good idea to still implement the fallback view if the attachment is corrupted though.
@hayata-suenaga, I've worked on preventing corrupt images from being uploaded, and it seems to be functioning well across all platforms. As for the PDF issue, it's slated to be addressed in this issue. The proposal selected to resolve the problem doesn't appear to offer a straightforward solution for detecting corrupt PDFs across all platforms. Therefore, I agree with your suggestion to proceed with implementing the fallback view. Additionally, I've noticed that some PDFs preview correctly on the confirmation list but then display an error message stating that the PDF can't be loaded.
You can try with this pdf: Bug6460367_1713968986208.class-9-maths-chapter-10-solutions-2024-02-08_22_17_00.194.pdf
This works fine until we submit the request and go to details page but as soon as we refresh it shows Failed to load PDF file
.
Ok, so I guess, we agree on showing fallback for corrupted files, will start implementing the changes today and update.
Ok, so I guess, we agree on showing fallback for corrupted files, will start implementing the changes today and update.
Yes sorry if that wan't clear 🙇 thank you for pushing the PR forward 👍
@dannymcclain, I don't think we have Receipt Slash
in the app, can you pls share it.
I don't think we have Receipt Slash in the app, can you pls share it.
@Krishna2323 No prob!
Code changes are done. @dannymcclain @shawnborton, can we confirm what width and height size we should use for the ReceiptSlash icon?
With 72px:
Receipt doc size:
Hmm I could have sworn we already have a pattern in place for receipt placeholders, like these:
Can we match that size? From Figma, it looks like they are at 80x80.
@shawnborton @dannymcclain @hayata-suenaga @jayeshmangwani, while recording videos for recent changes, I found that we can prevent users from uploading corrupt PDFs, and it works on all platforms. There will be a minor difference in corrupt image detection and corrupt PDF detection: for images, we show the alert modal immediately after the user selects it, and for PDFs, we will show it on the confirmation page, just like we show the alert for protected PDFs on the confirmation page. I don't think that's a very major inconsistency, so I have already updated the code for that. The fallback is also implemented in case a corrupt PDF passes the check, but that will be in very rare cases.
https://github.com/Expensify/App/assets/85894871/716891b9-0e5d-4649-a612-cdda525ce25e
https://github.com/Expensify/App/assets/85894871/1f3564cf-46a5-4888-a09b-7c8907d15ef1
https://github.com/Expensify/App/assets/85894871/c0a85e3b-96cd-438a-bbb0-591537b852ee
@jayeshmangwani, you can start the review.
Two questions:
Why can't we detect the corrupted PDF immediately, the same way we do for images?
How did you get a camera view like this where the capture button is off to the right? Looks like we're missing a flash icon?
Why can't we detect the corrupted PDF immediately, the same way we do for images?
Also curious about this. It feels pretty weird to drop the user back at the contact selector when they acknowledge the warning. They don't need to pick a new contact, they need to upload a different file. So that feels pretty strange to me.
@dannymcclain @shawnborton, we can push the user to file selector page instead of participants selector but we can't detect the pdf immediately. For images we use react-native-image-size
package which works on all platforms but we don't have any package to detect corrupt pdf's. We first need to render it with different libraries for native and web and if the render fails we get the error. You can try uploading a protected pdf, you won't get any alert until you reach the confirmation page.
Hmm yeah, I'm a bit stumped so I would be curious for what our engineering team thinks.
I think the reality is, we haven't had a single customer ever report this corrupted PDF flow. This was a super edge case flow reported by our QA team. So I'm hesitant to spin the wheels too much here, given that I think this is not going to be any kind of mainline flow that we should optimize for.
If what you are proposing is the best we can do with our current limitations, I think it's probably our best bet.
@dannymcclain @shawnborton, we can push the user to file selector page instead of participants selector but we can't detect the pdf immediately. For images we use react-native-image-size package which works on all platforms but we don't have any package to detect corrupt pdf's. We first need to render it with different libraries for native and web and if the render fails we get the error. You can try uploading a protected pdf, you won't get any alert until you reach the confirmation page.
My knowledge of PDF flow is also very limited. But one question. We still display the corrupt PDF on the front end before uploading the PDF to the backend, right? If the file is corrupted, why the front end can display the file?
@hayata-suenaga, the library attempts to display the provided pdf, but when it fails, it throws an error and shows 'Failed to load pdf file' instead of the pdf on the frontend. Corrupt pdf isn't displayed on the frontend in any case, only the error message is shown. What I did is captured that thrown error and displayed the alert modal.
@jayeshmangwani, bump for review.
bumped them on Slack
@Krishna2323 Remove HOLD from the PR title and resolve the conflicts In local I am getting conflicts with the latest main branch
resolve the conflicts In local I am getting conflicts with the latest main branch
@Krishna2323 bump for this comment
resolve the conflicts
@jayeshmangwani, on it.
@jayeshmangwani, conflicts resolved.
Details
Fixed Issues
$ https://github.com/Expensify/App/issues/39356 PROPOSAL: https://github.com/Expensify/App/issues/39356#issuecomment-2029731489
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 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
https://github.com/Expensify/App/assets/85894871/a00a0769-6e56-4a9e-8fac-c7d8abbfd110Android: mWeb Chrome
https://github.com/Expensify/App/assets/85894871/a4dd89e3-4ec8-445e-a134-6174efbc771eiOS: Native
https://github.com/Expensify/App/assets/85894871/6207d5c5-20a6-4983-b358-918caaae763aiOS: mWeb Safari
https://github.com/Expensify/App/assets/85894871/d6ecb4f8-67e9-4055-9b56-2db83adeaaeaMacOS: Chrome / Safari
https://github.com/Expensify/App/assets/85894871/02c98eb5-a5c1-425d-a9a8-f52336f0ae4aMacOS: Desktop
https://github.com/Expensify/App/assets/85894871/320ace27-7210-4c8c-b4c0-a8f89a37d29e