Skip to content
Merged
Show file tree
Hide file tree
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
4 changes: 1 addition & 3 deletions src/components/TestDrive/TestDriveDemo.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,12 @@ function TestDriveDemo() {
const [onboarding] = useOnyx(ONYXKEYS.NVP_ONBOARDING, {canBeMissing: false});
const [onboardingReport] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT}${onboarding?.chatReportID}`, {canBeMissing: true});
const [introSelected] = useOnyx(ONYXKEYS.NVP_INTRO_SELECTED, {canBeMissing: true});
const viewTourReportID = introSelected?.viewTour;
const [viewTourReport] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT}${viewTourReportID}`, {canBeMissing: true});
const {testDrive} = useOnboardingMessages();

useEffect(() => {
InteractionManager.runAfterInteractions(() => {
setIsVisible(true);
completeTestDriveTask(viewTourReport, viewTourReportID);
completeTestDriveTask();
});

// This should fire only during mount.
Expand Down
4 changes: 2 additions & 2 deletions src/libs/actions/Task.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
let currentUserEmail = '';
let currentUserAccountID = -1;

Onyx.connect({

Check warning on line 48 in src/libs/actions/Task.ts

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

Onyx.connect() is deprecated. Use useOnyx() hook instead and pass the data as parameters to a pure function
key: ONYXKEYS.SESSION,
callback: (value) => {
currentUserEmail = value?.email ?? '';
Expand All @@ -54,13 +54,13 @@
});

let allPersonalDetails: OnyxEntry<OnyxTypes.PersonalDetailsList>;
Onyx.connect({

Check warning on line 57 in src/libs/actions/Task.ts

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

Onyx.connect() is deprecated. Use useOnyx() hook instead and pass the data as parameters to a pure function
key: ONYXKEYS.PERSONAL_DETAILS_LIST,
callback: (value) => (allPersonalDetails = value),
});

let quickAction: OnyxEntry<OnyxTypes.QuickAction> = {};
Onyx.connect({

Check warning on line 63 in src/libs/actions/Task.ts

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

Onyx.connect() is deprecated. Use useOnyx() hook instead and pass the data as parameters to a pure function
key: ONYXKEYS.NVP_QUICK_ACTION_GLOBAL_CREATE,
callback: (value) => {
quickAction = value;
Expand All @@ -68,7 +68,7 @@
});

let allReportActions: OnyxCollection<ReportActions>;
Onyx.connect({

Check warning on line 71 in src/libs/actions/Task.ts

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

Onyx.connect() is deprecated. Use useOnyx() hook instead and pass the data as parameters to a pure function
key: ONYXKEYS.COLLECTION.REPORT_ACTIONS,
waitForCollectionCallback: true,
callback: (actions) => {
Expand All @@ -81,7 +81,7 @@
});

let allReports: OnyxCollection<OnyxTypes.Report>;
Onyx.connect({

Check warning on line 84 in src/libs/actions/Task.ts

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

Onyx.connect() is deprecated. Use useOnyx() hook instead and pass the data as parameters to a pure function
key: ONYXKEYS.COLLECTION.REPORT,
waitForCollectionCallback: true,
callback: (value) => {
Expand All @@ -90,13 +90,13 @@
});

let introSelected: OnyxEntry<OnyxTypes.IntroSelected> = {};
Onyx.connect({

Check warning on line 93 in src/libs/actions/Task.ts

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

Onyx.connect() is deprecated. Use useOnyx() hook instead and pass the data as parameters to a pure function
key: ONYXKEYS.NVP_INTRO_SELECTED,
callback: (val) => (introSelected = val),
});

let allReportNameValuePair: OnyxCollection<OnyxTypes.ReportNameValuePairs>;
Onyx.connect({

Check warning on line 99 in src/libs/actions/Task.ts

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

Onyx.connect() is deprecated. Use useOnyx() hook instead and pass the data as parameters to a pure function
key: ONYXKEYS.COLLECTION.REPORT_NAME_VALUE_PAIRS,
waitForCollectionCallback: true,
callback: (value) => {
Expand Down Expand Up @@ -1324,9 +1324,9 @@

return {};
}
function completeTestDriveTask(viewTourReport: OnyxEntry<OnyxTypes.Report>, viewTourReportID: string | undefined, shouldUpdateSelfTourViewedOnlyLocally = false) {
function completeTestDriveTask(shouldUpdateSelfTourViewedOnlyLocally = false) {
setSelfTourViewed(shouldUpdateSelfTourViewedOnlyLocally);
completeTask(viewTourReport, viewTourReportID);
getFinishOnboardingTaskOnyxData(CONST.ONBOARDING_TASK_TYPE.VIEW_TOUR);
}

export {
Expand Down
6 changes: 1 addition & 5 deletions src/pages/Search/EmptySearchView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -163,8 +163,6 @@ function EmptySearchView({hash, type, groupBy, hasResults}: EmptySearchViewProps
selector: hasSeenTourSelector,
canBeMissing: true,
});
const viewTourReportID = introSelected?.viewTour;
const [viewTourReport] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT}${viewTourReportID}`, {canBeMissing: true});

// Default 'Folder' lottie animation, along with its background styles
const defaultViewItemHeader = useMemo(
Expand Down Expand Up @@ -204,7 +202,7 @@ function EmptySearchView({hash, type, groupBy, hasResults}: EmptySearchViewProps
introSelected?.choice === CONST.ONBOARDING_CHOICES.TRACK_WORKSPACE ||
(introSelected?.choice === CONST.ONBOARDING_CHOICES.SUBMIT && introSelected.inviteType === CONST.ONBOARDING_INVITE_TYPES.WORKSPACE)
) {
completeTestDriveTask(viewTourReport, viewTourReportID);
completeTestDriveTask();
Navigation.navigate(ROUTES.TEST_DRIVE_DEMO_ROOT);
} else {
Navigation.navigate(ROUTES.TEST_DRIVE_MODAL_ROOT.route);
Expand Down Expand Up @@ -382,8 +380,6 @@ function EmptySearchView({hash, type, groupBy, hasResults}: EmptySearchViewProps
currentUserPersonalDetails,
tripViewChildren,
shouldRedirectToExpensifyClassic,
viewTourReport,
viewTourReportID,
transactions,
]);

Expand Down
4 changes: 1 addition & 3 deletions src/pages/home/sidebar/FloatingActionButtonAndPopover.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -135,8 +135,6 @@ function FloatingActionButtonAndPopover({onHideCreateMenu, onShowCreateMenu, isT
selector: hasSeenTourSelector,
canBeMissing: true,
});
const viewTourReportID = introSelected?.viewTour;
const [viewTourReport] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT}${viewTourReportID}`, {canBeMissing: true});

const groupPoliciesWithChatEnabled = getGroupPaidPoliciesWithExpenseChatEnabled();

Expand Down Expand Up @@ -537,7 +535,7 @@ function FloatingActionButtonAndPopover({onHideCreateMenu, onShowCreateMenu, isT
introSelected?.choice === CONST.ONBOARDING_CHOICES.TRACK_WORKSPACE ||
(introSelected?.choice === CONST.ONBOARDING_CHOICES.SUBMIT && introSelected.inviteType === CONST.ONBOARDING_INVITE_TYPES.WORKSPACE)
) {
completeTestDriveTask(viewTourReport, viewTourReportID, isAnonymousUser());
completeTestDriveTask(isAnonymousUser());
Navigation.navigate(ROUTES.TEST_DRIVE_DEMO_ROOT);
} else {
Navigation.navigate(ROUTES.TEST_DRIVE_MODAL_ROOT.route);
Expand Down
8 changes: 1 addition & 7 deletions src/pages/iou/request/step/IOURequestStepConfirmation.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -189,10 +189,6 @@ function IOURequestStepConfirmation({
const [isConfirmed, setIsConfirmed] = useState(false);
const [isConfirming, setIsConfirming] = useState(false);

const [introSelected] = useOnyx(ONYXKEYS.NVP_INTRO_SELECTED, {canBeMissing: true});
const viewTourReportID = introSelected?.viewTour;
const [viewTourReport] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT}${viewTourReportID}`, {canBeMissing: true});

const headerTitle = useMemo(() => {
if (isCategorizingTrackExpense) {
return translate('iou.categorize');
Expand Down Expand Up @@ -453,7 +449,7 @@ function IOURequestStepConfirmation({
const isTestDriveReceipt = receipt?.isTestDriveReceipt ?? false;

if (isTestDriveReceipt) {
completeTestDriveTask(viewTourReport, viewTourReportID);
completeTestDriveTask();
}

requestMoneyIOUActions({
Expand Down Expand Up @@ -515,8 +511,6 @@ function IOURequestStepConfirmation({
transactionTaxAmount,
customUnitRateID,
backToReport,
viewTourReport,
viewTourReportID,
],
);

Expand Down
9 changes: 2 additions & 7 deletions tests/actions/TaskTest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ import useParentReport from '@hooks/useParentReport';
import useReportIsArchived from '@hooks/useReportIsArchived';
import {canActionTask, canModifyTask, completeTestDriveTask, getFinishOnboardingTaskOnyxData} from '@libs/actions/Task';
// eslint-disable-next-line no-restricted-syntax -- this is required to allow mocking
import * as API from '@libs/API';
import {WRITE_COMMANDS} from '@libs/API/types';
import DateUtils from '@libs/DateUtils';
import {translateLocal} from '@libs/Localize';
import Parser from '@libs/Parser';
Expand Down Expand Up @@ -223,11 +221,8 @@ describe('actions/Task', () => {
});

it('Completes test drive task', () => {
const writeSpy = jest.spyOn(API, 'write');

completeTestDriveTask(testDriveTaskReport, testDriveTaskReport.reportID);

expect(writeSpy).toHaveBeenCalledWith(WRITE_COMMANDS.COMPLETE_TASK, expect.anything(), expect.anything());
completeTestDriveTask();
expect(Object.values(getFinishOnboardingTaskOnyxData(CONST.ONBOARDING_TASK_TYPE.VIEW_TOUR)).length).toBe(0);
});
});

Expand Down
Loading