Skip to content

Commit

Permalink
Merge pull request #52585 from software-mansion-labs/fix/guided-setup
Browse files Browse the repository at this point in the history
Fix that onboarding tasks are duplicated when switching chat
  • Loading branch information
Gonals authored Nov 14, 2024
2 parents d7634a1 + 6842df9 commit 93ae75f
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
17 changes: 16 additions & 1 deletion src/libs/actions/Report.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ import type {
IntroSelected,
InvitedEmailsToAccountIDs,
NewGroupChatDraft,
Onboarding,
OnboardingPurpose,
PersonalDetailsList,
PolicyReportField,
Expand Down Expand Up @@ -279,6 +280,17 @@ Onyx.connect({
callback: (val) => (quickAction = val),
});

let onboarding: OnyxEntry<Onboarding>;
Onyx.connect({
key: ONYXKEYS.NVP_ONBOARDING,
callback: (val) => {
if (Array.isArray(val)) {
return;
}
onboarding = val;
},
});

let introSelected: OnyxEntry<IntroSelected> = {};
Onyx.connect({
key: ONYXKEYS.NVP_INTRO_SELECTED,
Expand Down Expand Up @@ -858,8 +870,11 @@ function openReport(
};

const isInviteOnboardingComplete = introSelected?.isInviteOnboardingComplete ?? false;
const isOnboardingCompleted = onboarding?.hasCompletedGuidedSetupFlow ?? false;

if (introSelected && !isInviteOnboardingComplete) {
// 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;
const isInviteChoiceCorrect = choice === CONST.ONBOARDING_CHOICES.ADMIN || choice === CONST.ONBOARDING_CHOICES.SUBMIT || choice === CONST.ONBOARDING_CHOICES.CHAT_SPLIT;
Expand Down
2 changes: 2 additions & 0 deletions src/types/onyx/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -237,6 +238,7 @@ export type {
SaveSearch,
RecentSearchItem,
ImportedSpreadsheet,
Onboarding,
OnboardingPurpose,
ValidateMagicCodeAction,
};

0 comments on commit 93ae75f

Please sign in to comment.