-
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
[HOLD for payment 2024-06-06] [$250] Attachment - Blank preview when opened URL of deleted file #42438
Comments
Triggered auto assignment to @slafortune ( |
We think this issue might be related to the #vip-vsb. |
ProposalPlease re-state the problem that we are trying to solve in this issue.Blank preview when opened URL of deleted file What is the root cause of that problem?The In and then we send this source to What changes do you think we should make in order to solve the problem?We need to check if the source is a valid file and exists, we can use a combination of URL validation and an HTTP request to verify its existence. Here's how you can achieve this in your React Native web app:
Here's a code snippet that demonstrates these solution: function ReportAttachments({route}: ReportAttachmentsProps) {
const reportID = route.params.reportID;
const report = ReportUtils.getReport(reportID);
const [source, setSource] = useState<string | number | null>(null);
const [isValidSource, setIsValidSource] = useState(false);
useEffect(() => {
// eslint-disable-next-line @lwc/lwc/no-async-await
const validateAndCheckSource = async () => {
const sourceToCheck = Number(route.params.source) || route.params.source;
console.log('source: ', sourceToCheck);
if (typeof sourceToCheck === 'string') {
try {
const response = await fetch(sourceToCheck, {method: 'HEAD'});
if (response.ok) {
setSource(sourceToCheck);
setIsValidSource(true);
} else {
console.error('File does not exist at the given source.');
setIsValidSource(false);
}
} catch (error) {
console.error('Error fetching the source:', error);
setIsValidSource(false);
}
} else {
// Assuming native image source is valid
setSource(sourceToCheck);
setIsValidSource(true);
}
};
validateAndCheckSource();
}, [route.params.source]);
const onCarouselAttachmentChange = useCallback(
(attachment: Attachment) => {
const routeToNavigate = ROUTES.REPORT_ATTACHMENTS.getRoute(reportID, String(attachment.source));
Navigation.navigate(routeToNavigate);
},
[reportID],
);
return (
<AttachmentModal
allowDownload
defaultOpen
report={report}
source={source}
shouldShowNotFoundPage={!isValidSource}
onModalHide={() => {
Navigation.dismissModal();
// This enables Composer refocus when the attachments modal is closed by the browser navigation
ComposerFocusManager.setReadyToFocus();
}}
onCarouselAttachmentChange={onCarouselAttachmentChange}
/>
);
}
ReportAttachments.displayName = 'ReportAttachments';
export default ReportAttachments; Explanation:
This approach ensures that your app checks the validity and existence of the file before attempting to use it. POC Video:20240521_180905.mp4 |
ProposalPlease re-state the problem that we are trying to solve in this issue.The attachment carosel shows blank when opening a deleted attachment. What is the root cause of that problem?This issue only happens when we do it on a chat that doesn't have any attachment. The not found will show if the App/src/components/Attachments/AttachmentCarousel/index.tsx Lines 167 to 168 in e8ae3c5
The initial value of
and we initialize it inside this App/src/components/Attachments/AttachmentCarousel/index.tsx Lines 49 to 64 in e8ae3c5
However, it won't reach that code because What changes do you think we should make in order to solve the problem?If both One way to do it is to check the array inside this if App/src/components/Attachments/AttachmentCarousel/index.tsx Lines 53 to 55 in e8ae3c5
If the we can check whether the page is already -1 or not before setting the page state too |
Job added to Upwork: https://www.upwork.com/jobs/~01aefa25ba0c7aa996 |
Triggered auto assignment to Contributor-plus team member for initial proposal review - @s77rt ( |
I'll be on vacation until June 4th so adding another BZ, I'll take this back on the 4th. |
Triggered auto assignment to @MitchExpensify ( |
@dragnoir Thanks for the proposal. Your RCA is not correct. In |
@bernhardoj Thanks for the proposal. Your RCA is correct. The solution looks good to me 👍. 🎀 👀 🎀 C+ reviewed |
Triggered auto assignment to @bondydaa, see https://stackoverflow.com/c/expensify/questions/7972 for more details. |
@bondydaa, @slafortune, @s77rt, @MitchExpensify Whoops! This issue is 2 days overdue. Let's get this updated quick! |
Waiting on engineer review #42438 (comment) |
📣 @s77rt 🎉 An offer has been automatically sent to your Upwork account for the Reviewer role 🎉 Thanks for contributing to the Expensify app! |
📣 @bernhardoj 🎉 An offer has been automatically sent to your Upwork account for the Contributor role 🎉 Thanks for contributing to the Expensify app! Offer link |
PR is ready cc: @s77rt |
|
The solution for this issue has been 🚀 deployed to production 🚀 in version 1.4.77-11 and is now subject to a 7-day regression period 📆. Here is the list of pull requests that resolve this issue: If no regressions arise, payment will be issued on 2024-06-06. 🎊 For reference, here are some details about the assignees on this issue:
|
BugZero Checklist: The PR fixing this issue has been merged! The following checklist (instructions) will need to be completed before the issue can be closed:
|
|
Thanks @MitchExpensify I'll take this back now - vacation is O V E R |
@s77rt requires Paid ✅ |
If you haven’t already, check out our contributing guidelines for onboarding and email [email protected] to request to join our Slack channel!
Version Number: v1.4.74-4
Reproducible in staging?: Y
Reproducible in production?: Y
If this was caught during regression testing, add the test name, ID and link from TestRail: https://github.com/Expensify/Expensify/issues/313988
Logs: https://stackoverflow.com/c/expensify/questions/4856
Issue reported by: Applause-Internal team
Action Performed:
Precondition: use two Gmail accounts or 1 Gmail and 1 Expensifail,
Expected Result:
The app displays 'Hmm its not here' page.
Actual Result:
The app displays blank page.
Workaround:
Unknown
Platforms:
Which of our officially supported platforms is this issue occurring on?
Screenshots/Videos
Bug6486224_1716210045654.attachment_preview_URL.mp4
View all open jobs on GitHub
Upwork Automation - Do Not Edit
Issue Owner
Current Issue Owner: @slafortune / @MitchExpensifyThe text was updated successfully, but these errors were encountered: