Skip to content

Commit cdc21a8

Browse files
committed
Revert "Merge pull request #59008 from ishpaul777/revert-59004-revert-PR58666"
This reverts commit 4c4d5a5, reversing changes made to 721ef83.
1 parent eb4e249 commit cdc21a8

File tree

12 files changed

+63
-144
lines changed

12 files changed

+63
-144
lines changed

src/components/ProductTrainingContext/TOOLTIPS.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ type ShouldShowConditionProps = {
2222

2323
type TooltipData = {
2424
content: Array<{text: TranslationPaths; isBold: boolean}>;
25-
onHideTooltip: (isDismissedUsingCloseButton?: boolean) => void;
25+
onHideTooltip: () => void;
2626
name: ProductTrainingTooltipName;
2727
priority: number;
2828
shouldShow: (props: ShouldShowConditionProps) => boolean;
@@ -35,7 +35,7 @@ const TOOLTIPS: Record<ProductTrainingTooltipName, TooltipData> = {
3535
{text: 'productTrainingTooltip.conciergeLHNGBR.part1', isBold: false},
3636
{text: 'productTrainingTooltip.conciergeLHNGBR.part2', isBold: true},
3737
],
38-
onHideTooltip: (isDismissedUsingCloseButton = false) => dismissProductTraining(CONCEIRGE_LHN_GBR, isDismissedUsingCloseButton),
38+
onHideTooltip: () => dismissProductTraining(CONCEIRGE_LHN_GBR),
3939
name: CONCEIRGE_LHN_GBR,
4040
priority: 1300,
4141
// TODO: CONCEIRGE_LHN_GBR tooltip will be replaced by a tooltip in the #admins room
@@ -47,7 +47,7 @@ const TOOLTIPS: Record<ProductTrainingTooltipName, TooltipData> = {
4747
{text: 'productTrainingTooltip.saveSearchTooltip.part1', isBold: true},
4848
{text: 'productTrainingTooltip.saveSearchTooltip.part2', isBold: false},
4949
],
50-
onHideTooltip: (isDismissedUsingCloseButton = false) => dismissProductTraining(RENAME_SAVED_SEARCH, isDismissedUsingCloseButton),
50+
onHideTooltip: () => dismissProductTraining(RENAME_SAVED_SEARCH),
5151
name: RENAME_SAVED_SEARCH,
5252
priority: 1250,
5353
shouldShow: ({shouldUseNarrowLayout}) => !shouldUseNarrowLayout,
@@ -58,7 +58,7 @@ const TOOLTIPS: Record<ProductTrainingTooltipName, TooltipData> = {
5858
{text: 'productTrainingTooltip.globalCreateTooltip.part2', isBold: false},
5959
{text: 'productTrainingTooltip.globalCreateTooltip.part3', isBold: false},
6060
],
61-
onHideTooltip: (isDismissedUsingCloseButton = false) => dismissProductTraining(GLOBAL_CREATE_TOOLTIP, isDismissedUsingCloseButton),
61+
onHideTooltip: () => dismissProductTraining(GLOBAL_CREATE_TOOLTIP),
6262
name: GLOBAL_CREATE_TOOLTIP,
6363
priority: 1200,
6464
shouldShow: () => true,
@@ -69,7 +69,7 @@ const TOOLTIPS: Record<ProductTrainingTooltipName, TooltipData> = {
6969
{text: 'productTrainingTooltip.bottomNavInboxTooltip.part2', isBold: false},
7070
{text: 'productTrainingTooltip.bottomNavInboxTooltip.part3', isBold: false},
7171
],
72-
onHideTooltip: (isDismissedUsingCloseButton = false) => dismissProductTraining(BOTTOM_NAV_INBOX_TOOLTIP, isDismissedUsingCloseButton),
72+
onHideTooltip: () => dismissProductTraining(BOTTOM_NAV_INBOX_TOOLTIP),
7373
name: BOTTOM_NAV_INBOX_TOOLTIP,
7474
priority: 900,
7575
shouldShow: () => true,
@@ -80,7 +80,7 @@ const TOOLTIPS: Record<ProductTrainingTooltipName, TooltipData> = {
8080
{text: 'productTrainingTooltip.workspaceChatTooltip.part2', isBold: false},
8181
{text: 'productTrainingTooltip.workspaceChatTooltip.part3', isBold: false},
8282
],
83-
onHideTooltip: (isDismissedUsingCloseButton = false) => dismissProductTraining(LHN_WORKSPACE_CHAT_TOOLTIP, isDismissedUsingCloseButton),
83+
onHideTooltip: () => dismissProductTraining(LHN_WORKSPACE_CHAT_TOOLTIP),
8484
name: LHN_WORKSPACE_CHAT_TOOLTIP,
8585
priority: 800,
8686
shouldShow: () => true,
@@ -102,7 +102,7 @@ const TOOLTIPS: Record<ProductTrainingTooltipName, TooltipData> = {
102102
{text: 'productTrainingTooltip.scanTestTooltip.part4', isBold: true},
103103
{text: 'productTrainingTooltip.scanTestTooltip.part5', isBold: false},
104104
],
105-
onHideTooltip: (isDismissedUsingCloseButton = false) => dismissProductTraining(SCAN_TEST_TOOLTIP_MANAGER, isDismissedUsingCloseButton),
105+
onHideTooltip: () => dismissProductTraining(SCAN_TEST_TOOLTIP_MANAGER),
106106
name: SCAN_TEST_TOOLTIP_MANAGER,
107107
priority: 1000,
108108
shouldShow: () => true,
@@ -113,7 +113,7 @@ const TOOLTIPS: Record<ProductTrainingTooltipName, TooltipData> = {
113113
{text: 'productTrainingTooltip.scanTestTooltip.part7', isBold: true},
114114
{text: 'productTrainingTooltip.scanTestTooltip.part8', isBold: false},
115115
],
116-
onHideTooltip: (isDismissedUsingCloseButton = false) => dismissProductTraining(SCAN_TEST_CONFIRMATION, isDismissedUsingCloseButton),
116+
onHideTooltip: () => dismissProductTraining(SCAN_TEST_CONFIRMATION),
117117
name: SCAN_TEST_CONFIRMATION,
118118
priority: 1100,
119119
shouldShow: () => true,

src/components/ProductTrainingContext/index.tsx

Lines changed: 26 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import {useOnyx} from 'react-native-onyx';
44
import Button from '@components/Button';
55
import Icon from '@components/Icon';
66
import * as Expensicons from '@components/Icon/Expensicons';
7-
import PressableWithoutFeedback from '@components/Pressable/PressableWithoutFeedback';
87
import Text from '@components/Text';
98
import useLocalize from '@hooks/useLocalize';
109
import useResponsiveLayout from '@hooks/useResponsiveLayout';
@@ -13,8 +12,6 @@ import useTheme from '@hooks/useTheme';
1312
import useThemeStyles from '@hooks/useThemeStyles';
1413
import {parseFSAttributes} from '@libs/Fullstory';
1514
import {hasCompletedGuidedSetupFlowSelector} from '@libs/onboardingSelectors';
16-
import isProductTrainingElementDismissed from '@libs/TooltipUtils';
17-
import variables from '@styles/variables';
1815
import CONST from '@src/CONST';
1916
import ONYXKEYS from '@src/ONYXKEYS';
2017
import type ChildrenProps from '@src/types/utils/ChildrenProps';
@@ -101,7 +98,7 @@ function ProductTrainingContextProvider({children}: ChildrenProps) {
10198
return false;
10299
}
103100

104-
const isDismissed = isProductTrainingElementDismissed(tooltipName, dismissedProductTraining);
101+
const isDismissed = !!dismissedProductTraining?.[tooltipName];
105102

106103
if (isDismissed) {
107104
return false;
@@ -205,22 +202,6 @@ const useProductTrainingContext = (tooltipName: ProductTrainingTooltipName, shou
205202
*/
206203
useLayoutEffect(parseFSAttributes, []);
207204

208-
const shouldShowProductTrainingTooltip = useMemo(() => {
209-
return shouldShow && shouldRenderTooltip(tooltipName) && !shouldHideToolTip;
210-
}, [shouldRenderTooltip, tooltipName, shouldShow, shouldHideToolTip]);
211-
212-
const hideTooltip = useCallback(
213-
(isDismissedUsingCloseButton = false) => {
214-
if (!shouldShowProductTrainingTooltip) {
215-
return;
216-
}
217-
const tooltip = TOOLTIPS[tooltipName];
218-
tooltip.onHideTooltip(isDismissedUsingCloseButton);
219-
unregisterTooltip(tooltipName);
220-
},
221-
[tooltipName, shouldShowProductTrainingTooltip, unregisterTooltip],
222-
);
223-
224205
const renderProductTrainingTooltip = useCallback(() => {
225206
const tooltip = TOOLTIPS[tooltipName];
226207
return (
@@ -236,8 +217,7 @@ const useProductTrainingContext = (tooltipName: ProductTrainingTooltipName, shou
236217
styles.flexWrap,
237218
styles.textAlignCenter,
238219
styles.gap3,
239-
styles.pv2,
240-
styles.ph1,
220+
styles.p2,
241221
]}
242222
>
243223
<Icon
@@ -258,23 +238,6 @@ const useProductTrainingContext = (tooltipName: ProductTrainingTooltipName, shou
258238
);
259239
})}
260240
</Text>
261-
{!tooltip?.shouldRenderActionButtons && (
262-
<PressableWithoutFeedback
263-
onPress={() => {
264-
hideTooltip(true);
265-
}}
266-
shouldUseAutoHitSlop
267-
accessibilityLabel={translate('productTrainingTooltip.scanTestTooltip.noThanks')}
268-
role={CONST.ROLE.BUTTON}
269-
>
270-
<Icon
271-
src={Expensicons.Close}
272-
fill={theme.icon}
273-
width={variables.iconSizeSemiSmall}
274-
height={variables.iconSizeSemiSmall}
275-
/>
276-
</PressableWithoutFeedback>
277-
)}
278241
</View>
279242
{!!tooltip?.shouldRenderActionButtons && (
280243
<View style={[styles.alignItemsCenter, styles.justifyContentBetween, styles.flexRow, styles.ph2, styles.pv2, styles.gap2]}>
@@ -294,35 +257,42 @@ const useProductTrainingContext = (tooltipName: ProductTrainingTooltipName, shou
294257
</View>
295258
);
296259
}, [
297-
tooltipName,
260+
config.onConfirm,
261+
config.onDismiss,
298262
styles.alignItemsCenter,
263+
styles.flex1,
299264
styles.flexRow,
300-
styles.justifyContentStart,
301-
styles.justifyContentCenter,
302265
styles.flexWrap,
303-
styles.textAlignCenter,
304266
styles.gap3,
305-
styles.pv2,
306-
styles.ph1,
267+
styles.justifyContentBetween,
268+
styles.justifyContentCenter,
269+
styles.mw100,
270+
styles.p2,
307271
styles.productTrainingTooltipText,
272+
styles.pv2,
273+
styles.textAlignCenter,
274+
styles.textBold,
308275
styles.textWrap,
309-
styles.mw100,
310-
styles.flex1,
311-
styles.justifyContentBetween,
312-
styles.ph2,
313276
styles.gap2,
314-
styles.textBold,
277+
styles.justifyContentStart,
278+
styles.ph2,
315279
theme.tooltipHighlightText,
316-
theme.icon,
280+
tooltipName,
317281
translate,
318-
config.onConfirm,
319-
config.onDismiss,
320-
hideTooltip,
321282
]);
322283

284+
const shouldShowProductTrainingTooltip = useMemo(() => {
285+
return shouldShow && shouldRenderTooltip(tooltipName) && !shouldHideToolTip;
286+
}, [shouldRenderTooltip, tooltipName, shouldShow, shouldHideToolTip]);
287+
323288
const hideProductTrainingTooltip = useCallback(() => {
324-
hideTooltip(false);
325-
}, [hideTooltip]);
289+
if (!shouldShowProductTrainingTooltip) {
290+
return;
291+
}
292+
const tooltip = TOOLTIPS[tooltipName];
293+
tooltip.onHideTooltip();
294+
unregisterTooltip(tooltipName);
295+
}, [tooltipName, shouldShowProductTrainingTooltip, unregisterTooltip]);
326296

327297
return {
328298
renderProductTrainingTooltip,

src/hooks/useOnboardingFlow.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ import {startOnboardingFlow} from '@libs/actions/Welcome/OnboardingFlow';
66
import Navigation from '@libs/Navigation/Navigation';
77
import {hasCompletedGuidedSetupFlowSelector, tryNewDotOnyxSelector} from '@libs/onboardingSelectors';
88
import {buildCannedSearchQuery} from '@libs/SearchQueryUtils';
9-
import isProductTrainingElementDismissed from '@libs/TooltipUtils';
109
import CONFIG from '@src/CONFIG';
1110
import ONYXKEYS from '@src/ONYXKEYS';
1211
import ROUTES from '@src/ROUTES';
@@ -46,7 +45,8 @@ function useOnboardingFlowRouter() {
4645
if (CONFIG.IS_HYBRID_APP && isLoadingOnyxValue(isSingleNewDotEntryMetadata)) {
4746
return;
4847
}
49-
if (hasBeenAddedToNudgeMigration && !isProductTrainingElementDismissed('migratedUserWelcomeModal', dismissedProductTraining)) {
48+
49+
if (hasBeenAddedToNudgeMigration && !dismissedProductTraining?.migratedUserWelcomeModal) {
5050
const defaultCannedQuery = buildCannedSearchQuery();
5151
const query = defaultCannedQuery;
5252
Navigation.navigate(ROUTES.SEARCH_ROOT.getRoute({query}));
Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
type DismissProductTrainingParams = {
22
name: string;
3-
dismissedMethod: 'x' | 'click';
43
};
54

65
export default DismissProductTrainingParams;

src/libs/TooltipUtils.ts

Lines changed: 0 additions & 8 deletions
This file was deleted.

src/libs/actions/Report.ts

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5387,14 +5387,11 @@ function dismissChangePolicyModal() {
53875387
onyxMethod: Onyx.METHOD.MERGE,
53885388
key: ONYXKEYS.NVP_DISMISSED_PRODUCT_TRAINING,
53895389
value: {
5390-
[CONST.CHANGE_POLICY_TRAINING_MODAL]: {
5391-
timestamp: DateUtils.getDBTime(date.valueOf()),
5392-
dismissedMethod: 'click',
5393-
},
5390+
[CONST.CHANGE_POLICY_TRAINING_MODAL]: DateUtils.getDBTime(date.valueOf()),
53945391
},
53955392
},
53965393
];
5397-
API.write(WRITE_COMMANDS.DISMISS_PRODUCT_TRAINING, {name: CONST.CHANGE_POLICY_TRAINING_MODAL, dismissedMethod: 'click'}, {optimisticData});
5394+
API.write(WRITE_COMMANDS.DISMISS_PRODUCT_TRAINING, {name: CONST.CHANGE_POLICY_TRAINING_MODAL}, {optimisticData});
53985395
}
53995396

54005397
/**

src/libs/actions/Welcome/index.ts

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -207,22 +207,18 @@ function setSelfTourViewed(shouldUpdateOnyxDataOnlyLocally = false) {
207207
API.write(WRITE_COMMANDS.SELF_TOUR_VIEWED, null, {optimisticData});
208208
}
209209

210-
function dismissProductTraining(elementName: string, isDismissedUsingCloseButton = false) {
210+
function dismissProductTraining(elementName: string) {
211211
const date = new Date();
212-
const dismissedMethod = isDismissedUsingCloseButton ? 'x' : 'click';
213212
const optimisticData = [
214213
{
215214
onyxMethod: Onyx.METHOD.MERGE,
216215
key: ONYXKEYS.NVP_DISMISSED_PRODUCT_TRAINING,
217216
value: {
218-
[elementName]: {
219-
timestamp: DateUtils.getDBTime(date.valueOf()),
220-
dismissedMethod,
221-
},
217+
[elementName]: DateUtils.getDBTime(date.valueOf()),
222218
},
223219
},
224220
];
225-
API.write(WRITE_COMMANDS.DISMISS_PRODUCT_TRAINING, {name: elementName, dismissedMethod}, {optimisticData});
221+
API.write(WRITE_COMMANDS.DISMISS_PRODUCT_TRAINING, {name: elementName}, {optimisticData});
226222
}
227223

228224
export {

src/pages/iou/request/step/IOURequestStepScan/index.native.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -532,7 +532,7 @@ function IOURequestStepScan({
532532
{
533533
onConfirm: setTestReceiptAndNavigate,
534534
onDismiss: () => {
535-
dismissProductTraining(CONST.PRODUCT_TRAINING_TOOLTIP_NAMES.SCAN_TEST_TOOLTIP, true);
535+
dismissProductTraining(CONST.PRODUCT_TRAINING_TOOLTIP_NAMES.SCAN_TEST_TOOLTIP);
536536
},
537537
},
538538
);

src/pages/iou/request/step/IOURequestStepScan/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -590,7 +590,7 @@ function IOURequestStepScan({
590590
{
591591
onConfirm: setTestReceiptAndNavigate,
592592
onDismiss: () => {
593-
dismissProductTraining(CONST.PRODUCT_TRAINING_TOOLTIP_NAMES.SCAN_TEST_TOOLTIP, true);
593+
dismissProductTraining(CONST.PRODUCT_TRAINING_TOOLTIP_NAMES.SCAN_TEST_TOOLTIP);
594594
},
595595
},
596596
);

src/types/onyx/DismissedProductTraining.ts

Lines changed: 10 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -10,72 +10,61 @@ const {
1010
SCAN_TEST_TOOLTIP_MANAGER,
1111
SCAN_TEST_CONFIRMATION,
1212
} = CONST.PRODUCT_TRAINING_TOOLTIP_NAMES;
13-
14-
/**
15-
* This type is used to store the timestamp of when the user dismisses a product training ui elements.
16-
*/
17-
type DismissedProductTrainingElement = {
18-
/** The timestamp of when the user dismissed the product training element. */
19-
timestamp: string;
20-
21-
/** The method of how the user dismissed the product training element, click or x. */
22-
dismissedMethod: 'click' | 'x';
23-
};
2413
/**
2514
* This type is used to store the timestamp of when the user dismisses a product training ui elements.
2615
*/
2716
type DismissedProductTraining = {
2817
/**
2918
* When user dismisses the nudgeMigration Welcome Modal, we store the timestamp here.
3019
*/
31-
[CONST.MIGRATED_USER_WELCOME_MODAL]: DismissedProductTrainingElement;
20+
[CONST.MIGRATED_USER_WELCOME_MODAL]: string;
3221

3322
// TODO: CONCEIRGE_LHN_GBR tooltip will be replaced by a tooltip in the #admins room
3423
// https://github.com/Expensify/App/issues/57045#issuecomment-2701455668
3524
/**
3625
* When user dismisses the conciergeLHNGBR product training tooltip, we store the timestamp here.
3726
*/
38-
[CONCEIRGE_LHN_GBR]: DismissedProductTrainingElement;
27+
[CONCEIRGE_LHN_GBR]: string;
3928

4029
/**
4130
* When user dismisses the renameSavedSearch product training tooltip, we store the timestamp here.
4231
*/
43-
[RENAME_SAVED_SEARCH]: DismissedProductTrainingElement;
32+
[RENAME_SAVED_SEARCH]: string;
4433

4534
/**
4635
* When user dismisses the bottomNavInboxTooltip product training tooltip, we store the timestamp here.
4736
*/
48-
[BOTTOM_NAV_INBOX_TOOLTIP]: DismissedProductTrainingElement;
37+
[BOTTOM_NAV_INBOX_TOOLTIP]: string;
4938

5039
/**
5140
* When user dismisses the lhnWorkspaceChatTooltip product training tooltip, we store the timestamp here.
5241
*/
53-
[LHN_WORKSPACE_CHAT_TOOLTIP]: DismissedProductTrainingElement;
42+
[LHN_WORKSPACE_CHAT_TOOLTIP]: string;
5443

5544
/**
5645
* When user dismisses the globalCreateTooltip product training tooltip, we store the timestamp here.
5746
*/
58-
[GLOBAL_CREATE_TOOLTIP]: DismissedProductTrainingElement;
47+
[GLOBAL_CREATE_TOOLTIP]: string;
5948

6049
/**
6150
* When user dismisses the globalCreateTooltip product training tooltip, we store the timestamp here.
6251
*/
63-
[SCAN_TEST_TOOLTIP]: DismissedProductTrainingElement;
52+
[SCAN_TEST_TOOLTIP]: string;
6453

6554
/**
6655
* When user dismisses the test manager tooltip product training tooltip, we store the timestamp here.
6756
*/
68-
[SCAN_TEST_TOOLTIP_MANAGER]: DismissedProductTrainingElement;
57+
[SCAN_TEST_TOOLTIP_MANAGER]: string;
6958

7059
/**
7160
* When user dismisses the test manager on confirmantion page product training tooltip, we store the timestamp here.
7261
*/
73-
[SCAN_TEST_CONFIRMATION]: DismissedProductTrainingElement;
62+
[SCAN_TEST_CONFIRMATION]: string;
7463

7564
/**
7665
* When user dismisses the ChangeReportPolicy feature training modal, we store the timestamp here.
7766
*/
78-
[CONST.CHANGE_POLICY_TRAINING_MODAL]: DismissedProductTrainingElement;
67+
[CONST.CHANGE_POLICY_TRAINING_MODAL]: string;
7968
};
8069

8170
export default DismissedProductTraining;

0 commit comments

Comments
 (0)