Skip to content

Commit

Permalink
Remove memory only keys logic and related code
Browse files Browse the repository at this point in the history
  • Loading branch information
blazejkustra committed Mar 8, 2024
1 parent 86a9904 commit 6106eca
Show file tree
Hide file tree
Showing 11 changed files with 2 additions and 92 deletions.
4 changes: 0 additions & 4 deletions src/ONYXKEYS.ts
Original file line number Diff line number Diff line change
Expand Up @@ -241,9 +241,6 @@ const ONYXKEYS = {
// This can be either "light", "dark" or "system"
PREFERRED_THEME: 'preferredTheme',

// Experimental memory only Onyx mode flag
IS_USING_MEMORY_ONLY_KEYS: 'isUsingMemoryOnlyKeys',

// Information about the onyx updates IDs that were received from the server
ONYX_UPDATES_FROM_SERVER: 'onyxUpdatesFromServer',

Expand Down Expand Up @@ -566,7 +563,6 @@ type OnyxValuesMapping = {
[ONYXKEYS.MY_DOMAIN_SECURITY_GROUPS]: Record<string, string>;
[ONYXKEYS.LAST_OPENED_PUBLIC_ROOM_ID]: string;
[ONYXKEYS.PREFERRED_THEME]: ValueOf<typeof CONST.THEME>;
[ONYXKEYS.IS_USING_MEMORY_ONLY_KEYS]: boolean;
[ONYXKEYS.MAPBOX_ACCESS_TOKEN]: OnyxTypes.MapboxAccessToken;
[ONYXKEYS.ONYX_UPDATES_FROM_SERVER]: OnyxTypes.OnyxUpdatesFromServer;
[ONYXKEYS.ONYX_UPDATES_LAST_UPDATE_ID_APPLIED_TO_CLIENT]: number;
Expand Down
12 changes: 0 additions & 12 deletions src/libs/Middleware/SaveResponseInOnyx.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
import {SIDE_EFFECT_REQUEST_COMMANDS, WRITE_COMMANDS} from '@libs/API/types';
import * as MemoryOnlyKeys from '@userActions/MemoryOnlyKeys/MemoryOnlyKeys';
import * as OnyxUpdates from '@userActions/OnyxUpdates';
import CONST from '@src/CONST';
import ONYXKEYS from '@src/ONYXKEYS';
import type Middleware from './types';

// If we're executing any of these requests, we don't need to trigger our OnyxUpdates flow to update the current data even if our current value is out of
Expand All @@ -19,16 +17,6 @@ const SaveResponseInOnyx: Middleware = (requestResponse, request) =>
return Promise.resolve(response);
}

// If there is an OnyxUpdate for using memory only keys, enable them
onyxUpdates?.find(({key, value}) => {
if (key !== ONYXKEYS.IS_USING_MEMORY_ONLY_KEYS || !value) {
return false;
}

MemoryOnlyKeys.enable();
return true;
});

const responseToApply = {
type: CONST.ONYX_UPDATE_TYPES.HTTPS,
lastUpdateID: Number(response?.lastUpdateID ?? 0),
Expand Down
14 changes: 2 additions & 12 deletions src/libs/Navigation/AppNavigator/AuthScreens.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,6 @@ type AuthScreensProps = {
/** The report ID of the last opened public room as anonymous user */
lastOpenedPublicRoomID: OnyxEntry<string>;

/** Opt-in experimental mode that prevents certain Onyx keys from persisting to disk */
isUsingMemoryOnlyKeys: OnyxEntry<boolean>;

/** The last Onyx update ID was applied to the client */
initialLastUpdateIDAppliedToClient: OnyxEntry<number>;
};
Expand Down Expand Up @@ -149,7 +146,7 @@ const modalScreenListeners = {
},
};

function AuthScreens({session, lastOpenedPublicRoomID, isUsingMemoryOnlyKeys = false, initialLastUpdateIDAppliedToClient}: AuthScreensProps) {
function AuthScreens({session, lastOpenedPublicRoomID, initialLastUpdateIDAppliedToClient}: AuthScreensProps) {
const styles = useThemeStyles();
const StyleUtils = useStyleUtils();
const {isSmallScreenWidth} = useWindowDimensions();
Expand All @@ -167,7 +164,6 @@ function AuthScreens({session, lastOpenedPublicRoomID, isUsingMemoryOnlyKeys = f
const chatShortcutConfig = CONST.KEYBOARD_SHORTCUTS.NEW_CHAT;
const currentUrl = getCurrentUrl();
const isLoggingInAsNewUser = !!session?.email && SessionUtils.isLoggingInAsNewUser(currentUrl, session.email);
const shouldGetAllData = !!isUsingMemoryOnlyKeys || SessionUtils.didUserLogInDuringSession();
// Sign out the current user if we're transitioning with a different user
const isTransitioning = currentUrl.includes(ROUTES.TRANSITION_BETWEEN_APPS);
const isSupportalTransition = currentUrl.includes('authTokenType=support');
Expand All @@ -189,10 +185,7 @@ function AuthScreens({session, lastOpenedPublicRoomID, isUsingMemoryOnlyKeys = f

// If we are on this screen then we are "logged in", but the user might not have "just logged in". They could be reopening the app
// or returning from background. If so, we'll assume they have some app data already and we can call reconnectApp() instead of openApp().
// Note: If a Guide has enabled the memory only key mode then we do want to run OpenApp as their app will not be rehydrated with
// the correct state on refresh. They are explicitly opting out of storing data they would need (i.e. reports_) to take advantage of
// the optimizations performed during ReconnectApp.
if (shouldGetAllData) {
if (SessionUtils.didUserLogInDuringSession()) {
App.openApp();
} else {
App.reconnectApp(initialLastUpdateIDAppliedToClient);
Expand Down Expand Up @@ -381,9 +374,6 @@ export default withOnyx<AuthScreensProps, AuthScreensProps>({
lastOpenedPublicRoomID: {
key: ONYXKEYS.LAST_OPENED_PUBLIC_ROOM_ID,
},
isUsingMemoryOnlyKeys: {
key: ONYXKEYS.IS_USING_MEMORY_ONLY_KEYS,
},
initialLastUpdateIDAppliedToClient: {
key: ONYXKEYS.ONYX_UPDATES_LAST_UPDATE_ID_APPLIED_TO_CLIENT,
},
Expand Down
6 changes: 0 additions & 6 deletions src/libs/PolicyUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -102,11 +102,6 @@ function isExpensifyTeam(email: string | undefined): boolean {
return emailDomain === CONST.EXPENSIFY_PARTNER_NAME || emailDomain === CONST.EMAIL.GUIDES_DOMAIN;
}

function isExpensifyGuideTeam(email: string): boolean {
const emailDomain = Str.extractEmailDomain(email ?? '');
return emailDomain === CONST.EMAIL.GUIDES_DOMAIN;
}

/**
* Checks if the current user is an admin of the policy.
*/
Expand Down Expand Up @@ -282,7 +277,6 @@ export {
getPolicyBrickRoadIndicatorStatus,
shouldShowPolicy,
isExpensifyTeam,
isExpensifyGuideTeam,
isInstantSubmitEnabled,
isFreeGroupPolicy,
isPolicyAdmin,
Expand Down
20 changes: 0 additions & 20 deletions src/libs/actions/MemoryOnlyKeys/MemoryOnlyKeys.ts

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

9 changes: 0 additions & 9 deletions src/pages/signin/LoginForm/BaseLoginForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,12 @@ import useThemeStyles from '@hooks/useThemeStyles';
import canFocusInputOnScreenFocus from '@libs/canFocusInputOnScreenFocus';
import * as ErrorUtils from '@libs/ErrorUtils';
import isInputAutoFilled from '@libs/isInputAutoFilled';
import Log from '@libs/Log';
import * as LoginUtils from '@libs/LoginUtils';
import {parsePhoneNumber} from '@libs/PhoneNumber';
import * as PolicyUtils from '@libs/PolicyUtils';
import * as ValidationUtils from '@libs/ValidationUtils';
import Visibility from '@libs/Visibility';
import willBlurTextInputOnTapOutsideFunc from '@libs/willBlurTextInputOnTapOutside';
import * as CloseAccount from '@userActions/CloseAccount';
import * as MemoryOnlyKeys from '@userActions/MemoryOnlyKeys/MemoryOnlyKeys';
import * as Session from '@userActions/Session';
import CONFIG from '@src/CONFIG';
import CONST from '@src/CONST';
Expand Down Expand Up @@ -151,12 +148,6 @@ function BaseLoginForm({account, credentials, closeAccount, blurOnSubmit = false

const loginTrim = login.trim();

// If the user has entered a guide email, then we are going to enable an experimental Onyx mode to help with performance
if (PolicyUtils.isExpensifyGuideTeam(loginTrim)) {
Log.info('Detected guide email in login field, setting memory only keys.');
MemoryOnlyKeys.enable();
}

const phoneLogin = LoginUtils.appendCountryCode(LoginUtils.getPhoneNumberWithoutSpecialChars(loginTrim));
const parsedPhoneNumber = parsePhoneNumber(phoneLogin);

Expand Down
3 changes: 0 additions & 3 deletions src/setup/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import Onyx from 'react-native-onyx';
import intlPolyfill from '@libs/IntlPolyfill';
import * as Metrics from '@libs/Metrics';
import * as Device from '@userActions/Device';
import exposeGlobalMemoryOnlyKeysMethods from '@userActions/MemoryOnlyKeys/exposeGlobalMemoryOnlyKeysMethods';
import CONST from '@src/CONST';
import ONYXKEYS from '@src/ONYXKEYS';
import addUtilsToWindow from './addUtilsToWindow';
Expand Down Expand Up @@ -47,8 +46,6 @@ export default function () {
},
});

exposeGlobalMemoryOnlyKeysMethods();

Device.setDeviceID();

// Force app layout to work left to right because our design does not currently support devices using this mode
Expand Down
2 changes: 0 additions & 2 deletions src/types/modules/react-native-onyx.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@ declare global {
// Global methods for Onyx key management for debugging purposes
// eslint-disable-next-line @typescript-eslint/consistent-type-definitions
interface Window {
enableMemoryOnlyKeys: () => void;
disableMemoryOnlyKeys: () => void;
Onyx: typeof Onyx;
}
}

0 comments on commit 6106eca

Please sign in to comment.