Skip to content
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

Mark the tour task as complete on redirecting to Concierge after finishing the Navattic tour #54824

Merged
Changes from 2 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
21 changes: 19 additions & 2 deletions src/pages/ConciergePage.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {useFocusEffect} from '@react-navigation/native';
import {useFocusEffect, useRoute} from '@react-navigation/native';
import React, {useCallback, useEffect, useRef} from 'react';
import {View} from 'react-native';
import {useOnyx} from 'react-native-onyx';
Expand All @@ -10,6 +10,8 @@ import useThemeStyles from '@hooks/useThemeStyles';
import Navigation from '@libs/Navigation/Navigation';
import * as App from '@userActions/App';
import * as Report from '@userActions/Report';
import * as Task from '@userActions/Task';
import CONST from '@src/CONST';
import ONYXKEYS from '@src/ONYXKEYS';

/*
Expand All @@ -23,6 +25,11 @@ function ConciergePage() {
const {shouldUseNarrowLayout} = useResponsiveLayout();
const [session] = useOnyx(ONYXKEYS.SESSION);
const [isLoadingReportData] = useOnyx(ONYXKEYS.IS_LOADING_REPORT_DATA, {initialValue: true});
const route = useRoute();

const [introSelected] = useOnyx(ONYXKEYS.NVP_INTRO_SELECTED);
const viewTourTaskReportID = introSelected?.viewTour;
const [viewTourTaskReport] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT}${viewTourTaskReportID}`);

useFocusEffect(
useCallback(() => {
Expand All @@ -32,12 +39,22 @@ function ConciergePage() {
if (isUnmounted.current || isLoadingReportData === undefined || !!isLoadingReportData) {
return;
}

// Mark the viewTourTask as complete if we are redirected to Concierge after finishing the Navattic tour
const {navattic} = route.params as {navattic?: string};
if (navattic === 'completed') {
Copy link
Member

Choose a reason for hiding this comment

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

This caused a regression #55054

if (viewTourTaskReport) {
Copy link
Member

@rushatgabhane rushatgabhane Jan 7, 2025

Choose a reason for hiding this comment

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

NAB: put this in CONST

Copy link
Contributor

Choose a reason for hiding this comment

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

+1

if (viewTourTaskReport.stateNum !== CONST.REPORT.STATE_NUM.APPROVED || viewTourTaskReport.statusNum !== CONST.REPORT.STATUS_NUM.APPROVED) {
Task.completeTask(viewTourTaskReport);
}
}
}
Report.navigateToConciergeChat(true, () => !isUnmounted.current);
});
} else {
Navigation.navigate();
}
}, [session, isLoadingReportData]),
}, [session, isLoadingReportData, route.params, viewTourTaskReport]),
);

useEffect(() => {
Expand Down
Loading