Skip to content

Commit

Permalink
Merge pull request #52617 from c3024/remove-tour-link-after-viewed-fr…
Browse files Browse the repository at this point in the history
…om-anywhere

Remove links to the tour after it has been viewed from anywhere
  • Loading branch information
lakchote authored Nov 21, 2024
2 parents 72034f2 + c583583 commit 8c8f8e3
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 2 deletions.
26 changes: 24 additions & 2 deletions src/pages/Search/EmptySearchView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,16 @@ import useStyleUtils from '@hooks/useStyleUtils';
import useTheme from '@hooks/useTheme';
import useThemeStyles from '@hooks/useThemeStyles';
import interceptAnonymousUser from '@libs/interceptAnonymousUser';
import {hasSeenTourSelector} from '@libs/onboardingSelectors';
import * as PolicyUtils from '@libs/PolicyUtils';
import * as ReportUtils from '@libs/ReportUtils';
import {getNavatticURL} from '@libs/TourUtils';
import * as TripsResevationUtils from '@libs/TripReservationUtils';
import variables from '@styles/variables';
import * as IOU from '@userActions/IOU';
import * as Link from '@userActions/Link';
import * as Task from '@userActions/Task';
import * as Welcome from '@userActions/Welcome';
import CONST from '@src/CONST';
import ONYXKEYS from '@src/ONYXKEYS';
import type * as OnyxTypes from '@src/types/onyx';
Expand Down Expand Up @@ -103,9 +106,15 @@ function EmptySearchView({type}: EmptySearchViewProps) {
);
}, [styles, translate, ctaErrorMessage]);

const [onboardingPurpose] = useOnyx(ONYXKEYS.NVP_INTRO_SELECTED, {selector: (introSelected) => introSelected?.choice});
const [introSelected] = useOnyx(ONYXKEYS.NVP_INTRO_SELECTED);
const onboardingPurpose = introSelected?.choice;
const {environment} = useEnvironment();
const navatticURL = getNavatticURL(environment, onboardingPurpose);
const [hasSeenTour = false] = useOnyx(ONYXKEYS.NVP_ONBOARDING, {
selector: hasSeenTourSelector,
});
const viewTourTaskReportID = introSelected?.viewTour;
const [viewTourTaskReport] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT}${viewTourTaskReportID}`);

const content = useMemo(() => {
switch (type) {
Expand All @@ -132,7 +141,18 @@ function EmptySearchView({type}: EmptySearchViewProps) {
title: translate('search.searchResults.emptyExpenseResults.title'),
subtitle: translate('search.searchResults.emptyExpenseResults.subtitle'),
buttons: [
{buttonText: translate('emptySearchView.takeATour'), buttonAction: () => Link.openExternalLink(navatticURL)},
...(!hasSeenTour
? [
{
buttonText: translate('emptySearchView.takeATour'),
buttonAction: () => {
Link.openExternalLink(navatticURL);
Welcome.setSelfTourViewed();
Task.completeTask(viewTourTaskReport);
},
},
]
: []),
{
buttonText: translate('iou.createExpense'),
buttonAction: () =>
Expand Down Expand Up @@ -171,6 +191,8 @@ function EmptySearchView({type}: EmptySearchViewProps) {
ctaErrorMessage,
navatticURL,
shouldRedirectToExpensifyClassic,
hasSeenTour,
viewTourTaskReport,
]);

return (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -501,6 +501,9 @@ function FloatingActionButtonAndPopover({onHideCreateMenu, onShowCreateMenu}: Fl
isValidReport,
]);

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

return (
<View style={styles.flexGrow1}>
<PopoverMenu
Expand Down Expand Up @@ -559,6 +562,7 @@ function FloatingActionButtonAndPopover({onHideCreateMenu, onShowCreateMenu}: Fl
onSelected: () => {
Welcome.setSelfTourViewed();
Link.openExternalLink(navatticURL);
Task.completeTask(viewTourTaskReport);
},
},
]
Expand Down
3 changes: 3 additions & 0 deletions src/types/onyx/IntroSelected.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ type IntroSelected = {

/** Whether the onboarding is complete */
isInviteOnboardingComplete?: boolean;

/** Task reportID for 'viewTour' type */
viewTour?: string;
};

export default IntroSelected;

0 comments on commit 8c8f8e3

Please sign in to comment.