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

Fix that onboarding tasks are duplicated when switching chat #52585

Merged
merged 4 commits into from
Nov 14, 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
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;
blazejkustra marked this conversation as resolved.
Show resolved Hide resolved

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,
};
Loading