Skip to content

Commit

Permalink
Merge pull request #48148 from daledah/fix/47331
Browse files Browse the repository at this point in the history
fix: prevent not here page open twice
  • Loading branch information
Beamanator authored Sep 9, 2024
2 parents 3a82afa + d3101ed commit 9fda38d
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 3 deletions.
23 changes: 21 additions & 2 deletions src/pages/ErrorPage/NotFoundPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,37 @@ import React from 'react';
import type {FullPageNotFoundViewProps} from '@components/BlockingViews/FullPageNotFoundView';
import FullPageNotFoundView from '@components/BlockingViews/FullPageNotFoundView';
import ScreenWrapper from '@components/ScreenWrapper';
import useWindowDimensions from '@hooks/useWindowDimensions';
import Navigation from '@libs/Navigation/Navigation';
import * as ReportUtils from '@libs/ReportUtils';

type NotFoundPageProps = {
onBackButtonPress?: () => void;
isReportRelatedPage?: boolean;
} & FullPageNotFoundViewProps;

// eslint-disable-next-line rulesdir/no-negated-variables
function NotFoundPage({onBackButtonPress, ...fullPageNotFoundViewProps}: NotFoundPageProps) {
function NotFoundPage({onBackButtonPress = () => Navigation.goBack(), isReportRelatedPage, ...fullPageNotFoundViewProps}: NotFoundPageProps) {
const {isSmallScreen} = useWindowDimensions();

Check failure on line 16 in src/pages/ErrorPage/NotFoundPage.tsx

View workflow job for this annotation

GitHub Actions / typecheck / typecheck

Property 'isSmallScreen' does not exist on type 'WindowDimensions'.

return (
<ScreenWrapper testID={NotFoundPage.displayName}>
<FullPageNotFoundView
shouldShow
onBackButtonPress={onBackButtonPress}
onBackButtonPress={() => {
if (!isReportRelatedPage || !isSmallScreen) {
onBackButtonPress();
return;
}
const topmostReportId = Navigation.getTopmostReportId();
const report = ReportUtils.getReport(topmostReportId ?? '');
// detect the report is invalid
if (topmostReportId && (!report || report.errorFields?.notFound)) {
Navigation.dismissModal();
return;
}
onBackButtonPress();
}}
// eslint-disable-next-line react/jsx-props-no-spreading
{...fullPageNotFoundViewProps}
/>
Expand Down
2 changes: 1 addition & 1 deletion src/pages/home/report/withReportOrNotFound.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ export default function (
}

if (shouldShowNotFoundPage) {
return <NotFoundPage />;
return <NotFoundPage isReportRelatedPage />;
}
}

Expand Down

0 comments on commit 9fda38d

Please sign in to comment.