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

[NoQA] Remove DemoSetupPage and related code #33213

Merged
merged 2 commits into from
Dec 26, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
5 changes: 0 additions & 5 deletions src/CONST.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2915,11 +2915,6 @@ const CONST = {
PARENT_CHILD_SEPARATOR: ': ',
CATEGORY_LIST_THRESHOLD: 8,
TAG_LIST_THRESHOLD: 8,
DEMO_PAGES: {
SAASTR: 'SaaStrDemoSetup',
SBE: 'SbeDemoSetup',
MONEY2020: 'Money2020DemoSetup',
},
COLON: ':',
MAPBOX: {
PADDING: 50,
Expand Down
6 changes: 3 additions & 3 deletions src/Expensify.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import AppleAuthWrapper from './components/SignInButtons/AppleAuthWrapper';
import SplashScreenHider from './components/SplashScreenHider';
import UpdateAppModal from './components/UpdateAppModal';
import withLocalize, {withLocalizePropTypes} from './components/withLocalize';
import * as DemoActions from './libs/actions/DemoActions';
import runDemo from './libs/actions/DemoActions';
import * as EmojiPickerAction from './libs/actions/EmojiPickerAction';
import * as Report from './libs/actions/Report';
import * as User from './libs/actions/User';
Expand Down Expand Up @@ -183,13 +183,13 @@ function Expensify(props) {

// If the app is opened from a deep link, get the reportID (if exists) from the deep link and navigate to the chat report
Linking.getInitialURL().then((url) => {
DemoActions.runDemoByURL(url);
runDemo();
Report.openReportFromDeepLink(url, isAuthenticated);
});

// Open chat report from a deep link (only mobile native)
Linking.addEventListener('url', (state) => {
DemoActions.runDemoByURL(state.url);
runDemo();
Report.openReportFromDeepLink(state.url, isAuthenticated);
});

Expand Down
5 changes: 0 additions & 5 deletions src/ROUTES.ts
Original file line number Diff line number Diff line change
Expand Up @@ -463,11 +463,6 @@ const ROUTES = {
route: 'referral/:contentType',
getRoute: (contentType: string) => `referral/${contentType}` as const,
},

// These are some one-off routes that will be removed once they're no longer needed (see GH issues for details)
SAASTR: 'saastr',
SBE: 'sbe',
MONEY2020: 'money2020',
} as const;

export {getUrlWithBackToParam};
Expand Down
28 changes: 1 addition & 27 deletions src/libs/Navigation/AppNavigator/AuthScreens.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import * as Pusher from '@libs/Pusher/pusher';
import PusherConnectionManager from '@libs/PusherConnectionManager';
import * as SessionUtils from '@libs/SessionUtils';
import type {AuthScreensParamList} from '@navigation/types';
import DemoSetupPage from '@pages/DemoSetupPage';
import NotFoundPage from '@pages/ErrorPage/NotFoundPage';
import DesktopSignInRedirectPage from '@pages/signin/DesktopSignInRedirectPage';
import SearchInputManager from '@pages/workspace/SearchInputManager';
Expand Down Expand Up @@ -50,9 +49,6 @@ type AuthScreensProps = {

/** The last Onyx update ID was applied to the client */
lastUpdateIDAppliedToClient: OnyxEntry<number>;

/** Information about any currently running demos */
demoInfo: OnyxEntry<OnyxTypes.DemoInfo>;
};

const loadReportAttachments = () => require('../../../pages/home/report/ReportAttachments').default as React.ComponentType;
Expand Down Expand Up @@ -130,7 +126,7 @@ const modalScreenListeners = {
},
};

function AuthScreens({lastUpdateIDAppliedToClient, session, lastOpenedPublicRoomID, demoInfo, isUsingMemoryOnlyKeys = false}: AuthScreensProps) {
function AuthScreens({lastUpdateIDAppliedToClient, session, lastOpenedPublicRoomID, isUsingMemoryOnlyKeys = false}: AuthScreensProps) {
const styles = useThemeStyles();
const {isSmallScreenWidth} = useWindowDimensions();
const screenOptions = getRootNavigatorScreenOptions(isSmallScreenWidth, styles);
Expand Down Expand Up @@ -189,10 +185,6 @@ function AuthScreens({lastUpdateIDAppliedToClient, session, lastOpenedPublicRoom

App.redirectThirdPartyDesktopSignIn();

// Check if we should be running any demos immediately after signing in.
if (demoInfo?.money2020?.isBeginningDemo) {
Navigation.navigate(ROUTES.MONEY2020, CONST.NAVIGATION.TYPE.FORCED_UP);
}
if (lastOpenedPublicRoomID) {
// Re-open the last opened public room if the user logged in from a public room link
Report.openLastOpenedPublicRoom(lastOpenedPublicRoomID);
Expand Down Expand Up @@ -283,21 +275,6 @@ function AuthScreens({lastUpdateIDAppliedToClient, session, lastOpenedPublicRoom
options={defaultScreenOptions}
getComponent={loadConciergePage}
/>
<RootStack.Screen
name={CONST.DEMO_PAGES.SAASTR}
options={defaultScreenOptions}
component={DemoSetupPage}
/>
<RootStack.Screen
name={CONST.DEMO_PAGES.SBE}
options={defaultScreenOptions}
component={DemoSetupPage}
/>
<RootStack.Screen
name={CONST.DEMO_PAGES.MONEY2020}
options={defaultScreenOptions}
component={DemoSetupPage}
/>
<RootStack.Screen
name={SCREENS.REPORT_ATTACHMENTS}
options={{
Expand Down Expand Up @@ -345,7 +322,4 @@ export default withOnyx<AuthScreensProps, AuthScreensProps>({
lastUpdateIDAppliedToClient: {
key: ONYXKEYS.ONYX_UPDATES_LAST_UPDATE_ID_APPLIED_TO_CLIENT,
},
demoInfo: {
key: ONYXKEYS.DEMO_INFO,
},
})(AuthScreensMemoized);
3 changes: 0 additions & 3 deletions src/libs/Navigation/linkingConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,6 @@ const linkingConfig: LinkingOptions<RootStackParamList> = {
[SCREENS.DESKTOP_SIGN_IN_REDIRECT]: ROUTES.DESKTOP_SIGN_IN_REDIRECT,
[SCREENS.REPORT_ATTACHMENTS]: ROUTES.REPORT_ATTACHMENTS.route,

// Demo routes
[CONST.DEMO_PAGES.MONEY2020]: ROUTES.MONEY2020,

// Sidebar
[SCREENS.HOME]: {
path: ROUTES.HOME,
Expand Down
7 changes: 0 additions & 7 deletions src/libs/Navigation/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -400,16 +400,9 @@ type AuthScreensParamList = {
reportID: string;
source: string;
};
[CONST.DEMO_PAGES.SAASTR]: {
name: string;
};
[CONST.DEMO_PAGES.SBE]: {
name: string;
};
[SCREENS.NOT_FOUND]: undefined;
[NAVIGATORS.RIGHT_MODAL_NAVIGATOR]: NavigatorScreenParams<RightModalNavigatorParamList>;
[SCREENS.DESKTOP_SIGN_IN_REDIRECT]: undefined;
[CONST.DEMO_PAGES.MONEY2020]: undefined;
};

type RootStackParamList = PublicScreensParamList & AuthScreensParamList;
Expand Down
68 changes: 5 additions & 63 deletions src/libs/actions/DemoActions.js
Original file line number Diff line number Diff line change
@@ -1,70 +1,12 @@
import lodashGet from 'lodash/get';
import Config from 'react-native-config';
import Onyx from 'react-native-onyx';
import * as API from '@libs/API';
import Navigation from '@libs/Navigation/Navigation';
import * as ReportUtils from '@libs/ReportUtils';
import ONYXKEYS from '@src/ONYXKEYS';
import ROUTES from '@src/ROUTES';

let currentUserEmail;
Onyx.connect({
key: ONYXKEYS.SESSION,
callback: (val) => {
currentUserEmail = lodashGet(val, 'email', '');
},
});

function runMoney2020Demo() {
// Try to navigate to existing demo chat if it exists in Onyx
const money2020AccountID = Number(lodashGet(Config, 'EXPENSIFY_ACCOUNT_ID_MONEY2020', 15864555));
const existingChatReport = ReportUtils.getChatByParticipants([money2020AccountID]);
if (existingChatReport) {
// We must call goBack() to remove the demo route from nav history
Navigation.goBack();
Navigation.navigate(ROUTES.REPORT_WITH_ID.getRoute(existingChatReport.reportID));
return;
}

// We use makeRequestWithSideEffects here because we need to get the chat report ID to navigate to it after it's created
// eslint-disable-next-line rulesdir/no-api-side-effects-method
API.makeRequestWithSideEffects('CreateChatReport', {
emailList: `${currentUserEmail},money2020@expensify.com`,
activationConference: 'money2020',
}).then((response) => {
// If there's no response or no reportID in the response, navigate the user home so user doesn't get stuck.
if (!response || !response.reportID) {
Navigation.goBack();
Navigation.navigate(ROUTES.HOME);
return;
}

// Get reportID & navigate to it
// Note: We must call goBack() to remove the demo route from history
const chatReportID = response.reportID;
Navigation.goBack();
Navigation.navigate(ROUTES.REPORT_WITH_ID.getRoute(chatReportID));
});
}

/**
* Runs code for specific demos, based on the provided URL
*
* @param {String} url - URL user is navigating to via deep link (or regular link in web)
* Runs demo code
*/
function runDemoByURL(url = '') {
const cleanUrl = (url || '').toLowerCase();

if (cleanUrl.endsWith(ROUTES.MONEY2020)) {
Onyx.set(ONYXKEYS.DEMO_INFO, {
money2020: {
isBeginningDemo: true,
},
});
} else {
// No demo is being run, so clear out demo info
Onyx.set(ONYXKEYS.DEMO_INFO, {});
}
function runDemo() {
// No demo is being run, so clear out demo info
JKobrynski marked this conversation as resolved.
Show resolved Hide resolved
Onyx.set(ONYXKEYS.DEMO_INFO, {});
}

export {runMoney2020Demo, runDemoByURL};
export default runDemo;
40 changes: 0 additions & 40 deletions src/pages/DemoSetupPage.js

This file was deleted.

Loading