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

Remove deprecated CompleteEngagementModal API command call and associated logic #42873

Merged
merged 3 commits into from
May 31, 2024
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: 0 additions & 4 deletions src/ONYXKEYS.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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',

Expand Down Expand Up @@ -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;
Expand Down
10 changes: 0 additions & 10 deletions src/libs/API/parameters/CompleteEngagementModalParams.ts

This file was deleted.

1 change: 0 additions & 1 deletion src/libs/API/parameters/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down
2 changes: 0 additions & 2 deletions src/libs/API/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down Expand Up @@ -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;
Expand Down
124 changes: 0 additions & 124 deletions src/libs/actions/Report.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ import type {
AddCommentOrAttachementParams,
AddEmojiReactionParams,
AddWorkspaceRoomParams,
CompleteEngagementModalParams,
CompleteGuidedSetupParams,
DeleteCommentParams,
ExpandURLPreviewParams,
Expand All @@ -36,7 +35,6 @@ import type {
ResolveActionableReportMentionWhisperParams,
SearchForReportsParams,
SearchForRoomsToMentionParams,
SetNameValuePairParams,
TogglePinnedChatParams,
UpdateCommentParams,
UpdateGroupChatAvatarParams,
Expand Down Expand Up @@ -3414,126 +3412,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<Report> = {
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<OptimisticAddCommentReportAction> = {};
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,
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};
Expand Down Expand Up @@ -3844,8 +3722,6 @@ export {
hasErrorInPrivateNotes,
getOlderActions,
getNewerActions,
completeEngagementModal,
dismissEngagementModal,
openRoomMembersPage,
savePrivateNotesDraft,
getDraftPrivateNote,
Expand Down
13 changes: 1 addition & 12 deletions src/libs/actions/Welcome.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand Down Expand Up @@ -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;
}

Expand Down Expand Up @@ -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,
Expand Down
1 change: 0 additions & 1 deletion src/libs/migrations/NVPMigration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Loading