Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 6 additions & 16 deletions src/DeepLinkHandler.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,16 +28,16 @@ function DeepLinkHandler({onInitialUrl}: DeepLinkHandlerProps) {
const linkingChangeListener = useRef<NativeEventSubscription | null>(null);
const initialUrlProcessed = useRef(false);

const [allReports, allReportsMetadata] = useOnyx(ONYXKEYS.COLLECTION.REPORT);
const [allReports] = useOnyx(ONYXKEYS.COLLECTION.REPORT);
const [, sessionMetadata] = useOnyx(ONYXKEYS.SESSION);
const [conciergeReportID, conciergeReportIDMetadata] = useOnyx(ONYXKEYS.CONCIERGE_REPORT_ID);
const [introSelected, introSelectedMetadata] = useOnyx(ONYXKEYS.NVP_INTRO_SELECTED);
const [conciergeReportID] = useOnyx(ONYXKEYS.CONCIERGE_REPORT_ID);
const [introSelected] = useOnyx(ONYXKEYS.NVP_INTRO_SELECTED);
const [isSelfTourViewed, isSelfTourViewedMetadata] = useOnyx(ONYXKEYS.NVP_ONBOARDING, {selector: hasSeenTourSelector});
const [betas, betasMetadata] = useOnyx(ONYXKEYS.BETAS);
const [betas] = useOnyx(ONYXKEYS.BETAS);
const isAuthenticated = useIsAuthenticated();

useEffect(() => {
if (isLoadingOnyxValue(allReportsMetadata, sessionMetadata, conciergeReportIDMetadata, introSelectedMetadata, isSelfTourViewedMetadata, betasMetadata)) {
if (isLoadingOnyxValue(sessionMetadata, isSelfTourViewedMetadata)) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Wait for dependent Onyx keys before reading initial URL

On a cold start from a deep link where SESSION/onboarding finish loading before CONCIERGE_REPORT_ID, NVP_INTRO_SELECTED, BETAS, or the reports collection, this effect now proceeds with those values still undefined. When any of those values loads, the dependency array below changes and the effect calls Linking.getInitialURL() again; initialUrlProcessed does not prevent re-processing, so the same URL is passed to openReportFromDeepLink() twice. For anonymous public-room links this can issue duplicate OpenReport requests and repeat navigation/onboarding side effects; the effect should either keep waiting for the metadata it consumes or skip initial URL handling once it has already completed.

Useful? React with 👍 / 👎.

return;
}

Expand Down Expand Up @@ -111,17 +111,7 @@ function DeepLinkHandler({onInitialUrl}: DeepLinkHandlerProps) {
linkingChangeListener.current?.remove();
};
// eslint-disable-next-line react-hooks/exhaustive-deps -- intentionally excluding allReports, isAuthenticated, and onInitialUrl to avoid re-triggering deep link handling on every report update
}, [
conciergeReportID,
introSelected,
betas,
allReportsMetadata.status,
sessionMetadata.status,
conciergeReportIDMetadata.status,
introSelectedMetadata.status,
isSelfTourViewedMetadata.status,
betasMetadata.status,
]);
}, [sessionMetadata?.status, conciergeReportID, introSelected, isSelfTourViewedMetadata, betas]);

// Safety net: if getInitialURL() resolves before the session loads, hasAuthToken() may return false
// for an authenticated user, causing openReportFromDeepLink to take the wrong path. Once isAuthenticated
Expand Down
Loading