Skip to content
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
18 changes: 9 additions & 9 deletions src/ONYXKEYS.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ const ONYXKEYS = {
DEVICE_ID: 'deviceID',

/** Boolean flag set whenever the sidebar has loaded */
IS_SIDEBAR_LOADED: 'isSidebarLoaded',
RAM_ONLY_IS_SIDEBAR_LOADED: 'isSidebarLoaded',

/** Boolean flag set whenever we are searching for reports in the server */
RAM_ONLY_IS_SEARCHING_FOR_REPORTS: 'isSearchingForReports',
Expand Down Expand Up @@ -210,7 +210,7 @@ const ONYXKEYS = {
NVP_PREFERRED_LOCALE: 'nvp_preferredLocale',

/** Whether the app is currently loading a translation */
ARE_TRANSLATIONS_LOADING: 'areTranslationsLoading',
RAM_ONLY_ARE_TRANSLATIONS_LOADING: 'areTranslationsLoading',

/** Whether the user has tried focus mode yet */
NVP_TRY_FOCUS_MODE: 'nvp_tryFocusMode',
Expand Down Expand Up @@ -547,7 +547,7 @@ const ONYXKEYS = {
ASSIGN_CARD: 'assignCard',

/** Stores the information if mobile selection mode is active */
MOBILE_SELECTION_MODE: 'mobileSelectionMode',
RAM_ONLY_MOBILE_SELECTION_MODE: 'mobileSelectionMode',

NVP_PRIVATE_CANCELLATION_DETAILS: 'nvp_private_cancellationDetails',

Expand Down Expand Up @@ -802,7 +802,7 @@ const ONYXKEYS = {
NVP_EXPENSIFY_REPORT_PDF_FILENAME: 'nvp_expensify_report_PDFFilename_',

/** Stores the information about the state of issuing a new card */
ISSUE_NEW_EXPENSIFY_CARD: 'issueNewExpensifyCard_',
RAM_ONLY_ISSUE_NEW_EXPENSIFY_CARD: 'issueNewExpensifyCard_',

/** Used for identifying user as admin of a domain */
SHARED_NVP_PRIVATE_ADMIN_ACCESS: 'sharedNVP_private_admin_access_',
Expand Down Expand Up @@ -1288,7 +1288,7 @@ type OnyxCollectionValuesMapping = {
[ONYXKEYS.COLLECTION.LAST_SELECTED_FEED]: OnyxTypes.CompanyCardFeedWithDomainID;
[ONYXKEYS.COLLECTION.LAST_SELECTED_EXPENSIFY_CARD_FEED]: OnyxTypes.FundID;
[ONYXKEYS.COLLECTION.NVP_EXPENSIFY_ON_CARD_WAITLIST]: OnyxTypes.CardOnWaitlist;
[ONYXKEYS.COLLECTION.ISSUE_NEW_EXPENSIFY_CARD]: OnyxTypes.IssueNewCard;
[ONYXKEYS.COLLECTION.RAM_ONLY_ISSUE_NEW_EXPENSIFY_CARD]: OnyxTypes.IssueNewCard;
[ONYXKEYS.COLLECTION.SHARED_NVP_PRIVATE_ADMIN_ACCESS]: boolean;
[ONYXKEYS.COLLECTION.SAML_METADATA]: OnyxTypes.SamlMetadata;
[ONYXKEYS.COLLECTION.DOMAIN_PENDING_ACTIONS]: OnyxTypes.DomainPendingActions;
Expand All @@ -1312,7 +1312,7 @@ type OnyxValuesMapping = {
[ONYXKEYS.RECENTLY_USED_CURRENCIES]: string[];
[ONYXKEYS.ACTIVE_CLIENTS]: string[];
[ONYXKEYS.DEVICE_ID]: string;
[ONYXKEYS.IS_SIDEBAR_LOADED]: boolean;
[ONYXKEYS.RAM_ONLY_IS_SIDEBAR_LOADED]: boolean;
[ONYXKEYS.PERSISTED_REQUESTS]: OnyxTypes.AnyRequest[];
[ONYXKEYS.PERSISTED_ONGOING_REQUESTS]: OnyxTypes.AnyRequest;
[ONYXKEYS.CURRENT_DATE]: string;
Expand Down Expand Up @@ -1379,7 +1379,7 @@ type OnyxValuesMapping = {
[ONYXKEYS.ONFIDO_TOKEN]: string;
[ONYXKEYS.ONFIDO_APPLICANT_ID]: string;
[ONYXKEYS.NVP_PREFERRED_LOCALE]: OnyxTypes.Locale;
[ONYXKEYS.ARE_TRANSLATIONS_LOADING]: boolean;
[ONYXKEYS.RAM_ONLY_ARE_TRANSLATIONS_LOADING]: boolean;
[ONYXKEYS.NVP_ACTIVE_POLICY_ID]: string;
[ONYXKEYS.NVP_DISMISSED_REFERRAL_BANNERS]: OnyxTypes.DismissedReferralBanners;
[ONYXKEYS.NVP_HAS_SEEN_TRACK_TRAINING]: boolean;
Expand Down Expand Up @@ -1413,11 +1413,11 @@ type OnyxValuesMapping = {
[ONYXKEYS.IS_LOADING_SHARE_BANK_ACCOUNTS]: boolean;
[ONYXKEYS.IS_LOADING_BULK_CHANGE_APPROVER_PAGE]: boolean;
[ONYXKEYS.IS_LOADING_POLICY_CODING_RULES_PREVIEW]: boolean;
[ONYXKEYS.IS_LOADING_REPORT_DATA]: boolean;
[ONYXKEYS.IS_SEARCH_FILTERS_CARD_DATA_LOADED]: boolean;
[ONYXKEYS.IS_LOADING_SUBSCRIPTION_DATA]: boolean;
[ONYXKEYS.IS_PENDING_UPDATE_PERSONAL_KARMA]: boolean;
[ONYXKEYS.IS_SEARCH_PAGE_DATA_LOADED]: boolean;
[ONYXKEYS.IS_LOADING_REPORT_DATA]: boolean;
[ONYXKEYS.IS_TEST_TOOLS_MODAL_OPEN]: boolean;
[ONYXKEYS.IS_LOADING_APP]: boolean;
[ONYXKEYS.HAS_LOADED_APP]: boolean;
Expand Down Expand Up @@ -1467,7 +1467,7 @@ type OnyxValuesMapping = {
[ONYXKEYS.ADD_NEW_COMPANY_CARD]: OnyxTypes.AddNewCompanyCardFeed;
[ONYXKEYS.ADD_NEW_PERSONAL_CARD]: OnyxTypes.AddNewPersonalCard;
[ONYXKEYS.ASSIGN_CARD]: OnyxTypes.AssignCard;
[ONYXKEYS.MOBILE_SELECTION_MODE]: boolean;
[ONYXKEYS.RAM_ONLY_MOBILE_SELECTION_MODE]: boolean;
[ONYXKEYS.DUPLICATE_WORKSPACE]: OnyxTypes.DuplicateWorkspace;
[ONYXKEYS.NVP_FIRST_DAY_FREE_TRIAL]: string;
[ONYXKEYS.NVP_LAST_DAY_FREE_TRIAL]: string;
Expand Down
2 changes: 1 addition & 1 deletion src/components/LocaleContextProvider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ const COLLATOR_OPTIONS: Intl.CollatorOptions = {usage: 'sort', sensitivity: 'var

function LocaleContextProvider({children}: LocaleContextProviderProps) {
const currentUserPersonalDetails = useCurrentUserPersonalDetails();
const [areTranslationsLoading = true] = useOnyx(ONYXKEYS.ARE_TRANSLATIONS_LOADING, {initWithStoredValues: false});
const [areTranslationsLoading = true] = useOnyx(ONYXKEYS.RAM_ONLY_ARE_TRANSLATIONS_LOADING);
const [countryCodeByIP = 1] = useOnyx(ONYXKEYS.COUNTRY_CODE);
const [nvpPreferredLocale, nvpPreferredLocaleMetadata] = useOnyx(ONYXKEYS.NVP_PREFERRED_LOCALE);
const [currentLocale, setCurrentLocale] = useState<Locale | undefined>(() => IntlStore.getCurrentLocale());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ function TransactionGroupListExpanded<TItem extends ListItem>({
const {windowWidth} = useWindowDimensions();
const currentUserDetails = useCurrentUserPersonalDetails();
const {translate} = useLocalize();
const [isMobileSelectionModeEnabled] = useOnyx(ONYXKEYS.MOBILE_SELECTION_MODE);
const [isMobileSelectionModeEnabled] = useOnyx(ONYXKEYS.RAM_ONLY_MOBILE_SELECTION_MODE);
const [introSelected] = useOnyx(ONYXKEYS.NVP_INTRO_SELECTED);
const [betas] = useOnyx(ONYXKEYS.BETAS);
const [visibleColumns] = useOnyx(ONYXKEYS.FORMS.SEARCH_ADVANCED_FILTERS_FORM, {selector: columnsSelector});
Expand Down
2 changes: 1 addition & 1 deletion src/hooks/useMobileSelectionMode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import useOnyx from './useOnyx';
import usePrevious from './usePrevious';

export default function useMobileSelectionMode(onTurnOffSelectionMode = () => {}) {
const [isSelectionModeEnabled = false] = useOnyx(ONYXKEYS.MOBILE_SELECTION_MODE, {initWithStoredValues: false});
const [isSelectionModeEnabled = false] = useOnyx(ONYXKEYS.RAM_ONLY_MOBILE_SELECTION_MODE);
const initialSelectionModeValueRef = useRef(isSelectionModeEnabled);
const prevIsSelectionModeEnabled = usePrevious(isSelectionModeEnabled);

Expand Down
2 changes: 1 addition & 1 deletion src/hooks/useSearchBackPress/index.android.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import ONYXKEYS from '@src/ONYXKEYS';
import type UseSearchBackPress from './types';

const useSearchBackPress: UseSearchBackPress = ({onClearSelection, onNavigationCallBack}) => {
const [selectionMode] = useOnyx(ONYXKEYS.MOBILE_SELECTION_MODE);
const [selectionMode] = useOnyx(ONYXKEYS.RAM_ONLY_MOBILE_SELECTION_MODE);
useFocusEffect(
useCallback(() => {
const onBackPress = () => {
Expand Down
2 changes: 1 addition & 1 deletion src/languages/IntlStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import type zhHans from './zh-hans';
// This function was added here to avoid circular dependencies
function setAreTranslationsLoading(areTranslationsLoading: boolean) {
// eslint-disable-next-line rulesdir/prefer-actions-set-data
Onyx.set(ONYXKEYS.ARE_TRANSLATIONS_LOADING, areTranslationsLoading);
Onyx.set(ONYXKEYS.RAM_ONLY_ARE_TRANSLATIONS_LOADING, areTranslationsLoading);
}

class IntlStore {
Expand Down
2 changes: 1 addition & 1 deletion src/libs/PersonalDetailsUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
let personalDetails: Array<PersonalDetails | null> = [];
let allPersonalDetails: OnyxEntry<PersonalDetailsList> = {};
let emailToPersonalDetailsCache: Record<string, PersonalDetails> = {};
Onyx.connect({

Check warning on line 26 in src/libs/PersonalDetailsUtils.ts

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

Onyx.connect() is deprecated. Use useOnyx() hook instead and pass the data as parameters to a pure function
key: ONYXKEYS.PERSONAL_DETAILS_LIST,
callback: (val) => {
personalDetails = Object.values(val ?? {});
Expand All @@ -40,8 +40,8 @@
let hiddenTranslation = '';
let youTranslation = '';

Onyx.connect({

Check warning on line 43 in src/libs/PersonalDetailsUtils.ts

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

Onyx.connect() is deprecated. Use useOnyx() hook instead and pass the data as parameters to a pure function
key: ONYXKEYS.ARE_TRANSLATIONS_LOADING,
key: ONYXKEYS.RAM_ONLY_ARE_TRANSLATIONS_LOADING,
callback: (value) => {
if (value ?? true) {
return;
Expand Down
3 changes: 1 addition & 2 deletions src/libs/ReportUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
import type PolicyData from '@hooks/usePolicyData/types';
import type {PolicyTagList} from '@pages/workspace/tags/types';
import type {ThemeColors} from '@styles/theme/types';
import {canApproveIOU, canIOUBePaid, canSubmitReport, getIOUReportActionWithBadge} from '@userActions/IOU/ReportWorkflow';

Check warning on line 27 in src/libs/ReportUtils.ts

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

Unexpected subpath import via alias '@userActions/IOU/ReportWorkflow'. Use './actions/IOU/ReportWorkflow' instead
import type {IOUAction, IOUType, OnboardingAccounting} from '@src/CONST';
import CONST, {TASK_TO_FEATURE} from '@src/CONST';
import type {ParentNavigationSummaryParams} from '@src/languages/params';
Expand Down Expand Up @@ -1035,7 +1035,7 @@
};

let conciergeReportIDOnyxConnect: OnyxEntry<string>;
Onyx.connect({

Check warning on line 1038 in src/libs/ReportUtils.ts

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

Onyx.connect() is deprecated. Use useOnyx() hook instead and pass the data as parameters to a pure function
key: ONYXKEYS.CONCIERGE_REPORT_ID,
callback: (value) => {
conciergeReportIDOnyxConnect = value;
Expand All @@ -1043,7 +1043,7 @@
});

const defaultAvatarBuildingIconTestID = 'SvgDefaultAvatarBuilding Icon';
Onyx.connect({

Check warning on line 1046 in src/libs/ReportUtils.ts

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

Onyx.connect() is deprecated. Use useOnyx() hook instead and pass the data as parameters to a pure function
key: ONYXKEYS.SESSION,
callback: (value) => {
// When signed out, val is undefined
Expand All @@ -1061,7 +1061,7 @@
let allPersonalDetails: OnyxEntry<PersonalDetailsList>;
let allPersonalDetailLogins: string[];
let currentUserPersonalDetails: OnyxEntry<PersonalDetails>;
Onyx.connect({

Check warning on line 1064 in src/libs/ReportUtils.ts

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

Onyx.connect() is deprecated. Use useOnyx() hook instead and pass the data as parameters to a pure function
key: ONYXKEYS.PERSONAL_DETAILS_LIST,
callback: (value) => {
if (deprecatedCurrentUserAccountID) {
Expand All @@ -1073,7 +1073,7 @@
});

let allReportsDraft: OnyxCollection<Report>;
Onyx.connect({

Check warning on line 1076 in src/libs/ReportUtils.ts

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

Onyx.connect() is deprecated. Use useOnyx() hook instead and pass the data as parameters to a pure function
key: ONYXKEYS.COLLECTION.REPORT_DRAFT,
waitForCollectionCallback: true,
callback: (value) => (allReportsDraft = value),
Expand All @@ -1081,7 +1081,7 @@

let allPolicies: OnyxCollection<Policy>;
let policiesArray: Policy[] = [];
Onyx.connect({

Check warning on line 1084 in src/libs/ReportUtils.ts

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

Onyx.connect() is deprecated. Use useOnyx() hook instead and pass the data as parameters to a pure function
key: ONYXKEYS.COLLECTION.POLICY,
waitForCollectionCallback: true,
callback: (value) => {
Expand All @@ -1091,7 +1091,7 @@
});

let allPolicyDrafts: OnyxCollection<Policy>;
Onyx.connect({

Check warning on line 1094 in src/libs/ReportUtils.ts

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

Onyx.connect() is deprecated. Use useOnyx() hook instead and pass the data as parameters to a pure function
key: ONYXKEYS.COLLECTION.POLICY_DRAFTS,
waitForCollectionCallback: true,
callback: (value) => (allPolicyDrafts = value),
Expand All @@ -1099,7 +1099,7 @@

let deprecatedAllReports: OnyxCollection<Report>;
let deprecatedReportsByPolicyID: ReportByPolicyMap;
Onyx.connect({

Check warning on line 1102 in src/libs/ReportUtils.ts

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

Onyx.connect() is deprecated. Use useOnyx() hook instead and pass the data as parameters to a pure function
key: ONYXKEYS.COLLECTION.REPORT,
waitForCollectionCallback: true,
callback: (value) => {
Expand Down Expand Up @@ -1245,8 +1245,7 @@
let unavailableTranslation = '';

Onyx.connect({
key: ONYXKEYS.ARE_TRANSLATIONS_LOADING,
initWithStoredValues: false,
key: ONYXKEYS.RAM_ONLY_ARE_TRANSLATIONS_LOADING,
callback: (value) => {
if (value ?? true) {
return;
Expand Down
9 changes: 4 additions & 5 deletions src/libs/actions/App.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,8 @@ Onyx.connectWithoutView({
// `useOnyx` would trigger extra rerenders without affecting the View, so `Onyx.connectWithoutView` is used instead
let isSidebarLoaded: boolean | undefined;
Onyx.connectWithoutView({
key: ONYXKEYS.IS_SIDEBAR_LOADED,
key: ONYXKEYS.RAM_ONLY_IS_SIDEBAR_LOADED,
callback: (val) => (isSidebarLoaded = val),
initWithStoredValues: false,
});

// `isUsingImportedState` is used in `openApp`, `reconnectApp`, and `clearOnyxAndResetApp` to prevent API calls when using imported state.
Expand Down Expand Up @@ -122,9 +121,9 @@ Onyx.connectWithoutView({

const KEYS_TO_PRESERVE: OnyxKey[] = [
ONYXKEYS.ACCOUNT,
ONYXKEYS.IS_CHECKING_PUBLIC_ROOM,
ONYXKEYS.IS_LOADING_APP,
ONYXKEYS.IS_SIDEBAR_LOADED,
ONYXKEYS.RAM_ONLY_IS_SIDEBAR_LOADED,
ONYXKEYS.IS_CHECKING_PUBLIC_ROOM,
ONYXKEYS.MODAL,
ONYXKEYS.NETWORK,
ONYXKEYS.SESSION,
Expand Down Expand Up @@ -223,7 +222,7 @@ function setSidebarLoaded() {
return;
}

Onyx.set(ONYXKEYS.IS_SIDEBAR_LOADED, true);
Onyx.set(ONYXKEYS.RAM_ONLY_IS_SIDEBAR_LOADED, true);
}

function setAppLoading(isLoading: boolean) {
Expand Down
18 changes: 9 additions & 9 deletions src/libs/actions/Card.ts
Original file line number Diff line number Diff line change
Expand Up @@ -749,7 +749,7 @@ function getCardDefaultName(userName?: string) {
}

function setIssueNewCardStepAndData({data, isEditing, step, policyID, isChangeAssigneeDisabled}: IssueNewCardFlowData) {
Onyx.merge(`${ONYXKEYS.COLLECTION.ISSUE_NEW_EXPENSIFY_CARD}${policyID}`, {
Onyx.merge(`${ONYXKEYS.COLLECTION.RAM_ONLY_ISSUE_NEW_EXPENSIFY_CARD}${policyID}`, {
data,
isEditing,
currentStep: step,
Expand All @@ -765,7 +765,7 @@ function setDraftInviteAccountID(assigneeEmail: string | undefined, assigneeAcco
}

function clearIssueNewCardFlow(policyID: string | undefined) {
Onyx.set(`${ONYXKEYS.COLLECTION.ISSUE_NEW_EXPENSIFY_CARD}${policyID}`, {
Onyx.set(`${ONYXKEYS.COLLECTION.RAM_ONLY_ISSUE_NEW_EXPENSIFY_CARD}${policyID}`, {
currentStep: null,
data: {},
isSuccessful: false,
Expand All @@ -778,7 +778,7 @@ function clearIssueNewCardFormData() {
}

function clearIssueNewCardError(policyID: string | undefined) {
Onyx.merge(`${ONYXKEYS.COLLECTION.ISSUE_NEW_EXPENSIFY_CARD}${policyID}`, {errors: null});
Onyx.merge(`${ONYXKEYS.COLLECTION.RAM_ONLY_ISSUE_NEW_EXPENSIFY_CARD}${policyID}`, {errors: null});
}

function buildCardListUpdates(workspaceAccountID: number, cardID: number, cardUpdateData: CardListUpdateData, shouldUpdateCardList: boolean): CardOnyxUpdate[] {
Expand Down Expand Up @@ -1368,10 +1368,10 @@ function issueExpensifyCard(

const {assigneeEmail, limit, limitType, cardTitle, cardType, validFrom, validThru} = data;

const optimisticData: Array<OnyxUpdate<typeof ONYXKEYS.COLLECTION.ISSUE_NEW_EXPENSIFY_CARD>> = [
const optimisticData: Array<OnyxUpdate<typeof ONYXKEYS.COLLECTION.RAM_ONLY_ISSUE_NEW_EXPENSIFY_CARD>> = [
{
onyxMethod: Onyx.METHOD.MERGE,
key: `${ONYXKEYS.COLLECTION.ISSUE_NEW_EXPENSIFY_CARD}${policyID}`,
key: `${ONYXKEYS.COLLECTION.RAM_ONLY_ISSUE_NEW_EXPENSIFY_CARD}${policyID}`,
value: {
isLoading: true,
errors: null,
Expand All @@ -1380,21 +1380,21 @@ function issueExpensifyCard(
},
];

const successData: Array<OnyxUpdate<typeof ONYXKEYS.COLLECTION.ISSUE_NEW_EXPENSIFY_CARD>> = [
const successData: Array<OnyxUpdate<typeof ONYXKEYS.COLLECTION.RAM_ONLY_ISSUE_NEW_EXPENSIFY_CARD>> = [
{
onyxMethod: Onyx.METHOD.MERGE,
key: `${ONYXKEYS.COLLECTION.ISSUE_NEW_EXPENSIFY_CARD}${policyID}`,
key: `${ONYXKEYS.COLLECTION.RAM_ONLY_ISSUE_NEW_EXPENSIFY_CARD}${policyID}`,
value: {
isLoading: false,
isSuccessful: true,
},
},
];

const failureData: Array<OnyxUpdate<typeof ONYXKEYS.COLLECTION.ISSUE_NEW_EXPENSIFY_CARD>> = [
const failureData: Array<OnyxUpdate<typeof ONYXKEYS.COLLECTION.RAM_ONLY_ISSUE_NEW_EXPENSIFY_CARD>> = [
{
onyxMethod: Onyx.METHOD.MERGE,
key: `${ONYXKEYS.COLLECTION.ISSUE_NEW_EXPENSIFY_CARD}${policyID}`,
key: `${ONYXKEYS.COLLECTION.RAM_ONLY_ISSUE_NEW_EXPENSIFY_CARD}${policyID}`,
value: {
isLoading: false,
errors: ErrorUtils.getMicroSecondOnyxErrorWithTranslationKey('common.genericErrorMessage'),
Expand Down
4 changes: 2 additions & 2 deletions src/libs/actions/Delegate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ const KEYS_TO_PRESERVE_DELEGATE_ACCESS = [
ONYXKEYS.NVP_TRY_FOCUS_MODE,
ONYXKEYS.PREFERRED_THEME,
ONYXKEYS.NVP_PREFERRED_LOCALE,
ONYXKEYS.ARE_TRANSLATIONS_LOADING,
ONYXKEYS.RAM_ONLY_ARE_TRANSLATIONS_LOADING,
ONYXKEYS.SESSION,
ONYXKEYS.STASHED_SESSION,
ONYXKEYS.HAS_LOADED_APP,
Expand All @@ -33,7 +33,7 @@ const KEYS_TO_PRESERVE_DELEGATE_ACCESS = [

// We need to preserve the sidebar loaded state since we never unmount the sidebar when connecting as a delegate
// This allows the report screen to load correctly when the delegate token expires and the delegate is returned to their original account.
ONYXKEYS.IS_SIDEBAR_LOADED,
ONYXKEYS.RAM_ONLY_IS_SIDEBAR_LOADED,
ONYXKEYS.NETWORK,
ONYXKEYS.SHOULD_USE_STAGING_SERVER,
ONYXKEYS.IS_DEBUG_MODE_ENABLED,
Expand Down
4 changes: 2 additions & 2 deletions src/libs/actions/MobileSelectionMode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@ import Onyx from 'react-native-onyx';
import ONYXKEYS from '@src/ONYXKEYS';

const turnOnMobileSelectionMode = () => {
Onyx.merge(ONYXKEYS.MOBILE_SELECTION_MODE, true);
Onyx.merge(ONYXKEYS.RAM_ONLY_MOBILE_SELECTION_MODE, true);
};

const turnOffMobileSelectionMode = () => {
Onyx.merge(ONYXKEYS.MOBILE_SELECTION_MODE, false);
Onyx.merge(ONYXKEYS.RAM_ONLY_MOBILE_SELECTION_MODE, false);
};

export {turnOnMobileSelectionMode, turnOffMobileSelectionMode};
3 changes: 1 addition & 2 deletions src/libs/actions/OnyxDerived/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -115,8 +115,7 @@ function init() {
} else if (dependencyOnyxKey === ONYXKEYS.NVP_PREFERRED_LOCALE) {
// Special case for locale, we want to recompute derived values when the locale change actually loads.
Onyx.connectWithoutView({
key: ONYXKEYS.ARE_TRANSLATIONS_LOADING,
initWithStoredValues: false,
key: ONYXKEYS.RAM_ONLY_ARE_TRANSLATIONS_LOADING,
callback: (value) => {
if (value ?? true) {
Log.info(`[OnyxDerived] translations are still loading, not recomputing derived value for ${key}`);
Expand Down
4 changes: 2 additions & 2 deletions src/libs/actions/QueuedOnyxUpdates.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,12 @@ function flushQueue(): Promise<void> {
ONYXKEYS.NVP_TRY_FOCUS_MODE,
ONYXKEYS.PREFERRED_THEME,
ONYXKEYS.NVP_PREFERRED_LOCALE,
ONYXKEYS.ARE_TRANSLATIONS_LOADING,
ONYXKEYS.RAM_ONLY_ARE_TRANSLATIONS_LOADING,
ONYXKEYS.SESSION,
ONYXKEYS.IS_LOADING_APP,
ONYXKEYS.HAS_LOADED_APP,
ONYXKEYS.CREDENTIALS,
ONYXKEYS.IS_SIDEBAR_LOADED,
ONYXKEYS.RAM_ONLY_IS_SIDEBAR_LOADED,
ONYXKEYS.ACCOUNT,
ONYXKEYS.IS_CHECKING_PUBLIC_ROOM,
ONYXKEYS.MODAL,
Expand Down
4 changes: 2 additions & 2 deletions src/libs/actions/Session/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,7 @@ const KEYS_TO_PRESERVE_SUPPORTAL = [
ONYXKEYS.NVP_TRY_FOCUS_MODE,
ONYXKEYS.PREFERRED_THEME,
ONYXKEYS.NVP_PREFERRED_LOCALE,
ONYXKEYS.ARE_TRANSLATIONS_LOADING,
ONYXKEYS.RAM_ONLY_ARE_TRANSLATIONS_LOADING,
ONYXKEYS.SESSION,
ONYXKEYS.STASHED_SESSION,
ONYXKEYS.HAS_LOADED_APP,
Expand All @@ -309,7 +309,7 @@ const KEYS_TO_PRESERVE_SUPPORTAL = [

// We need to preserve the sidebar loaded state since we never unmount the sidebar when connecting as a delegate
// This allows the report screen to load correctly when the delegate token expires and the delegate is returned to their original account.
ONYXKEYS.IS_SIDEBAR_LOADED,
ONYXKEYS.RAM_ONLY_IS_SIDEBAR_LOADED,
ONYXKEYS.NETWORK,
ONYXKEYS.SHOULD_USE_STAGING_SERVER,
ONYXKEYS.IS_DEBUG_MODE_ENABLED,
Expand Down
2 changes: 1 addition & 1 deletion src/libs/actions/SignInRedirect.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ function clearStorageAndRedirect(errorMessage?: string): Promise<void> {
// flashes of unwanted default state.
const keysToPreserve: OnyxKey[] = [];
keysToPreserve.push(ONYXKEYS.NVP_PREFERRED_LOCALE);
keysToPreserve.push(ONYXKEYS.ARE_TRANSLATIONS_LOADING);
keysToPreserve.push(ONYXKEYS.RAM_ONLY_ARE_TRANSLATIONS_LOADING);
keysToPreserve.push(ONYXKEYS.PREFERRED_THEME);
keysToPreserve.push(ONYXKEYS.ACTIVE_CLIENTS);
keysToPreserve.push(ONYXKEYS.DEVICE_ID);
Expand Down
22 changes: 21 additions & 1 deletion src/libs/actions/Wallet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,27 @@ function openInitialSettingsPage() {
* Fetches data when the user opens the EnablePaymentsPage
*/
function openEnablePaymentsPage() {
API.read(READ_COMMANDS.OPEN_ENABLE_PAYMENTS_PAGE, null);
const optimisticData: Array<OnyxUpdate<typeof ONYXKEYS.USER_WALLET>> = [
{
onyxMethod: Onyx.METHOD.MERGE,
key: ONYXKEYS.USER_WALLET,
value: {
isLoading: true,

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Avoid pre-populating USER_WALLET during OpenEnablePayments

Merging isLoading: true into ONYXKEYS.USER_WALLET before the API response makes the wallet object non-empty immediately, which breaks callers that use emptiness as their load gate (notably src/pages/EnablePayments/EnablePayments.tsx, which only fetches while isEmptyObject(userWallet) and shows a loader only for empty wallets). In that route, this change can render the flow with incomplete/stale wallet data before the read completes, and if the read fails it can leave {isLoading:false} in Onyx so the page neither shows the loading state nor retries.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we already addressed all this in https://github.com/callstack-internal/Expensify-App/blob/4e613515f5014fe413befa6a20fa59c66a53cc98/src/pages/EnablePayments/EnablePaymentsPage.tsx and the bot likely missed that we made changes in EnablePaymentsPage.tsx

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@fabioh8010 I was also confused at first but there is one more component named EnablePayments.tsx. Or am I missing something?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh you are right, fixed here

},
},
];

const finallyData: Array<OnyxUpdate<typeof ONYXKEYS.USER_WALLET>> = [
{
onyxMethod: Onyx.METHOD.MERGE,
key: ONYXKEYS.USER_WALLET,
value: {
isLoading: false,
},
},
];

API.read(READ_COMMANDS.OPEN_ENABLE_PAYMENTS_PAGE, null, {optimisticData, finallyData});
}

function updateCurrentStep(currentStep: ValueOf<typeof CONST.WALLET.STEP> | null) {
Expand Down
8 changes: 3 additions & 5 deletions src/pages/EnablePayments/EnablePayments.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,11 @@ function EnablePaymentsPage() {
return;
}

if (isEmptyObject(userWallet)) {
openEnablePaymentsPage();
}
}, [isOffline, userWallet]);
openEnablePaymentsPage();
}, [isOffline]);

const isUserWalletEmpty = isEmptyObject(userWallet);
if (isUserWalletEmpty) {
if (isUserWalletEmpty || userWallet?.isLoading) {
const reasonAttributes: SkeletonSpanReasonAttributes = {
context: 'EnablePaymentsPage',
isUserWalletEmpty,
Expand Down
Loading
Loading