From 33253ab22da7334dffdf1a1b3262d643deef377a Mon Sep 17 00:00:00 2001 From: Francois Laithier Date: Thu, 30 May 2024 13:30:10 -0700 Subject: [PATCH 1/3] Remove `CompleteEngagementModal` API command call --- .../CompleteEngagementModalParams.ts | 10 -- src/libs/API/parameters/index.ts | 1 - src/libs/API/types.ts | 2 - src/libs/actions/Report.ts | 103 ------------------ 4 files changed, 116 deletions(-) delete mode 100644 src/libs/API/parameters/CompleteEngagementModalParams.ts diff --git a/src/libs/API/parameters/CompleteEngagementModalParams.ts b/src/libs/API/parameters/CompleteEngagementModalParams.ts deleted file mode 100644 index cffbc0a5ba66..000000000000 --- a/src/libs/API/parameters/CompleteEngagementModalParams.ts +++ /dev/null @@ -1,10 +0,0 @@ -type CompleteEngagementModalParams = { - reportID: string; - reportActionID?: string; - commentReportActionID?: string | null; - reportComment?: string; - engagementChoice: string; - timezone?: string; -}; - -export default CompleteEngagementModalParams; diff --git a/src/libs/API/parameters/index.ts b/src/libs/API/parameters/index.ts index c9e2e342c5ae..68097a201120 100644 --- a/src/libs/API/parameters/index.ts +++ b/src/libs/API/parameters/index.ts @@ -136,7 +136,6 @@ export type {default as EditTaskAssigneeParams} from './EditTaskAssigneeParams'; export type {default as EditTaskParams} from './EditTaskParams'; export type {default as ReopenTaskParams} from './ReopenTaskParams'; export type {default as CompleteTaskParams} from './CompleteTaskParams'; -export type {default as CompleteEngagementModalParams} from './CompleteEngagementModalParams'; export type {default as SetNameValuePairParams} from './SetNameValuePairParams'; export type {default as SetReportFieldParams} from './SetReportFieldParams'; export type {default as SetReportNameParams} from './SetReportNameParams'; diff --git a/src/libs/API/types.ts b/src/libs/API/types.ts index 40deec85bc47..897b300f0471 100644 --- a/src/libs/API/types.ts +++ b/src/libs/API/types.ts @@ -142,7 +142,6 @@ const WRITE_COMMANDS = { EDIT_TASK: 'EditTask', REOPEN_TASK: 'ReopenTask', COMPLETE_TASK: 'CompleteTask', - COMPLETE_ENGAGEMENT_MODAL: 'CompleteEngagementModal', COMPLETE_GUIDED_SETUP: 'CompleteGuidedSetup', SET_NAME_VALUE_PAIR: 'SetNameValuePair', SET_REPORT_FIELD: 'Report_SetFields', @@ -351,7 +350,6 @@ type WriteCommandParameters = { [WRITE_COMMANDS.EDIT_TASK]: Parameters.EditTaskParams; [WRITE_COMMANDS.REOPEN_TASK]: Parameters.ReopenTaskParams; [WRITE_COMMANDS.COMPLETE_TASK]: Parameters.CompleteTaskParams; - [WRITE_COMMANDS.COMPLETE_ENGAGEMENT_MODAL]: Parameters.CompleteEngagementModalParams; [WRITE_COMMANDS.COMPLETE_GUIDED_SETUP]: Parameters.CompleteGuidedSetupParams; [WRITE_COMMANDS.SET_NAME_VALUE_PAIR]: Parameters.SetNameValuePairParams; [WRITE_COMMANDS.SET_REPORT_FIELD]: Parameters.SetReportFieldParams; diff --git a/src/libs/actions/Report.ts b/src/libs/actions/Report.ts index 88c33c9d98ad..64e2ac9f1c36 100644 --- a/src/libs/actions/Report.ts +++ b/src/libs/actions/Report.ts @@ -14,7 +14,6 @@ import type { AddCommentOrAttachementParams, AddEmojiReactionParams, AddWorkspaceRoomParams, - CompleteEngagementModalParams, CompleteGuidedSetupParams, DeleteCommentParams, ExpandURLPreviewParams, @@ -3414,107 +3413,6 @@ function completeOnboarding( API.write(WRITE_COMMANDS.COMPLETE_GUIDED_SETUP, parameters, {optimisticData, successData, failureData}); } -/** - * Completes the engagement modal that new NewDot users see when they first sign up/log in by doing the following: - * - * - Sets the introSelected NVP to the choice the user made - * - Creates an optimistic report comment from concierge - */ -function completeEngagementModal(choice: OnboardingPurposeType, text?: string) { - const conciergeAccountID = PersonalDetailsUtils.getAccountIDsByLogins([CONST.EMAIL.CONCIERGE])[0]; - - // We do not need to send any message for some choices - if (!text) { - const parameters: CompleteEngagementModalParams = { - reportID: conciergeChatReportID ?? '', - engagementChoice: choice, - }; - - const optimisticData: OnyxUpdate[] = [ - { - onyxMethod: Onyx.METHOD.MERGE, - key: ONYXKEYS.NVP_INTRO_SELECTED, - value: {choice}, - }, - ]; - API.write(WRITE_COMMANDS.COMPLETE_ENGAGEMENT_MODAL, parameters, { - optimisticData, - }); - return; - } - - const reportComment = ReportUtils.buildOptimisticAddCommentReportAction(text, undefined, conciergeAccountID); - const reportCommentAction: OptimisticAddCommentReportAction = reportComment.reportAction; - const lastComment = reportCommentAction?.message?.[0]; - const lastCommentText = ReportUtils.formatReportLastMessageText(lastComment?.text ?? ''); - const reportCommentText = reportComment.commentText; - const currentTime = DateUtils.getDBTime(); - - const optimisticReport: Partial = { - lastVisibleActionCreated: currentTime, - lastMessageTranslationKey: lastComment?.translationKey ?? '', - lastMessageText: lastCommentText, - lastMessageHtml: lastCommentText, - lastActorAccountID: currentUserAccountID, - lastReadTime: currentTime, - }; - - const conciergeChatReport = ReportUtils.getChatByParticipants([conciergeAccountID, currentUserAccountID]); - conciergeChatReportID = conciergeChatReport?.reportID; - - const report = ReportUtils.getReport(conciergeChatReportID); - - if (!isEmptyObject(report) && ReportUtils.getReportNotificationPreference(report) === CONST.REPORT.NOTIFICATION_PREFERENCE.HIDDEN) { - optimisticReport.notificationPreference = CONST.REPORT.NOTIFICATION_PREFERENCE.ALWAYS; - } - - // Optimistically add the new actions to the store before waiting to save them to the server - const optimisticReportActions: OnyxCollection = {}; - if (reportCommentAction?.reportActionID) { - optimisticReportActions[reportCommentAction.reportActionID] = reportCommentAction; - } - - const parameters: CompleteEngagementModalParams = { - reportID: conciergeChatReportID ?? '', - reportActionID: reportCommentAction.reportActionID, - reportComment: reportCommentText, - engagementChoice: choice, - }; - - const optimisticData: OnyxUpdate[] = [ - { - onyxMethod: Onyx.METHOD.MERGE, - key: `${ONYXKEYS.COLLECTION.REPORT}${conciergeChatReportID}`, - value: optimisticReport, - }, - { - onyxMethod: Onyx.METHOD.MERGE, - key: `${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${conciergeChatReportID}`, - value: optimisticReportActions as ReportActions, - }, - { - onyxMethod: Onyx.METHOD.MERGE, - key: ONYXKEYS.NVP_INTRO_SELECTED, - value: {choice}, - }, - ]; - - const successData: OnyxUpdate[] = [ - { - onyxMethod: Onyx.METHOD.MERGE, - key: `${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${conciergeChatReportID}`, - value: {[reportCommentAction.reportActionID ?? '']: {pendingAction: null}}, - }, - ]; - - // eslint-disable-next-line rulesdir/no-multiple-api-calls - API.write(WRITE_COMMANDS.COMPLETE_ENGAGEMENT_MODAL, parameters, { - optimisticData, - successData, - }); - notifyNewAction(conciergeChatReportID ?? '', reportCommentAction.actorAccountID, reportCommentAction.reportActionID); -} - function dismissEngagementModal() { const parameters: SetNameValuePairParams = { name: ONYXKEYS.NVP_HAS_DISMISSED_IDLE_PANEL, @@ -3844,7 +3742,6 @@ export { hasErrorInPrivateNotes, getOlderActions, getNewerActions, - completeEngagementModal, dismissEngagementModal, openRoomMembersPage, savePrivateNotesDraft, From 5e18a777f4dba2b23b7d39d2b59b2b1f3faec4d5 Mon Sep 17 00:00:00 2001 From: Francois Laithier Date: Thu, 30 May 2024 14:42:17 -0700 Subject: [PATCH 2/3] Remove `hasDismissedModal` logic --- src/ONYXKEYS.ts | 4 ---- src/libs/actions/Report.ts | 20 -------------------- src/libs/actions/Welcome.ts | 13 +------------ src/libs/migrations/NVPMigration.ts | 1 - 4 files changed, 1 insertion(+), 37 deletions(-) diff --git a/src/ONYXKEYS.ts b/src/ONYXKEYS.ts index a027a8493b41..6c29fa7fb513 100755 --- a/src/ONYXKEYS.ts +++ b/src/ONYXKEYS.ts @@ -133,9 +133,6 @@ const ONYXKEYS = { /** This NVP holds to most recent waypoints that a person has used when creating a distance expense */ NVP_RECENT_WAYPOINTS: 'expensify_recentWaypoints', - /** This NVP will be `true` if the user has ever dismissed the engagement modal on either OldDot or NewDot. If it becomes true it should stay true forever. */ - NVP_HAS_DISMISSED_IDLE_PANEL: 'nvp_hasDismissedIdlePanel', - /** This NVP contains the choice that the user made on the engagement modal */ NVP_INTRO_SELECTED: 'nvp_introSelected', @@ -628,7 +625,6 @@ type OnyxValuesMapping = { [ONYXKEYS.FOCUS_MODE_NOTIFICATION]: boolean; [ONYXKEYS.NVP_LAST_PAYMENT_METHOD]: OnyxTypes.LastPaymentMethod; [ONYXKEYS.NVP_RECENT_WAYPOINTS]: OnyxTypes.RecentWaypoint[]; - [ONYXKEYS.NVP_HAS_DISMISSED_IDLE_PANEL]: boolean; [ONYXKEYS.NVP_INTRO_SELECTED]: OnyxTypes.IntroSelected; [ONYXKEYS.NVP_LAST_SELECTED_DISTANCE_RATES]: OnyxTypes.LastSelectedDistanceRates; [ONYXKEYS.PUSH_NOTIFICATIONS_ENABLED]: boolean; diff --git a/src/libs/actions/Report.ts b/src/libs/actions/Report.ts index 64e2ac9f1c36..b7589444c079 100644 --- a/src/libs/actions/Report.ts +++ b/src/libs/actions/Report.ts @@ -3413,25 +3413,6 @@ function completeOnboarding( API.write(WRITE_COMMANDS.COMPLETE_GUIDED_SETUP, parameters, {optimisticData, successData, failureData}); } -function dismissEngagementModal() { - const parameters: SetNameValuePairParams = { - name: ONYXKEYS.NVP_HAS_DISMISSED_IDLE_PANEL, - value: true, - }; - - const optimisticData: OnyxUpdate[] = [ - { - onyxMethod: Onyx.METHOD.MERGE, - key: ONYXKEYS.NVP_HAS_DISMISSED_IDLE_PANEL, - value: true, - }, - ]; - - API.write(WRITE_COMMANDS.SET_NAME_VALUE_PAIR, parameters, { - optimisticData, - }); -} - /** Loads necessary data for rendering the RoomMembersPage */ function openRoomMembersPage(reportID: string) { const parameters: OpenRoomMembersPageParams = {reportID}; @@ -3742,7 +3723,6 @@ export { hasErrorInPrivateNotes, getOlderActions, getNewerActions, - dismissEngagementModal, openRoomMembersPage, savePrivateNotesDraft, getDraftPrivateNote, diff --git a/src/libs/actions/Welcome.ts b/src/libs/actions/Welcome.ts index 119b7da42e21..2dbe47608ab9 100644 --- a/src/libs/actions/Welcome.ts +++ b/src/libs/actions/Welcome.ts @@ -7,7 +7,6 @@ import type OnyxPolicy from '@src/types/onyx/Policy'; import type {EmptyObject} from '@src/types/utils/EmptyObject'; let onboarding: Onboarding | [] | undefined; -let hasDismissedModal: boolean | undefined; let isLoadingReportData = true; type HasCompletedOnboardingFlowProps = { @@ -58,7 +57,7 @@ function checkOnboardingDataReady() { * Check if user dismissed modal and if report data are loaded */ function checkServerDataReady() { - if (isLoadingReportData || hasDismissedModal === undefined) { + if (isLoadingReportData) { return; } @@ -91,16 +90,6 @@ Onyx.connect({ }, }); -Onyx.connect({ - key: ONYXKEYS.NVP_HAS_DISMISSED_IDLE_PANEL, - initWithStoredValues: true, - callback: (value) => { - hasDismissedModal = value ?? false; - - checkServerDataReady(); - }, -}); - Onyx.connect({ key: ONYXKEYS.IS_LOADING_REPORT_DATA, initWithStoredValues: false, diff --git a/src/libs/migrations/NVPMigration.ts b/src/libs/migrations/NVPMigration.ts index fc5bce22641f..dcab130186d3 100644 --- a/src/libs/migrations/NVPMigration.ts +++ b/src/libs/migrations/NVPMigration.ts @@ -19,7 +19,6 @@ const migrations = { private_pushNotificationID: ONYXKEYS.NVP_PRIVATE_PUSH_NOTIFICATION_ID, tryFocusMode: ONYXKEYS.NVP_TRY_FOCUS_MODE, introSelected: ONYXKEYS.NVP_INTRO_SELECTED, - hasDismissedIdlePanel: ONYXKEYS.NVP_HAS_DISMISSED_IDLE_PANEL, }; // This migration changes the keys of all the NVP related keys so that they are standardized From fb9eaa305559b2e10614b6fe16e98a7f89327442 Mon Sep 17 00:00:00 2001 From: Francois Laithier Date: Thu, 30 May 2024 15:46:37 -0700 Subject: [PATCH 3/3] Fix linter error --- src/libs/actions/Report.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/src/libs/actions/Report.ts b/src/libs/actions/Report.ts index b7589444c079..c7e1164687c0 100644 --- a/src/libs/actions/Report.ts +++ b/src/libs/actions/Report.ts @@ -35,7 +35,6 @@ import type { ResolveActionableReportMentionWhisperParams, SearchForReportsParams, SearchForRoomsToMentionParams, - SetNameValuePairParams, TogglePinnedChatParams, UpdateCommentParams, UpdateGroupChatAvatarParams,