From b675ea85be3a31d6d7088d3d6f75927cf743cfed Mon Sep 17 00:00:00 2001 From: Blazej Kustra Date: Thu, 14 Nov 2024 17:11:53 +0100 Subject: [PATCH 1/4] Fix that onboarding tasks are duplicated when switching chat --- src/libs/actions/Report.ts | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/src/libs/actions/Report.ts b/src/libs/actions/Report.ts index f2b4186fa566..ca2809be54af 100644 --- a/src/libs/actions/Report.ts +++ b/src/libs/actions/Report.ts @@ -108,6 +108,7 @@ import type { ReportActionReactions, ReportUserIsTyping, } from '@src/types/onyx'; +import Onboarding from '@src/types/onyx/Onboarding'; import type {Decision} from '@src/types/onyx/OriginalMessage'; import type {ConnectionName} from '@src/types/onyx/Policy'; import type Report from '@src/types/onyx/Report'; @@ -279,6 +280,17 @@ Onyx.connect({ callback: (val) => (quickAction = val), }); +let onboarding: OnyxEntry; +Onyx.connect({ + key: ONYXKEYS.NVP_ONBOARDING, + callback: (val) => { + if (Array.isArray(val)) { + return; + } + onboarding = val; + }, +}); + let introSelected: OnyxEntry = {}; Onyx.connect({ key: ONYXKEYS.NVP_INTRO_SELECTED, @@ -858,8 +870,9 @@ function openReport( }; const isInviteOnboardingComplete = introSelected?.isInviteOnboardingComplete ?? false; + const isOnboardingCompleted = onboarding?.hasCompletedGuidedSetupFlow ?? false; - if (introSelected && !isInviteOnboardingComplete) { + if (introSelected && !isOnboardingCompleted && !isInviteOnboardingComplete) { const {choice, inviteType} = introSelected; const isInviteIOUorInvoice = inviteType === CONST.ONBOARDING_INVITE_TYPES.IOU || inviteType === CONST.ONBOARDING_INVITE_TYPES.INVOICE; const isInviteChoiceCorrect = choice === CONST.ONBOARDING_CHOICES.ADMIN || choice === CONST.ONBOARDING_CHOICES.SUBMIT || choice === CONST.ONBOARDING_CHOICES.CHAT_SPLIT; From 518602c3b7a214f359d5996583f8b08321b5a2cd Mon Sep 17 00:00:00 2001 From: Blazej Kustra Date: Thu, 14 Nov 2024 17:34:25 +0100 Subject: [PATCH 2/4] Fix eslint --- src/libs/actions/Report.ts | 2 +- src/types/onyx/index.ts | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/libs/actions/Report.ts b/src/libs/actions/Report.ts index ca2809be54af..b5f8ce367318 100644 --- a/src/libs/actions/Report.ts +++ b/src/libs/actions/Report.ts @@ -99,6 +99,7 @@ import type { IntroSelected, InvitedEmailsToAccountIDs, NewGroupChatDraft, + Onboarding, OnboardingPurpose, PersonalDetailsList, PolicyReportField, @@ -108,7 +109,6 @@ import type { ReportActionReactions, ReportUserIsTyping, } from '@src/types/onyx'; -import Onboarding from '@src/types/onyx/Onboarding'; import type {Decision} from '@src/types/onyx/OriginalMessage'; import type {ConnectionName} from '@src/types/onyx/Policy'; import type Report from '@src/types/onyx/Report'; diff --git a/src/types/onyx/index.ts b/src/types/onyx/index.ts index 79c2b4f230d4..cec5243990a6 100644 --- a/src/types/onyx/index.ts +++ b/src/types/onyx/index.ts @@ -41,6 +41,7 @@ import type MobileSelectionMode from './MobileSelectionMode'; import type Modal from './Modal'; import type Network from './Network'; import type NewGroupChatDraft from './NewGroupChatDraft'; +import type Onboarding from './Onboarding'; import type OnyxInputOrEntry from './OnyxInputOrEntry'; import type {OnyxUpdateEvent, OnyxUpdatesFromServer} from './OnyxUpdatesFromServer'; import type {DecisionName, OriginalMessageIOU} from './OriginalMessage'; @@ -237,6 +238,7 @@ export type { SaveSearch, RecentSearchItem, ImportedSpreadsheet, + Onboarding, OnboardingPurpose, ValidateMagicCodeAction, }; From 668fd184513bdacced73a418560cdbfc5b903370 Mon Sep 17 00:00:00 2001 From: Blazej Kustra Date: Thu, 14 Nov 2024 19:22:17 +0100 Subject: [PATCH 3/4] Add comment --- src/libs/actions/Report.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/libs/actions/Report.ts b/src/libs/actions/Report.ts index b5f8ce367318..cc9d05d50042 100644 --- a/src/libs/actions/Report.ts +++ b/src/libs/actions/Report.ts @@ -872,6 +872,8 @@ function openReport( const isInviteOnboardingComplete = introSelected?.isInviteOnboardingComplete ?? false; const isOnboardingCompleted = onboarding?.hasCompletedGuidedSetupFlow ?? false; + // Add guided setup data only when nvp_introSelected is set and guided setup is not completed + // OldDot users will never have introSelected set, so they will not see guided setup if (introSelected && !isOnboardingCompleted && !isInviteOnboardingComplete) { const {choice, inviteType} = introSelected; const isInviteIOUorInvoice = inviteType === CONST.ONBOARDING_INVITE_TYPES.IOU || inviteType === CONST.ONBOARDING_INVITE_TYPES.INVOICE; From 6842df972a5d47990a554e0e345c5e6afc6e96c4 Mon Sep 17 00:00:00 2001 From: Blazej Kustra Date: Thu, 14 Nov 2024 19:29:46 +0100 Subject: [PATCH 4/4] Correct comments --- src/libs/actions/Report.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/libs/actions/Report.ts b/src/libs/actions/Report.ts index cc9d05d50042..ec87dcb16df8 100644 --- a/src/libs/actions/Report.ts +++ b/src/libs/actions/Report.ts @@ -872,8 +872,8 @@ function openReport( const isInviteOnboardingComplete = introSelected?.isInviteOnboardingComplete ?? false; const isOnboardingCompleted = onboarding?.hasCompletedGuidedSetupFlow ?? false; - // Add guided setup data only when nvp_introSelected is set and guided setup is not completed - // OldDot users will never have introSelected set, so they will not see guided setup + // Prepare guided setup data only when nvp_introSelected is set and onboarding is not completed + // OldDot users will never have nvp_introSelected set, so they will not see guided setup messages if (introSelected && !isOnboardingCompleted && !isInviteOnboardingComplete) { const {choice, inviteType} = introSelected; const isInviteIOUorInvoice = inviteType === CONST.ONBOARDING_INVITE_TYPES.IOU || inviteType === CONST.ONBOARDING_INVITE_TYPES.INVOICE;