Skip to content

Commit

Permalink
Merge pull request #57328 from software-mansion-labs/refactor-switch-…
Browse files Browse the repository at this point in the history
…to-old-dot-on-11+

Define noop implementation of 11+ redirect for desktop app
  • Loading branch information
Julesssss authored Feb 24, 2025
2 parents 4ffe292 + c6dc6a5 commit 8851091
Show file tree
Hide file tree
Showing 5 changed files with 42 additions and 29 deletions.
25 changes: 1 addition & 24 deletions src/libs/actions/Welcome/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@ import * as API from '@libs/API';
import {SIDE_EFFECT_REQUEST_COMMANDS, WRITE_COMMANDS} from '@libs/API/types';
import DateUtils from '@libs/DateUtils';
import Log from '@libs/Log';
import CONST from '@src/CONST';
import type {OnboardingCompanySize} from '@src/CONST';
import ONYXKEYS from '@src/ONYXKEYS';
import type {OnboardingPurpose} from '@src/types/onyx';
import type Onboarding from '@src/types/onyx/Onboarding';
import type TryNewDot from '@src/types/onyx/TryNewDot';
import {isEmptyObject} from '@src/types/utils/EmptyObject';
import {clearInitialPath} from './OnboardingFlow';
import switchToOldDotOnNonMicroCompanySize from './switchToOldDotOnNonMicroCompanySize';

type OnboardingData = Onboarding | undefined;

Expand Down Expand Up @@ -150,29 +150,6 @@ function completeHybridAppOnboarding() {
});
}

/*
* Decides whether we should set dismissed key to `true` or `false` based on company size
*/
function switchToOldDotOnNonMicroCompanySize(onboardingCompanySize: OnboardingCompanySize) {
if (onboardingCompanySize === CONST.ONBOARDING_COMPANY_SIZE.MICRO) {
return;
}

const optimisticData: OnyxUpdate[] = [
{
onyxMethod: Onyx.METHOD.MERGE,
key: ONYXKEYS.NVP_TRYNEWDOT,
value: {
classicRedirect: {
dismissed: true,
},
},
},
];

API.write(WRITE_COMMANDS.SWITCH_TO_OLD_DOT_ON_COMPANY_SIZE, {onboardingCompanySize}, {optimisticData});
}

Onyx.connect({
key: ONYXKEYS.NVP_ONBOARDING,
callback: (value) => {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import type SwitchToOldDotOnNonMicroCompanySize from './types';

// We don't want to use this API on desktop, so we just noop here
const switchToOldDotOnNonMicroCompanySize: SwitchToOldDotOnNonMicroCompanySize = () => {};

export default switchToOldDotOnNonMicroCompanySize;
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import type {OnyxUpdate} from 'react-native-onyx';
import Onyx from 'react-native-onyx';
import * as API from '@libs/API';
import {WRITE_COMMANDS} from '@libs/API/types';
import CONST from '@src/CONST';
import ONYXKEYS from '@src/ONYXKEYS';
import type SwitchToOldDotOnNonMicroCompanySize from './types';

const switchToOldDotOnNonMicroCompanySize: SwitchToOldDotOnNonMicroCompanySize = (onboardingCompanySize) => {
if (onboardingCompanySize === CONST.ONBOARDING_COMPANY_SIZE.MICRO) {
return;
}

const optimisticData: OnyxUpdate[] = [
{
onyxMethod: Onyx.METHOD.MERGE,
key: ONYXKEYS.NVP_TRYNEWDOT,
value: {
classicRedirect: {
dismissed: true,
},
},
},
];

API.write(WRITE_COMMANDS.SWITCH_TO_OLD_DOT_ON_COMPANY_SIZE, {onboardingCompanySize}, {optimisticData});
};

export default switchToOldDotOnNonMicroCompanySize;
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import type {OnboardingCompanySize} from '@src/CONST';

type SwitchToOldDotOnNonMicroCompanySize = (onboardingCompanySize: OnboardingCompanySize) => void;

export default SwitchToOldDotOnNonMicroCompanySize;
6 changes: 1 addition & 5 deletions src/pages/OnboardingEmployees/BaseOnboardingEmployees.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -74,11 +74,7 @@ function BaseOnboardingEmployees({shouldUseNativeStyles, route}: BaseOnboardingE
return;
}
setOnboardingCompanySize(selectedCompanySize);

// Redirect is disabled on desktop
if (getPlatform() !== CONST.PLATFORM.DESKTOP) {
switchToOldDotOnNonMicroCompanySize(selectedCompanySize);
}
switchToOldDotOnNonMicroCompanySize(selectedCompanySize);

const shouldCreateWorkspace = !onboardingPolicyID && !paidGroupPolicy;

Expand Down

0 comments on commit 8851091

Please sign in to comment.