From 52ab1eb1742df538815c6573456d54a213a7a012 Mon Sep 17 00:00:00 2001 From: Povilas Zirgulis Date: Tue, 15 Apr 2025 11:08:13 +0300 Subject: [PATCH 1/5] remove unused code from components,hooks, actions folders --- .../HTMLEngineProvider/htmlEngineUtils.ts | 2 +- src/components/InputBlurContext/index.tsx | 2 +- src/components/MultiGestureCanvas/index.tsx | 4 +- src/components/OptionListContextProvider.tsx | 2 +- .../VideoPlayerContexts/PlaybackContext.tsx | 2 +- src/components/withEnvironment.tsx | 26 +--- .../UpdatePolicyConnectionConfigParams.ts | 9 -- src/libs/API/parameters/index.ts | 1 - src/libs/API/types.ts | 2 - src/libs/actions/BankAccounts.ts | 6 - .../actions/CachedPDFPaths/index.native.ts | 8 +- src/libs/actions/CachedPDFPaths/index.ts | 6 +- src/libs/actions/CachedPDFPaths/types.ts | 3 +- src/libs/actions/connections/index.ts | 113 +----------------- 14 files changed, 14 insertions(+), 172 deletions(-) delete mode 100644 src/libs/API/parameters/UpdatePolicyConnectionConfigParams.ts diff --git a/src/components/HTMLEngineProvider/htmlEngineUtils.ts b/src/components/HTMLEngineProvider/htmlEngineUtils.ts index f94339820fbf..24f6e4bbc81b 100644 --- a/src/components/HTMLEngineProvider/htmlEngineUtils.ts +++ b/src/components/HTMLEngineProvider/htmlEngineUtils.ts @@ -71,4 +71,4 @@ function isDeletedNode(tnode: TNode): boolean { return 'textDecorationLine' in parentStyle && parentStyle.textDecorationLine === 'line-through'; } -export {computeEmbeddedMaxWidth, isChildOfComment, isCommentTag, isChildOfH1, isDeletedNode, isChildOfTaskTitle}; +export {computeEmbeddedMaxWidth, isChildOfComment, isChildOfH1, isDeletedNode, isChildOfTaskTitle}; diff --git a/src/components/InputBlurContext/index.tsx b/src/components/InputBlurContext/index.tsx index 949c7029d849..06d76cbd4f56 100644 --- a/src/components/InputBlurContext/index.tsx +++ b/src/components/InputBlurContext/index.tsx @@ -29,4 +29,4 @@ function useInputBlurContext() { return useContext(InputBlurContext); } -export {InputBlurContext, useInputBlurContext, InputBlurContextProvider}; +export {useInputBlurContext, InputBlurContextProvider}; diff --git a/src/components/MultiGestureCanvas/index.tsx b/src/components/MultiGestureCanvas/index.tsx index 7e5c5d2365d8..7a21eafa0a08 100644 --- a/src/components/MultiGestureCanvas/index.tsx +++ b/src/components/MultiGestureCanvas/index.tsx @@ -10,7 +10,7 @@ import Animated, {cancelAnimation, runOnUI, useAnimatedReaction, useAnimatedStyl import useStyleUtils from '@hooks/useStyleUtils'; import useThemeStyles from '@hooks/useThemeStyles'; import type ChildrenProps from '@src/types/utils/ChildrenProps'; -import {DEFAULT_ZOOM_RANGE, SPRING_CONFIG, ZOOM_RANGE_BOUNCE_FACTORS} from './constants'; +import {DEFAULT_ZOOM_RANGE, SPRING_CONFIG} from './constants'; import type {CanvasSize, ContentSize, OnScaleChangedCallback, OnSwipeDownCallback, OnTapCallback, ZoomRange} from './types'; import usePanGesture from './usePanGesture'; import usePinchGesture from './usePinchGesture'; @@ -289,5 +289,5 @@ function MultiGestureCanvas({ MultiGestureCanvas.displayName = 'MultiGestureCanvas'; export default MultiGestureCanvas; -export {DEFAULT_ZOOM_RANGE, ZOOM_RANGE_BOUNCE_FACTORS}; +export {DEFAULT_ZOOM_RANGE}; export type {MultiGestureCanvasProps}; diff --git a/src/components/OptionListContextProvider.tsx b/src/components/OptionListContextProvider.tsx index 48595608c57f..3665e676fb94 100644 --- a/src/components/OptionListContextProvider.tsx +++ b/src/components/OptionListContextProvider.tsx @@ -201,4 +201,4 @@ const useOptionsList = (options?: {shouldInitialize: boolean}) => { export default OptionsListContextProvider; -export {useOptionsListContext, useOptionsList, OptionsListContext}; +export {useOptionsList, OptionsListContext}; diff --git a/src/components/VideoPlayerContexts/PlaybackContext.tsx b/src/components/VideoPlayerContexts/PlaybackContext.tsx index 33076b5521a1..9b548ef06f89 100644 --- a/src/components/VideoPlayerContexts/PlaybackContext.tsx +++ b/src/components/VideoPlayerContexts/PlaybackContext.tsx @@ -247,4 +247,4 @@ function usePlaybackContext() { PlaybackContextProvider.displayName = 'PlaybackContextProvider'; -export {Context as PlaybackContext, PlaybackContextProvider, usePlaybackContext}; +export {PlaybackContextProvider, usePlaybackContext}; diff --git a/src/components/withEnvironment.tsx b/src/components/withEnvironment.tsx index bd57ed5da696..bd3aef395ba3 100644 --- a/src/components/withEnvironment.tsx +++ b/src/components/withEnvironment.tsx @@ -1,8 +1,7 @@ -import type {ComponentType, ForwardedRef, ReactElement, ReactNode, RefAttributes} from 'react'; -import React, {createContext, forwardRef, useContext, useEffect, useMemo, useState} from 'react'; +import type {ReactElement, ReactNode} from 'react'; +import React, {createContext, useEffect, useMemo, useState} from 'react'; import type {ValueOf} from 'type-fest'; import * as Environment from '@libs/Environment/Environment'; -import getComponentDisplayName from '@libs/getComponentDisplayName'; import CONST from '@src/CONST'; type EnvironmentProviderProps = { @@ -47,26 +46,5 @@ function EnvironmentProvider({children}: EnvironmentProviderProps): ReactElement EnvironmentProvider.displayName = 'EnvironmentProvider'; -export default function withEnvironment( - WrappedComponent: ComponentType>, -): (props: Omit & React.RefAttributes) => ReactElement | null { - function WithEnvironment(props: Omit, ref: ForwardedRef): ReactElement { - const {environment, environmentURL} = useContext(EnvironmentContext); - return ( - - ); - } - - WithEnvironment.displayName = `withEnvironment(${getComponentDisplayName(WrappedComponent)})`; - - return forwardRef(WithEnvironment); -} - export {EnvironmentContext, EnvironmentProvider}; export type {EnvironmentContextValue}; diff --git a/src/libs/API/parameters/UpdatePolicyConnectionConfigParams.ts b/src/libs/API/parameters/UpdatePolicyConnectionConfigParams.ts deleted file mode 100644 index 111674b8ffb6..000000000000 --- a/src/libs/API/parameters/UpdatePolicyConnectionConfigParams.ts +++ /dev/null @@ -1,9 +0,0 @@ -type UpdatePolicyConnectionConfigParams = { - policyID: string; - connectionName: string; - settingName: string; - settingValue: string; - idempotencyKey: string; -}; - -export default UpdatePolicyConnectionConfigParams; diff --git a/src/libs/API/parameters/index.ts b/src/libs/API/parameters/index.ts index a70093c83b11..01cfa138476e 100644 --- a/src/libs/API/parameters/index.ts +++ b/src/libs/API/parameters/index.ts @@ -229,7 +229,6 @@ export type {default as SetPolicyForeignCurrencyDefaultParams} from './SetPolicy export type {default as SetPolicyCurrencyDefaultParams} from './SetPolicyCurrencyDefaultParams'; export type {default as UpdateQuickbooksOnlineGenericTypeParams} from './UpdateQuickbooksOnlineGenericTypeParams'; export type {default as UpdateQuickbooksDesktopGenericTypeParams} from './UpdateQuickbooksDesktopGenericTypeParams'; -export type {default as UpdatePolicyConnectionConfigParams} from './UpdatePolicyConnectionConfigParams'; export type {default as UpdateManyPolicyConnectionConfigurationsParams} from './UpdateManyPolicyConnectionConfigurationsParams'; export type {default as RemovePolicyConnectionParams} from './RemovePolicyConnectionParams'; export type {default as RenamePolicyTaxParams} from './RenamePolicyTaxParams'; diff --git a/src/libs/API/types.ts b/src/libs/API/types.ts index a96b93931949..4757b4052e06 100644 --- a/src/libs/API/types.ts +++ b/src/libs/API/types.ts @@ -255,7 +255,6 @@ const WRITE_COMMANDS = { ACCEPT_JOIN_REQUEST: 'AcceptJoinRequest', DECLINE_JOIN_REQUEST: 'DeclineJoinRequest', CREATE_POLICY_TAX: 'CreatePolicyTax', - UPDATE_POLICY_CONNECTION_CONFIG: 'UpdatePolicyConnectionConfiguration', UPDATE_QUICKBOOKS_ONLINE_ENABLE_NEW_CATEGORIES: 'UpdateQuickbooksOnlineEnableNewCategories', UPDATE_QUICKBOOKS_ONLINE_AUTO_CREATE_VENDOR: 'UpdateQuickbooksOnlineAutoCreateVendor', UPDATE_QUICKBOOKS_ONLINE_REIMBURSABLE_EXPENSES_ACCOUNT: 'UpdateQuickbooksOnlineReimbursableExpensesAccount', @@ -768,7 +767,6 @@ type WriteCommandParameters = { [WRITE_COMMANDS.UPDATE_QUICKBOOKS_DESKTOP_SYNC_CUSTOMERS]: Parameters.UpdateQuickbooksDesktopGenericTypeParams; [WRITE_COMMANDS.UPDATE_QUICKBOOKS_DESKTOP_SYNC_ITEMS]: Parameters.UpdateQuickbooksDesktopGenericTypeParams; [WRITE_COMMANDS.UPDATE_QUICKBOOKS_DESKTOP_EXPORT]: Parameters.UpdateQuickbooksDesktopGenericTypeParams; - [WRITE_COMMANDS.UPDATE_POLICY_CONNECTION_CONFIG]: Parameters.UpdatePolicyConnectionConfigParams; [WRITE_COMMANDS.UPDATE_MANY_POLICY_CONNECTION_CONFIGS]: Parameters.UpdateManyPolicyConnectionConfigurationsParams; [WRITE_COMMANDS.REMOVE_POLICY_CONNECTION]: Parameters.RemovePolicyConnectionParams; [WRITE_COMMANDS.UPDATE_POLICY_DISTANCE_RATE_VALUE]: Parameters.UpdatePolicyDistanceRateValueParams; diff --git a/src/libs/actions/BankAccounts.ts b/src/libs/actions/BankAccounts.ts index 096c296be8af..e92c69b87b62 100644 --- a/src/libs/actions/BankAccounts.ts +++ b/src/libs/actions/BankAccounts.ts @@ -546,10 +546,6 @@ function saveCorpayOnboardingBeneficialOwners(parameters: SaveCorpayOnboardingBe return API.write(WRITE_COMMANDS.SAVE_CORPAY_ONBOARDING_BENEFICIAL_OWNER, parameters, onyxData); } -function clearReimbursementAccount() { - Onyx.set(ONYXKEYS.REIMBURSEMENT_ACCOUNT, null); -} - function clearCorpayBankAccountFields() { Onyx.set(ONYXKEYS.CORPAY_FIELDS, null); } @@ -819,7 +815,6 @@ export { addPersonalBankAccount, clearOnfidoToken, clearPersonalBankAccount, - clearPlaid, setPlaidEvent, openPlaidView, connectBankAccountManually, @@ -829,7 +824,6 @@ export { handlePlaidError, setPersonalBankAccountContinueKYCOnSuccess, openPersonalBankAccountSetupView, - clearReimbursementAccount, openReimbursementAccountPage, updateBeneficialOwnersForBankAccount, updateCompanyInformationForBankAccount, diff --git a/src/libs/actions/CachedPDFPaths/index.native.ts b/src/libs/actions/CachedPDFPaths/index.native.ts index 09203995e9a1..5f3b52c94be9 100644 --- a/src/libs/actions/CachedPDFPaths/index.native.ts +++ b/src/libs/actions/CachedPDFPaths/index.native.ts @@ -1,7 +1,7 @@ import {exists, unlink} from 'react-native-fs'; import Onyx from 'react-native-onyx'; import ONYXKEYS from '@src/ONYXKEYS'; -import type {Add, Clear, ClearAll, ClearByKey} from './types'; +import type {Add, Clear, ClearByKey} from './types'; /* * We need to save the paths of PDF files so we can delete them later. @@ -40,8 +40,4 @@ const clearByKey: ClearByKey = (id: string) => { clear(pdfPaths[id] ?? '').then(() => Onyx.merge(ONYXKEYS.CACHED_PDF_PATHS, {[id]: null})); }; -const clearAll: ClearAll = () => { - Promise.all(Object.values(pdfPaths).map(clear)).then(() => Onyx.merge(ONYXKEYS.CACHED_PDF_PATHS, {})); -}; - -export {add, clearByKey, clearAll}; +export {add, clearByKey}; diff --git a/src/libs/actions/CachedPDFPaths/index.ts b/src/libs/actions/CachedPDFPaths/index.ts index 3cac21bf3c25..b890e243195e 100644 --- a/src/libs/actions/CachedPDFPaths/index.ts +++ b/src/libs/actions/CachedPDFPaths/index.ts @@ -1,9 +1,7 @@ -import type {Add, ClearAll, ClearByKey} from './types'; +import type {Add, ClearByKey} from './types'; const add: Add = () => Promise.resolve(); const clearByKey: ClearByKey = () => {}; -const clearAll: ClearAll = () => {}; - -export {add, clearByKey, clearAll}; +export {add, clearByKey}; diff --git a/src/libs/actions/CachedPDFPaths/types.ts b/src/libs/actions/CachedPDFPaths/types.ts index 728759daaa98..66a579cbe852 100644 --- a/src/libs/actions/CachedPDFPaths/types.ts +++ b/src/libs/actions/CachedPDFPaths/types.ts @@ -1,6 +1,5 @@ type Add = (id: string, path: string) => Promise; type Clear = (path: string) => Promise; -type ClearAll = () => void; type ClearByKey = (id: string) => void; -export type {Add, Clear, ClearAll, ClearByKey}; +export type {Add, Clear, ClearByKey}; diff --git a/src/libs/actions/connections/index.ts b/src/libs/actions/connections/index.ts index c0215e91838a..a2cd42b258bd 100644 --- a/src/libs/actions/connections/index.ts +++ b/src/libs/actions/connections/index.ts @@ -1,30 +1,19 @@ import {differenceInMinutes, isValid, parseISO} from 'date-fns'; -import isObject from 'lodash/isObject'; import type {OnyxEntry, OnyxUpdate} from 'react-native-onyx'; import Onyx from 'react-native-onyx'; import * as API from '@libs/API'; -import type { - RemovePolicyConnectionParams, - SyncPolicyToQuickbooksDesktopParams, - UpdateManyPolicyConnectionConfigurationsParams, - UpdatePolicyConnectionConfigParams, -} from '@libs/API/parameters'; +import type {RemovePolicyConnectionParams, SyncPolicyToQuickbooksDesktopParams, UpdateManyPolicyConnectionConfigurationsParams} from '@libs/API/parameters'; import {READ_COMMANDS, WRITE_COMMANDS} from '@libs/API/types'; import * as ErrorUtils from '@libs/ErrorUtils'; import * as PolicyUtils from '@libs/PolicyUtils'; import CONST from '@src/CONST'; import ONYXKEYS from '@src/ONYXKEYS'; -import type * as OnyxCommon from '@src/types/onyx/OnyxCommon'; import type {ConnectionName, Connections, PolicyConnectionName, PolicyConnectionSyncProgress} from '@src/types/onyx/Policy'; import type Policy from '@src/types/onyx/Policy'; import {isEmptyObject} from '@src/types/utils/EmptyObject'; type ConnectionNameExceptNetSuite = Exclude; -type Nullable = { - [P in keyof T]: T[P] | null; -}; - function removePolicyConnection(policyID: string, connectionName: PolicyConnectionName) { const optimisticData: OnyxUpdate[] = [ { @@ -89,105 +78,6 @@ function removePolicyConnection(policyID: string, connectionName: PolicyConnecti API.write(WRITE_COMMANDS.REMOVE_POLICY_CONNECTION, parameters, {optimisticData, successData, failureData}); } -function createPendingFields( - settingName: TSettingName, - settingValue: Partial, - pendingValue: OnyxCommon.PendingAction, -) { - if (!isObject(settingValue)) { - return {[settingName]: pendingValue}; - } - - return Object.keys(settingValue).reduce>((acc, setting) => { - acc[setting] = pendingValue; - return acc; - }, {}); -} - -function createErrorFields( - settingName: TSettingName, - settingValue: Partial, - errorValue: OnyxCommon.Errors | null, -) { - if (!isObject(settingValue)) { - return {[settingName]: errorValue}; - } - - return Object.keys(settingValue).reduce((acc, setting) => { - acc[setting] = errorValue; - return acc; - }, {}); -} - -function updatePolicyConnectionConfig( - policyID: string, - connectionName: TConnectionName, - settingName: TSettingName, - settingValue: Partial, - oldSettingValue?: Nullable>, -) { - const optimisticData: OnyxUpdate[] = [ - { - onyxMethod: Onyx.METHOD.MERGE, - key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`, - value: { - connections: { - [connectionName]: { - config: { - [settingName]: settingValue ?? null, - pendingFields: createPendingFields(settingName, settingValue, CONST.RED_BRICK_ROAD_PENDING_ACTION.UPDATE), - errorFields: createErrorFields(settingName, settingValue, null), - }, - }, - }, - }, - }, - ]; - - const failureData: OnyxUpdate[] = [ - { - onyxMethod: Onyx.METHOD.MERGE, - key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`, - value: { - connections: { - [connectionName]: { - config: { - [settingName]: oldSettingValue ?? null, - pendingFields: createPendingFields(settingName, settingValue, null), - errorFields: createErrorFields(settingName, settingValue, ErrorUtils.getMicroSecondOnyxErrorWithTranslationKey('common.genericErrorMessage')), - }, - }, - }, - }, - }, - ]; - - const successData: OnyxUpdate[] = [ - { - onyxMethod: Onyx.METHOD.MERGE, - key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`, - value: { - connections: { - [connectionName]: { - config: { - pendingFields: createPendingFields(settingName, settingValue, null), - errorFields: createErrorFields(settingName, settingValue, null), - }, - }, - }, - }, - }, - ]; - - const parameters: UpdatePolicyConnectionConfigParams = { - policyID, - connectionName, - settingName: String(settingName), - settingValue: JSON.stringify(settingValue), - idempotencyKey: String(settingName), - }; - API.write(WRITE_COMMANDS.UPDATE_POLICY_CONNECTION_CONFIG, parameters, {optimisticData, failureData, successData}); -} /** * This method returns read command and stage in progres for a given accounting integration. * @@ -440,7 +330,6 @@ function isConnectionInProgress(connectionSyncProgress: OnyxEntry Date: Wed, 16 Apr 2025 10:24:24 +0300 Subject: [PATCH 2/5] remove unused code from libs --- src/libs/CardUtils.ts | 34 -------------- src/libs/ComponentUtils/index.native.ts | 6 +-- src/libs/ComponentUtils/index.ts | 6 +-- src/libs/ComponentUtils/types.ts | 4 +- src/libs/E2E/reactNativeLaunchingTest.ts | 4 +- src/libs/EmojiUtils.tsx | 8 ---- src/libs/Metrics/index.native.ts | 9 +--- src/libs/Metrics/index.ts | 7 +-- src/libs/Metrics/types.ts | 3 +- src/libs/MoneyRequestUtils.ts | 19 -------- .../ModalStackNavigators/index.tsx | 16 ------- src/libs/NumberUtils.ts | 9 +--- src/libs/OptionsListUtils.ts | 8 ---- src/libs/Performance.tsx | 6 +-- src/libs/actions/Delegate.ts | 13 ------ src/libs/actions/Device/index.ts | 2 +- src/libs/actions/InputFocus/index.ts | 3 +- .../utils/DeferredOnyxUpdates.ts | 11 +---- src/libs/actions/PaymentMethods.ts | 16 ------- src/libs/actions/Policy/Policy.ts | 23 ---------- .../actions/ReimbursementAccount/store.ts | 7 +-- src/libs/actions/Session/index.ts | 46 ------------------- src/libs/actions/Transaction.ts | 30 ------------ src/libs/actions/User.ts | 39 ---------------- src/libs/actions/Wallet.ts | 26 ----------- src/libs/actions/Welcome/index.ts | 5 -- src/setup/platformSetup/index.native.ts | 4 +- 27 files changed, 23 insertions(+), 341 deletions(-) diff --git a/src/libs/CardUtils.ts b/src/libs/CardUtils.ts index e5d3d9e9ddb6..1805aef4ed9e 100644 --- a/src/libs/CardUtils.ts +++ b/src/libs/CardUtils.ts @@ -63,14 +63,6 @@ function isExpensifyCard(cardID?: number) { return card.bank === CONST.EXPENSIFY_CARD.BANK; } -/** - * @param cardID - * @returns boolean if the cardID is in the cardList from ONYX. Includes Expensify Cards. - */ -function isCorporateCard(cardID: number) { - return !!allCards[cardID]; -} - /** * @param cardID * @returns string in format % - %. @@ -92,10 +84,6 @@ function isCard(item: Card | Record): item is Card { return typeof item === 'object' && 'cardID' in item && !!item.cardID && 'bank' in item && !!item.bank; } -function isCardIssued(card: Card) { - return !!card?.nameValuePairs?.isVirtual || card?.state !== CONST.EXPENSIFY_CARD.STATE.STATE_NOT_ISSUED; -} - function isCardHiddenFromSearch(card: Card) { return !card?.nameValuePairs?.isVirtual && CONST.EXPENSIFY_CARD.HIDDEN_FROM_SEARCH_STATES.includes(card.state ?? 0); } @@ -228,24 +216,6 @@ function lastFourNumbersFromCardName(cardName: string | undefined): string { return match[1]; } -/** - * Finds physical card in a list of cards - * - * @returns a physical card object (or undefined if none is found) - */ -function findPhysicalCard(cards: Card[]) { - return cards.find((card) => !card?.nameValuePairs?.isVirtual); -} - -/** - * Checks if any of the cards in the list have detected fraud - * - * @param cardList - collection of assigned cards - */ -function hasDetectedFraud(cardList: Record): boolean { - return Object.values(cardList).some((card) => card.fraud !== CONST.EXPENSIFY_CARD.FRAUD_TYPES.NONE); -} - function getMCardNumberString(cardNumber: string): string { return cardNumber.replace(/\s/g, ''); } @@ -599,7 +569,6 @@ function isExpensifyCardFullySetUp(policy?: OnyxEntry, cardSettings?: On export { isExpensifyCard, - isCorporateCard, getDomainCards, formatCardExpiration, getMonthFromExpirationDateString, @@ -607,8 +576,6 @@ export { maskCard, maskCardNumber, getCardDescription, - findPhysicalCard, - hasDetectedFraud, getMCardNumberString, getTranslationKeyForLimitType, getEligibleBankAccountsForCard, @@ -630,7 +597,6 @@ export { mergeCardListWithWorkspaceFeeds, isCard, getAllCardsForWorkspace, - isCardIssued, isCardHiddenFromSearch, getFeedType, flatAllCardsList, diff --git a/src/libs/ComponentUtils/index.native.ts b/src/libs/ComponentUtils/index.native.ts index 7a3492c20ded..0906a8c341b7 100644 --- a/src/libs/ComponentUtils/index.native.ts +++ b/src/libs/ComponentUtils/index.native.ts @@ -1,10 +1,8 @@ import type {Component} from 'react'; import type {AnimatedRef} from 'react-native-reanimated'; import {dispatchCommand} from 'react-native-reanimated'; -import type {AccessibilityRoleForm, NewPasswordAutocompleteType, PasswordAutocompleteType} from './types'; +import type AccessibilityRoleForm from './types'; -const PASSWORD_AUTOCOMPLETE_TYPE: PasswordAutocompleteType = 'password'; -const NEW_PASSWORD_AUTOCOMPLETE_TYPE: NewPasswordAutocompleteType = 'password-new'; const ACCESSIBILITY_ROLE_FORM: AccessibilityRoleForm = 'none'; /** @@ -17,4 +15,4 @@ function forceClearInput(animatedInputRef: AnimatedRef) { dispatchCommand(animatedInputRef, 'clear'); } -export {PASSWORD_AUTOCOMPLETE_TYPE, ACCESSIBILITY_ROLE_FORM, NEW_PASSWORD_AUTOCOMPLETE_TYPE, forceClearInput}; +export { ACCESSIBILITY_ROLE_FORM, forceClearInput}; diff --git a/src/libs/ComponentUtils/index.ts b/src/libs/ComponentUtils/index.ts index 518791b572c9..c2d235dcaaa9 100644 --- a/src/libs/ComponentUtils/index.ts +++ b/src/libs/ComponentUtils/index.ts @@ -1,12 +1,10 @@ import type {Component} from 'react'; import type {AnimatedRef} from 'react-native-reanimated'; -import type {AccessibilityRoleForm, NewPasswordAutocompleteType, PasswordAutocompleteType} from './types'; +import type AccessibilityRoleForm from './types'; /** * Web password field needs `current-password` as autocomplete type which is not supported on native */ -const PASSWORD_AUTOCOMPLETE_TYPE: PasswordAutocompleteType = 'current-password'; -const NEW_PASSWORD_AUTOCOMPLETE_TYPE: NewPasswordAutocompleteType = 'new-password'; const ACCESSIBILITY_ROLE_FORM: AccessibilityRoleForm = 'form'; function forceClearInput(animatedInputRef: AnimatedRef) { @@ -18,4 +16,4 @@ function forceClearInput(animatedInputRef: AnimatedRef) { } } -export {PASSWORD_AUTOCOMPLETE_TYPE, ACCESSIBILITY_ROLE_FORM, NEW_PASSWORD_AUTOCOMPLETE_TYPE, forceClearInput}; +export {ACCESSIBILITY_ROLE_FORM, forceClearInput}; diff --git a/src/libs/ComponentUtils/types.ts b/src/libs/ComponentUtils/types.ts index 6efc53c2fdf7..30615e64b6d1 100644 --- a/src/libs/ComponentUtils/types.ts +++ b/src/libs/ComponentUtils/types.ts @@ -1,5 +1,3 @@ -type PasswordAutocompleteType = 'current-password' | 'password'; -type NewPasswordAutocompleteType = 'new-password' | 'password-new'; type AccessibilityRoleForm = 'form' | 'none'; -export type {PasswordAutocompleteType, NewPasswordAutocompleteType, AccessibilityRoleForm}; +export default AccessibilityRoleForm; diff --git a/src/libs/E2E/reactNativeLaunchingTest.ts b/src/libs/E2E/reactNativeLaunchingTest.ts index 50a0b3063ba9..507067ff4c31 100644 --- a/src/libs/E2E/reactNativeLaunchingTest.ts +++ b/src/libs/E2E/reactNativeLaunchingTest.ts @@ -5,7 +5,7 @@ * By doing this, we avoid bundling any E2E testing code * into the actual release app. */ -import * as Metrics from '@libs/Metrics'; +import canCapturePerformanceMetrics from '@libs/Metrics'; import Performance from '@libs/Performance'; import Config from 'react-native-config'; import E2EConfig from '../../../tests/e2e/config'; @@ -19,7 +19,7 @@ console.debug('==== Running e2e test ===='); console.debug('=========================='); // Check if the performance module is available -if (!Metrics.canCapturePerformanceMetrics()) { +if (!canCapturePerformanceMetrics()) { throw new Error('Performance module not available! Please set CAPTURE_METRICS=true in your environment file!'); } diff --git a/src/libs/EmojiUtils.tsx b/src/libs/EmojiUtils.tsx index a8fb6f7a92b3..42c04b6db609 100644 --- a/src/libs/EmojiUtils.tsx +++ b/src/libs/EmojiUtils.tsx @@ -146,13 +146,6 @@ const getEmojiUnicode = memoize( {monitoringName: 'getEmojiUnicode'}, ); -/** - * Function to remove Skin Tone and utf16 surrogates from Emoji - */ -function trimEmojiUnicode(emojiCode: string): string { - return emojiCode.replace(/(fe0f|1f3fb|1f3fc|1f3fd|1f3fe|1f3ff)$/, '').trim(); -} - /** * Validates first character is emoji in text string */ @@ -687,7 +680,6 @@ export { containsOnlyEmojis, replaceEmojis, suggestEmojis, - trimEmojiUnicode, getEmojiCodeWithSkinColor, getPreferredSkinToneIndex, getPreferredEmojiCode, diff --git a/src/libs/Metrics/index.native.ts b/src/libs/Metrics/index.native.ts index a1d008da653b..1749761de836 100644 --- a/src/libs/Metrics/index.native.ts +++ b/src/libs/Metrics/index.native.ts @@ -1,14 +1,9 @@ import CONFIG from '@src/CONFIG'; -import type {CanCaptureOnyxMetrics, CanCapturePerformanceMetrics} from './types'; +import type CanCapturePerformanceMetrics from './types'; /** * Is capturing performance stats enabled. */ const canCapturePerformanceMetrics: CanCapturePerformanceMetrics = () => CONFIG.CAPTURE_METRICS; -/** - * Is capturing Onyx stats enabled. - */ -const canCaptureOnyxMetrics: CanCaptureOnyxMetrics = () => CONFIG.ONYX_METRICS; - -export {canCapturePerformanceMetrics, canCaptureOnyxMetrics}; +export default canCapturePerformanceMetrics; diff --git a/src/libs/Metrics/index.ts b/src/libs/Metrics/index.ts index 51248b891d81..658888b740f8 100644 --- a/src/libs/Metrics/index.ts +++ b/src/libs/Metrics/index.ts @@ -1,9 +1,6 @@ -import CONFIG from '@src/CONFIG'; -import type {CanCaptureOnyxMetrics, CanCapturePerformanceMetrics} from './types'; +import type CanCapturePerformanceMetrics from './types'; // We don't capture performance metrics on web as there are enough tools available const canCapturePerformanceMetrics: CanCapturePerformanceMetrics = () => false; -const canCaptureOnyxMetrics: CanCaptureOnyxMetrics = () => CONFIG.ONYX_METRICS; - -export {canCapturePerformanceMetrics, canCaptureOnyxMetrics}; +export default canCapturePerformanceMetrics; diff --git a/src/libs/Metrics/types.ts b/src/libs/Metrics/types.ts index 61b1400ae9f8..15e6c43575ce 100644 --- a/src/libs/Metrics/types.ts +++ b/src/libs/Metrics/types.ts @@ -1,4 +1,3 @@ type CanCapturePerformanceMetrics = () => boolean; -type CanCaptureOnyxMetrics = () => boolean; -export type {CanCapturePerformanceMetrics, CanCaptureOnyxMetrics}; +export default CanCapturePerformanceMetrics; diff --git a/src/libs/MoneyRequestUtils.ts b/src/libs/MoneyRequestUtils.ts index 7009379e15de..2dd71bee87a2 100644 --- a/src/libs/MoneyRequestUtils.ts +++ b/src/libs/MoneyRequestUtils.ts @@ -1,7 +1,4 @@ -import type {OnyxEntry} from 'react-native-onyx'; -import type {IOUType} from '@src/CONST'; import CONST from '@src/CONST'; -import type {SelectedTabRequest} from '@src/types/onyx'; /** * Strip comma from the amount @@ -82,24 +79,8 @@ function replaceAllDigits(text: string, convertFn: (char: string) => string): st .join(''); } -/** - * Check if distance expense or not - */ -function isDistanceRequest(iouType: IOUType, selectedTab: OnyxEntry): boolean { - return (iouType === CONST.IOU.TYPE.REQUEST || iouType === CONST.IOU.TYPE.SUBMIT) && selectedTab === CONST.TAB_REQUEST.DISTANCE; -} - -/** - * Check if scan expense or not - */ -function isScanRequest(selectedTab: SelectedTabRequest): boolean { - return selectedTab === CONST.TAB_REQUEST.SCAN; -} - export { addLeadingZero, - isDistanceRequest, - isScanRequest, replaceAllDigits, stripCommaFromAmount, stripDecimalsFromAmount, diff --git a/src/libs/Navigation/AppNavigator/ModalStackNavigators/index.tsx b/src/libs/Navigation/AppNavigator/ModalStackNavigators/index.tsx index 416e5160fafe..71c6acd087b6 100644 --- a/src/libs/Navigation/AppNavigator/ModalStackNavigators/index.tsx +++ b/src/libs/Navigation/AppNavigator/ModalStackNavigators/index.tsx @@ -18,7 +18,6 @@ import type { PrivateNotesNavigatorParamList, ProfileNavigatorParamList, ReferralDetailsNavigatorParamList, - ReimbursementAccountNavigatorParamList, ReportChangeWorkspaceNavigatorParamList, ReportDescriptionNavigatorParamList, ReportDetailsNavigatorParamList, @@ -636,10 +635,6 @@ const AddPersonalBankAccountModalStackNavigator = createModalStackNavigator require('../../../../pages/AddPersonalBankAccountPage').default, }); -const ReimbursementAccountModalStackNavigator = createModalStackNavigator({ - [SCREENS.REIMBURSEMENT_ACCOUNT_ROOT]: () => require('../../../../pages/ReimbursementAccount/ReimbursementAccountPage').default, -}); - const WalletStatementStackNavigator = createModalStackNavigator({ [SCREENS.WALLET_STATEMENT_ROOT]: () => require('../../../../pages/wallet/WalletStatementPage').default, }); @@ -664,14 +659,6 @@ const ReferralModalStackNavigator = createModalStackNavigator require('../../../../pages/ReferralDetailsPage').default, }); -const ProcessMoneyRequestHoldStackNavigator = createModalStackNavigator({ - [SCREENS.PROCESS_MONEY_REQUEST_HOLD_ROOT]: () => require('../../../../pages/ProcessMoneyRequestHoldPage').default, -}); - -const ChangePolicyEducationalStackNavigator = createModalStackNavigator({ - [SCREENS.CHANGE_POLICY_EDUCATIONAL_ROOT]: () => require('../../../../pages/ChangePolicyEducationalModal').default, -}); - const TransactionDuplicateStackNavigator = createModalStackNavigator({ [SCREENS.TRANSACTION_DUPLICATE.REVIEW]: () => require('../../../../pages/TransactionDuplicate/Review').default, [SCREENS.TRANSACTION_DUPLICATE.MERCHANT]: () => require('../../../../pages/TransactionDuplicate/ReviewMerchant').default, @@ -759,12 +746,9 @@ export { NewTaskModalStackNavigator, NewTeachersUniteNavigator, PrivateNotesModalStackNavigator, - ProcessMoneyRequestHoldStackNavigator, - ChangePolicyEducationalStackNavigator, ProfileModalStackNavigator, ReferralModalStackNavigator, TravelModalStackNavigator, - ReimbursementAccountModalStackNavigator, NewReportWorkspaceSelectionModalStackNavigator, ReportDescriptionModalStackNavigator, ReportDetailsModalStackNavigator, diff --git a/src/libs/NumberUtils.ts b/src/libs/NumberUtils.ts index 2dfc1e722c58..4981d8d975f5 100644 --- a/src/libs/NumberUtils.ts +++ b/src/libs/NumberUtils.ts @@ -69,13 +69,6 @@ function parseFloatAnyLocale(value: string): number { return parseFloat(value ? value.replace(',', '.') : value); } -/** - * Given an input number p and another number q, returns the largest number that's less than p and divisible by q. - */ -function roundDownToLargestMultiple(p: number, q: number) { - return Math.floor(p / q) * q; -} - /** * Rounds a number to two decimal places. * @returns the rounded value @@ -100,4 +93,4 @@ function generateNewRandomInt(old: number, min: number, max: number): number { return newNum; } -export {rand64, generateHexadecimalValue, generateRandomInt, parseFloatAnyLocale, roundDownToLargestMultiple, roundToTwoDecimalPlaces, clamp, generateNewRandomInt}; +export {rand64, generateHexadecimalValue, generateRandomInt, parseFloatAnyLocale, roundToTwoDecimalPlaces, clamp, generateNewRandomInt}; diff --git a/src/libs/OptionsListUtils.ts b/src/libs/OptionsListUtils.ts index bd8c336b7498..9b0b5e3e360a 100644 --- a/src/libs/OptionsListUtils.ts +++ b/src/libs/OptionsListUtils.ts @@ -1552,13 +1552,6 @@ function isManagerMcTestReport(report: SearchOption): boolean { return report.participantsList?.some((participant) => participant.accountID === CONST.ACCOUNT_ID.MANAGER_MCTEST) ?? false; } -/** - * Helper method to check if participant email is Manager McTest - */ -function isSelectedManagerMcTest(email: string | null | undefined): boolean { - return email === CONST.EMAIL.MANAGER_MCTEST; -} - function getValidPersonalDetailOptions( options: OptionList['personalDetails'], { @@ -2355,7 +2348,6 @@ export { filterReports, getIsUserSubmittedExpenseOrScannedReceipt, getManagerMcTestParticipant, - isSelectedManagerMcTest, shouldShowLastActorDisplayName, }; diff --git a/src/libs/Performance.tsx b/src/libs/Performance.tsx index df642e9f0681..868b70b9673e 100644 --- a/src/libs/Performance.tsx +++ b/src/libs/Performance.tsx @@ -8,7 +8,7 @@ import type {PerformanceEntry, PerformanceMark, PerformanceMeasure} from 'react- import CONST from '@src/CONST'; import isE2ETestSession from './E2E/isE2ETestSession'; import getComponentDisplayName from './getComponentDisplayName'; -import * as Metrics from './Metrics'; +import canCapturePerformanceMetrics from './Metrics'; /** * Deep diff between two objects. Useful for figuring out what changed about an object from one render to the next so @@ -52,7 +52,7 @@ function measureTTI(endMark?: string): void { // We don't want an alert to show: // - on builds with performance metrics collection disabled by a feature flag // - e2e test sessions - if (!Metrics.canCapturePerformanceMetrics() || isE2ETestSession()) { + if (!canCapturePerformanceMetrics() || isE2ETestSession()) { return; } @@ -218,7 +218,7 @@ type WrappedComponentConfig = {id: string}; * A HOC that captures render timings of the Wrapped component */ function withRenderTrace({id}: WrappedComponentConfig) { - if (!Metrics.canCapturePerformanceMetrics()) { + if (!canCapturePerformanceMetrics()) { return

>(WrappedComponent: React.ComponentType

): React.ComponentType

=> WrappedComponent; } diff --git a/src/libs/actions/Delegate.ts b/src/libs/actions/Delegate.ts index 2f376b4eca28..98567349e039 100644 --- a/src/libs/actions/Delegate.ts +++ b/src/libs/actions/Delegate.ts @@ -529,18 +529,6 @@ function isConnectedAsDelegate() { return !!delegatedAccess?.delegate; } -function removePendingDelegate(email: string) { - if (!delegatedAccess?.delegates) { - return; - } - - Onyx.merge(ONYXKEYS.ACCOUNT, { - delegatedAccess: { - delegates: delegatedAccess.delegates.filter((delegate) => delegate.email !== email), - }, - }); -} - function updateDelegateRole(email: string, role: DelegateRole, validateCode: string) { if (!delegatedAccess?.delegates) { return; @@ -711,7 +699,6 @@ export { addDelegate, requestValidationCode, clearDelegateErrorsByField, - removePendingDelegate, restoreDelegateSession, isConnectedAsDelegate, updateDelegateRoleOptimistically, diff --git a/src/libs/actions/Device/index.ts b/src/libs/actions/Device/index.ts index 991f9ce6227b..133171f64e69 100644 --- a/src/libs/actions/Device/index.ts +++ b/src/libs/actions/Device/index.ts @@ -62,4 +62,4 @@ function getDeviceInfoWithID(): Promise { ); }); } -export {getDeviceID, setDeviceID, getDeviceInfoWithID}; +export { setDeviceID, getDeviceInfoWithID}; diff --git a/src/libs/actions/InputFocus/index.ts b/src/libs/actions/InputFocus/index.ts index 6d8706ebdd0e..658ac2977d78 100644 --- a/src/libs/actions/InputFocus/index.ts +++ b/src/libs/actions/InputFocus/index.ts @@ -4,6 +4,5 @@ import type {Modal} from '@src/types/onyx'; function inputFocusChange(focus: boolean) {} // eslint-disable-next-line @typescript-eslint/no-unused-vars function composerFocusKeepFocusOn(ref: HTMLElement, isFocused: boolean, modal: Modal, onyxFocused: boolean) {} -const callback = (method: () => void) => method(); -export {composerFocusKeepFocusOn, inputFocusChange, callback}; +export {composerFocusKeepFocusOn, inputFocusChange}; diff --git a/src/libs/actions/OnyxUpdateManager/utils/DeferredOnyxUpdates.ts b/src/libs/actions/OnyxUpdateManager/utils/DeferredOnyxUpdates.ts index 8b3bf5d9af86..55593e74f3d2 100644 --- a/src/libs/actions/OnyxUpdateManager/utils/DeferredOnyxUpdates.ts +++ b/src/libs/actions/OnyxUpdateManager/utils/DeferredOnyxUpdates.ts @@ -99,15 +99,6 @@ function enqueue(updates: OnyxUpdatesFromServer | DeferredUpdatesDictionary, opt } } -/** - * Adds updates to the deferred updates queue and processes them immediately - * @param updates The updates that should be applied (e.g. updates from push notifications) - */ -function enqueueAndProcess(updates: OnyxUpdatesFromServer | DeferredUpdatesDictionary, options?: EnqueueDeferredOnyxUpdatesOptions) { - enqueue(updates, options); - process(); -} - type ClearDeferredOnyxUpdatesOptions = { shouldResetGetMissingOnyxUpdatesPromise?: boolean; shouldUnpauseSequentialQueue?: boolean; @@ -130,4 +121,4 @@ function clear(options?: ClearDeferredOnyxUpdatesOptions) { } } -export {getMissingOnyxUpdatesQueryPromise, setMissingOnyxUpdatesQueryPromise, getUpdates, isEmpty, process, enqueue, enqueueAndProcess, clear}; +export {getMissingOnyxUpdatesQueryPromise, setMissingOnyxUpdatesQueryPromise, getUpdates, isEmpty, process, enqueue, clear}; diff --git a/src/libs/actions/PaymentMethods.ts b/src/libs/actions/PaymentMethods.ts index d70c0af6294e..cd9bcc630d40 100644 --- a/src/libs/actions/PaymentMethods.ts +++ b/src/libs/actions/PaymentMethods.ts @@ -536,21 +536,6 @@ function updateBillingCurrency(currency: ValueOf { - return bankAccountList; -} - function hasCreditBankAccount(): boolean { if (!bankAccountList) { return false; @@ -27,4 +23,5 @@ function hasCreditBankAccount(): boolean { }); } -export {getBankAccountList, hasCreditBankAccount}; +export default {hasCreditBankAccount}; +export { hasCreditBankAccount}; diff --git a/src/libs/actions/Session/index.ts b/src/libs/actions/Session/index.ts index ffb736d13d16..6b9b9d8acc29 100644 --- a/src/libs/actions/Session/index.ts +++ b/src/libs/actions/Session/index.ts @@ -15,7 +15,6 @@ import type { BeginSignInParams, DisableTwoFactorAuthParams, LogOutParams, - RequestAccountValidationLinkParams, RequestNewValidateCodeParams, RequestUnlinkValidationLinkParams, ResetSMSDeliveryFailureStatusParams, @@ -353,50 +352,6 @@ function callFunctionIfActionIsAllowed an return callback; } -/** - * Resend the validation link to the user that is validating their account - */ -function resendValidationLink(login = credentials.login) { - const optimisticData: OnyxUpdate[] = [ - { - onyxMethod: Onyx.METHOD.MERGE, - key: ONYXKEYS.ACCOUNT, - value: { - isLoading: true, - errors: null, - message: null, - loadingForm: CONST.FORMS.RESEND_VALIDATION_FORM, - }, - }, - ]; - const successData: OnyxUpdate[] = [ - { - onyxMethod: Onyx.METHOD.MERGE, - key: ONYXKEYS.ACCOUNT, - value: { - isLoading: false, - message: 'resendValidationForm.linkHasBeenResent', - loadingForm: null, - }, - }, - ]; - const failureData: OnyxUpdate[] = [ - { - onyxMethod: Onyx.METHOD.MERGE, - key: ONYXKEYS.ACCOUNT, - value: { - isLoading: false, - message: null, - loadingForm: null, - }, - }, - ]; - - const params: RequestAccountValidationLinkParams = {email: login}; - - API.write(WRITE_COMMANDS.REQUEST_ACCOUNT_VALIDATION_LINK, params, {optimisticData, successData, failureData}); -} - /** * Request a new validate / magic code for user to sign in via passwordless flow */ @@ -1382,7 +1337,6 @@ export { cleanupSession, signOut, signOutAndRedirectToSignIn, - resendValidationLink, resendValidateCode, requestUnlinkValidationLink, unlinkLogin, diff --git a/src/libs/actions/Transaction.ts b/src/libs/actions/Transaction.ts index d2f996c3e965..d96c0a146be3 100644 --- a/src/libs/actions/Transaction.ts +++ b/src/libs/actions/Transaction.ts @@ -56,34 +56,6 @@ Onyx.connect({ callback: (val) => (allTransactionViolations = val ?? []), }); -function createInitialWaypoints(transactionID: string) { - Onyx.merge(`${ONYXKEYS.COLLECTION.TRANSACTION}${transactionID}`, { - comment: { - waypoints: { - waypoint0: {}, - waypoint1: {}, - }, - }, - }); -} - -/** - * Add a stop to the transaction - */ -function addStop(transactionID: string) { - const transaction = allTransactions?.[transactionID] ?? {}; - const existingWaypoints = transaction?.comment?.waypoints ?? {}; - const newLastIndex = Object.keys(existingWaypoints).length; - - Onyx.merge(`${ONYXKEYS.COLLECTION.TRANSACTION}${transactionID}`, { - comment: { - waypoints: { - [`waypoint${newLastIndex}`]: {}, - }, - }, - }); -} - function saveWaypoint(transactionID: string, index: string, waypoint: RecentWaypoint | null, isDraft = false) { Onyx.merge(`${isDraft ? ONYXKEYS.COLLECTION.TRANSACTION_DRAFT : ONYXKEYS.COLLECTION.TRANSACTION}${transactionID}`, { comment: { @@ -573,8 +545,6 @@ function getAllTransactions() { } export { - addStop, - createInitialWaypoints, saveWaypoint, removeWaypoint, getRoute, diff --git a/src/libs/actions/User.ts b/src/libs/actions/User.ts index c00f4c91bde0..f1e7571977b3 100644 --- a/src/libs/actions/User.ts +++ b/src/libs/actions/User.ts @@ -21,7 +21,6 @@ import type { UpdatePreferredEmojiSkinToneParams, UpdateStatusParams, UpdateThemeParams, - ValidateLoginParams, ValidateSecondaryLoginParams, } from '@libs/API/parameters'; import {READ_COMMANDS, WRITE_COMMANDS} from '@libs/API/types'; @@ -566,38 +565,6 @@ function requestValidateCodeAction() { API.write(WRITE_COMMANDS.RESEND_VALIDATE_CODE, null, {optimisticData, successData, failureData}); } -/** - * Validates a login given an accountID and validation code - */ -function validateLogin(accountID: number, validateCode: string) { - Onyx.merge(ONYXKEYS.ACCOUNT, {...CONST.DEFAULT_ACCOUNT_DATA, isLoading: true}); - - const optimisticData: OnyxUpdate[] = [ - { - onyxMethod: Onyx.METHOD.MERGE, - key: ONYXKEYS.ACCOUNT, - value: { - isLoading: true, - }, - }, - ]; - - const finallyData: OnyxUpdate[] = [ - { - onyxMethod: Onyx.METHOD.MERGE, - key: ONYXKEYS.ACCOUNT, - value: { - isLoading: false, - }, - }, - ]; - - const parameters: ValidateLoginParams = {accountID, validateCode}; - - API.write(WRITE_COMMANDS.VALIDATE_LOGIN, parameters, {optimisticData, finallyData}); - Navigation.navigate(ROUTES.HOME); -} - /** * Validates a secondary login / contact method */ @@ -1150,10 +1117,6 @@ function setShouldUseStagingServer(shouldUseStagingServer: boolean) { Onyx.merge(ONYXKEYS.USER, {shouldUseStagingServer}); } -function clearUserErrorMessage() { - Onyx.merge(ONYXKEYS.USER, {error: ''}); -} - function togglePlatformMute(platform: Platform, mutedPlatforms: Partial>) { const newMutedPlatforms = mutedPlatforms?.[platform] ? {...mutedPlatforms, [platform]: undefined} // Remove platform if it's muted @@ -1532,14 +1495,12 @@ export { clearContactMethodErrors, clearContactMethod, addNewContactMethod, - validateLogin, validateSecondaryLogin, isBlockedFromConcierge, subscribeToUserEvents, updatePreferredSkinTone, setShouldUseStagingServer, togglePlatformMute, - clearUserErrorMessage, joinScreenShare, clearScreenShareRequest, generateStatementPDF, diff --git a/src/libs/actions/Wallet.ts b/src/libs/actions/Wallet.ts index e0a19056e893..de240fbc6837 100644 --- a/src/libs/actions/Wallet.ts +++ b/src/libs/actions/Wallet.ts @@ -9,9 +9,7 @@ import Log from '@libs/Log'; import type CONST from '@src/CONST'; import ONYXKEYS from '@src/ONYXKEYS'; import type {WalletAdditionalQuestionDetails} from '@src/types/onyx'; -import type * as OnyxCommon from '@src/types/onyx/OnyxCommon'; import pkg from '../../../package.json'; -import {clearErrors} from './FormActions'; type WalletQuestionAnswer = { question: string; @@ -53,11 +51,6 @@ function setAdditionalDetailsQuestions(questions: WalletAdditionalQuestionDetail Onyx.merge(ONYXKEYS.WALLET_ADDITIONAL_DETAILS, {questions, idNumber}); } -function setAdditionalDetailsErrors(errorFields: OnyxCommon.ErrorFields) { - Onyx.merge(ONYXKEYS.WALLET_ADDITIONAL_DETAILS, {errorFields: null}); - Onyx.merge(ONYXKEYS.WALLET_ADDITIONAL_DETAILS, {errorFields}); -} - /** * Save the source that triggered the KYC wall and optionally the chat report ID associated with the IOU */ @@ -257,23 +250,6 @@ function resetWalletAdditionalDetailsDraft() { Onyx.set(ONYXKEYS.FORMS.WALLET_ADDITIONAL_DETAILS_DRAFT, null); } -/** - * Clear the error of specific card - * @param cardID The card id of the card that you want to clear the errors. - */ -function clearPhysicalCardError(cardID?: string) { - if (!cardID) { - return; - } - - clearErrors(ONYXKEYS.FORMS.REPORT_PHYSICAL_CARD_FORM); - Onyx.merge(ONYXKEYS.CARD_LIST, { - [cardID]: { - errors: null, - }, - }); -} - function issuerEncryptPayloadCallback(nonce: string, nonceSignature: string, certificates: string[]): Promise { // eslint-disable-next-line rulesdir/no-api-side-effects-method, rulesdir/no-api-in-views return API.makeRequestWithSideEffects(SIDE_EFFECT_REQUEST_COMMANDS.CREATE_DIGITAL_WALLET, { @@ -301,7 +277,6 @@ export { openOnfidoFlow, openInitialSettingsPage, openEnablePaymentsPage, - setAdditionalDetailsErrors, setAdditionalDetailsQuestions, updateCurrentStep, answerQuestionsForWallet, @@ -310,6 +285,5 @@ export { acceptWalletTerms, setKYCWallSource, resetWalletAdditionalDetailsDraft, - clearPhysicalCardError, issuerEncryptPayloadCallback, }; diff --git a/src/libs/actions/Welcome/index.ts b/src/libs/actions/Welcome/index.ts index e959d84c9c13..fe30896481ec 100644 --- a/src/libs/actions/Welcome/index.ts +++ b/src/libs/actions/Welcome/index.ts @@ -94,10 +94,6 @@ function checkOnboardingDataReady() { resolveOnboardingFlowStatus(); } -function setOnboardingCustomChoices(value: OnboardingPurpose[]) { - Onyx.set(ONYXKEYS.ONBOARDING_CUSTOM_CHOICES, value ?? []); -} - function setOnboardingPurposeSelected(value: OnboardingPurpose) { Onyx.set(ONYXKEYS.ONBOARDING_PURPOSE_SELECTED, value ?? null); } @@ -229,7 +225,6 @@ export { onServerDataReady, isOnboardingFlowCompleted, dismissProductTraining, - setOnboardingCustomChoices, setOnboardingPurposeSelected, updateOnboardingLastVisitedPath, resetAllChecks, diff --git a/src/setup/platformSetup/index.native.ts b/src/setup/platformSetup/index.native.ts index ded98285aa3e..62e7a52e1a68 100644 --- a/src/setup/platformSetup/index.native.ts +++ b/src/setup/platformSetup/index.native.ts @@ -1,5 +1,5 @@ import crashlytics from '@react-native-firebase/crashlytics'; -import * as Metrics from '@libs/Metrics'; +import canCapturePerformanceMetrics from '@libs/Metrics'; import Performance from '@libs/Performance'; import CONFIG from '@src/CONFIG'; @@ -11,7 +11,7 @@ export default function () { crashlytics().setCrashlyticsCollectionEnabled(false); } - if (Metrics.canCapturePerformanceMetrics()) { + if (canCapturePerformanceMetrics()) { Performance.enableMonitoring(); } } From 92e5a479e23bf1551070db67046d09d7237eec8e Mon Sep 17 00:00:00 2001 From: Povilas Zirgulis Date: Thu, 17 Apr 2025 08:42:29 +0300 Subject: [PATCH 3/5] fix prettier --- src/libs/ComponentUtils/index.native.ts | 2 +- src/libs/MoneyRequestUtils.ts | 11 +---------- src/libs/actions/Device/index.ts | 2 +- src/libs/actions/ReimbursementAccount/store.ts | 2 +- 4 files changed, 4 insertions(+), 13 deletions(-) diff --git a/src/libs/ComponentUtils/index.native.ts b/src/libs/ComponentUtils/index.native.ts index 0906a8c341b7..60be12c2a978 100644 --- a/src/libs/ComponentUtils/index.native.ts +++ b/src/libs/ComponentUtils/index.native.ts @@ -15,4 +15,4 @@ function forceClearInput(animatedInputRef: AnimatedRef) { dispatchCommand(animatedInputRef, 'clear'); } -export { ACCESSIBILITY_ROLE_FORM, forceClearInput}; +export {ACCESSIBILITY_ROLE_FORM, forceClearInput}; diff --git a/src/libs/MoneyRequestUtils.ts b/src/libs/MoneyRequestUtils.ts index 2dd71bee87a2..8cf7ecb4a73d 100644 --- a/src/libs/MoneyRequestUtils.ts +++ b/src/libs/MoneyRequestUtils.ts @@ -79,13 +79,4 @@ function replaceAllDigits(text: string, convertFn: (char: string) => string): st .join(''); } -export { - addLeadingZero, - replaceAllDigits, - stripCommaFromAmount, - stripDecimalsFromAmount, - stripSpacesFromAmount, - replaceCommasWithPeriod, - validateAmount, - validatePercentage, -}; +export {addLeadingZero, replaceAllDigits, stripCommaFromAmount, stripDecimalsFromAmount, stripSpacesFromAmount, replaceCommasWithPeriod, validateAmount, validatePercentage}; diff --git a/src/libs/actions/Device/index.ts b/src/libs/actions/Device/index.ts index 133171f64e69..a167a13f9507 100644 --- a/src/libs/actions/Device/index.ts +++ b/src/libs/actions/Device/index.ts @@ -62,4 +62,4 @@ function getDeviceInfoWithID(): Promise { ); }); } -export { setDeviceID, getDeviceInfoWithID}; +export {setDeviceID, getDeviceInfoWithID}; diff --git a/src/libs/actions/ReimbursementAccount/store.ts b/src/libs/actions/ReimbursementAccount/store.ts index 5247f90d97cf..bc298313ad1e 100644 --- a/src/libs/actions/ReimbursementAccount/store.ts +++ b/src/libs/actions/ReimbursementAccount/store.ts @@ -24,4 +24,4 @@ function hasCreditBankAccount(): boolean { } export default {hasCreditBankAccount}; -export { hasCreditBankAccount}; +export {hasCreditBankAccount}; From 5ece16ee9a981a39fc47f65845bf89f9ee4e29f3 Mon Sep 17 00:00:00 2001 From: Povilas Zirgulis Date: Thu, 17 Apr 2025 09:18:41 +0300 Subject: [PATCH 4/5] fix eslint --- src/components/Form/FormProvider.tsx | 6 +++--- src/components/Form/FormWrapper.tsx | 2 +- src/components/OptionListContextProvider.tsx | 6 +++--- src/components/ThreeDotsMenu/index.tsx | 2 +- .../ValidateCodeForm/BaseValidateCodeForm.tsx | 4 +++- src/components/withEnvironment.tsx | 6 +++--- .../Navigation/AppNavigator/AuthScreens.tsx | 4 +++- .../Navigators/OnboardingModalNavigator.tsx | 5 ++++- .../utils/DeferredOnyxUpdates.ts | 6 +++--- src/libs/actions/PaymentMethods.ts | 1 - src/pages/workspace/WorkspaceOverviewPage.tsx | 14 +++++++++---- src/pages/workspace/WorkspacesListPage.tsx | 21 +++++++++++-------- 12 files changed, 46 insertions(+), 31 deletions(-) diff --git a/src/components/Form/FormProvider.tsx b/src/components/Form/FormProvider.tsx index 2d1eaaf39b18..b7dfb2a6d5e5 100644 --- a/src/components/Form/FormProvider.tsx +++ b/src/components/Form/FormProvider.tsx @@ -102,9 +102,9 @@ function FormProvider( }: FormProviderProps, forwardedRef: ForwardedRef, ) { - const [network] = useOnyx(ONYXKEYS.NETWORK); - const [formState] = useOnyx(`${formID}`); - const [draftValues] = useOnyx(`${formID}Draft`); + const [network] = useOnyx(ONYXKEYS.NETWORK, {canBeMissing: true}); + const [formState] = useOnyx(`${formID}`, {canBeMissing: true}); + const [draftValues] = useOnyx(`${formID}Draft`, {canBeMissing: true}); const {preferredLocale, translate} = useLocalize(); const inputRefs = useRef({}); const touchedInputs = useRef>({}); diff --git a/src/components/Form/FormWrapper.tsx b/src/components/Form/FormWrapper.tsx index e3dd5da85aba..a6e30d2795f7 100644 --- a/src/components/Form/FormWrapper.tsx +++ b/src/components/Form/FormWrapper.tsx @@ -87,7 +87,7 @@ function FormWrapper({ const formRef = useRef(null); const formContentRef = useRef(null); - const [formState] = useOnyx(`${formID}`); + const [formState] = useOnyx(`${formID}`, {canBeMissing: true}); const errorMessage = useMemo(() => (formState ? getLatestErrorMessage(formState) : undefined), [formState]); diff --git a/src/components/OptionListContextProvider.tsx b/src/components/OptionListContextProvider.tsx index c9b477558498..d74fac25e195 100644 --- a/src/components/OptionListContextProvider.tsx +++ b/src/components/OptionListContextProvider.tsx @@ -46,8 +46,8 @@ function OptionsListContextProvider({children}: OptionsListProviderProps) { reports: [], personalDetails: [], }); - const [preferredLocale] = useOnyx(ONYXKEYS.NVP_PREFERRED_LOCALE); - const [reports] = useOnyx(ONYXKEYS.COLLECTION.REPORT); + const [preferredLocale] = useOnyx(ONYXKEYS.NVP_PREFERRED_LOCALE, {canBeMissing: true}); + const [reports] = useOnyx(ONYXKEYS.COLLECTION.REPORT, {canBeMissing: true}); const personalDetails = usePersonalDetails(); const prevPersonalDetails = usePrevious(personalDetails); @@ -182,7 +182,7 @@ const useOptionsListContext = () => useContext(OptionsListContext); const useOptionsList = (options?: {shouldInitialize: boolean}) => { const {shouldInitialize = true} = options ?? {}; const {initializeOptions, options: optionsList, areOptionsInitialized, resetOptions} = useOptionsListContext(); - const [isLoadingApp] = useOnyx(ONYXKEYS.IS_LOADING_APP); + const [isLoadingApp] = useOnyx(ONYXKEYS.IS_LOADING_APP, {canBeMissing: true}); useEffect(() => { if (!shouldInitialize || areOptionsInitialized || isLoadingApp) { diff --git a/src/components/ThreeDotsMenu/index.tsx b/src/components/ThreeDotsMenu/index.tsx index e87ada85863f..0359ccd94b3b 100644 --- a/src/components/ThreeDotsMenu/index.tsx +++ b/src/components/ThreeDotsMenu/index.tsx @@ -39,7 +39,7 @@ function ThreeDotsMenu({ shouldShowProductTrainingTooltip = false, isNested = false, }: ThreeDotsMenuProps) { - const [modal] = useOnyx(ONYXKEYS.MODAL); + const [modal] = useOnyx(ONYXKEYS.MODAL, {canBeMissing: true}); const theme = useTheme(); const styles = useThemeStyles(); diff --git a/src/components/ValidateCodeActionModal/ValidateCodeForm/BaseValidateCodeForm.tsx b/src/components/ValidateCodeActionModal/ValidateCodeForm/BaseValidateCodeForm.tsx index 1c68eb459e0c..2a975bafeb97 100644 --- a/src/components/ValidateCodeActionModal/ValidateCodeForm/BaseValidateCodeForm.tsx +++ b/src/components/ValidateCodeActionModal/ValidateCodeForm/BaseValidateCodeForm.tsx @@ -100,7 +100,9 @@ function BaseValidateCodeForm({ const [formError, setFormError] = useState({}); const [validateCode, setValidateCode] = useState(''); const inputValidateCodeRef = useRef(null); - const [account = {}] = useOnyx(ONYXKEYS.ACCOUNT); + const [account = {}] = useOnyx(ONYXKEYS.ACCOUNT, { + canBeMissing: true, + }); // eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing -- nullish coalescing doesn't achieve the same result in this case const shouldDisableResendValidateCode = !!isOffline || account?.isLoading; const focusTimeoutRef = useRef(null); diff --git a/src/components/withEnvironment.tsx b/src/components/withEnvironment.tsx index bd3aef395ba3..d8c620c964cb 100644 --- a/src/components/withEnvironment.tsx +++ b/src/components/withEnvironment.tsx @@ -1,7 +1,7 @@ import type {ReactElement, ReactNode} from 'react'; import React, {createContext, useEffect, useMemo, useState} from 'react'; import type {ValueOf} from 'type-fest'; -import * as Environment from '@libs/Environment/Environment'; +import {getEnvironment, getEnvironmentURL} from '@libs/Environment/Environment'; import CONST from '@src/CONST'; type EnvironmentProviderProps = { @@ -29,8 +29,8 @@ function EnvironmentProvider({children}: EnvironmentProviderProps): ReactElement const [environmentURL, setEnvironmentURL] = useState(CONST.NEW_EXPENSIFY_URL); useEffect(() => { - Environment.getEnvironment().then(setEnvironment); - Environment.getEnvironmentURL().then(setEnvironmentURL); + getEnvironment().then(setEnvironment); + getEnvironmentURL().then(setEnvironmentURL); }, []); const contextValue = useMemo( diff --git a/src/libs/Navigation/AppNavigator/AuthScreens.tsx b/src/libs/Navigation/AppNavigator/AuthScreens.tsx index 9ca79ba29b62..c55984a84cf8 100644 --- a/src/libs/Navigation/AppNavigator/AuthScreens.tsx +++ b/src/libs/Navigation/AppNavigator/AuthScreens.tsx @@ -224,7 +224,9 @@ function AuthScreens({session, lastOpenedPublicRoomID, initialLastUpdateIDApplie const currentUrl = getCurrentUrl(); const delegatorEmail = getSearchParamFromUrl(currentUrl, 'delegatorEmail'); - const [account] = useOnyx(ONYXKEYS.ACCOUNT); + const [account] = useOnyx(ONYXKEYS.ACCOUNT, { + canBeMissing: true, + }); const modal = useRef({}); const {isOnboardingCompleted} = useOnboardingFlowRouter(); const [shouldShowRequire2FAPage, setShouldShowRequire2FAPage] = useState(!!account?.needsTwoFactorAuthSetup && !account.requiresTwoFactorAuth); diff --git a/src/libs/Navigation/AppNavigator/Navigators/OnboardingModalNavigator.tsx b/src/libs/Navigation/AppNavigator/Navigators/OnboardingModalNavigator.tsx index 0b23c671b2ad..1d63fa2b309a 100644 --- a/src/libs/Navigation/AppNavigator/Navigators/OnboardingModalNavigator.tsx +++ b/src/libs/Navigation/AppNavigator/Navigators/OnboardingModalNavigator.tsx @@ -36,7 +36,10 @@ function OnboardingModalNavigator() { const styles = useThemeStyles(); const {onboardingIsMediumOrLargerScreenWidth} = useResponsiveLayout(); const outerViewRef = React.useRef(null); - const [accountID] = useOnyx(ONYXKEYS.SESSION, {selector: (session) => session?.accountID ?? 0}); + const [accountID] = useOnyx(ONYXKEYS.SESSION, { + selector: (session) => session?.accountID ?? CONST.DEFAULT_NUMBER_ID, + canBeMissing: true, + }); // Publish a sign_up event when we start the onboarding flow. This should track basic sign ups // as well as Google and Apple SSO. diff --git a/src/libs/actions/OnyxUpdateManager/utils/DeferredOnyxUpdates.ts b/src/libs/actions/OnyxUpdateManager/utils/DeferredOnyxUpdates.ts index 55593e74f3d2..a9edf1bdf82e 100644 --- a/src/libs/actions/OnyxUpdateManager/utils/DeferredOnyxUpdates.ts +++ b/src/libs/actions/OnyxUpdateManager/utils/DeferredOnyxUpdates.ts @@ -6,7 +6,7 @@ import ONYXKEYS from '@src/ONYXKEYS'; import type {OnyxUpdatesFromServer, Response} from '@src/types/onyx'; import {isValidOnyxUpdateFromServer} from '@src/types/onyx/OnyxUpdatesFromServer'; // eslint-disable-next-line import/no-cycle -import * as OnyxUpdateManagerUtils from '.'; +import {validateAndApplyDeferredUpdates} from '.'; let missingOnyxUpdatesQueryPromise: Promise | undefined; let deferredUpdates: DeferredUpdatesDictionary = {}; @@ -61,10 +61,10 @@ function isEmpty() { */ function process() { if (missingOnyxUpdatesQueryPromise) { - missingOnyxUpdatesQueryPromise.finally(() => OnyxUpdateManagerUtils.validateAndApplyDeferredUpdates); + missingOnyxUpdatesQueryPromise.finally(() => validateAndApplyDeferredUpdates); } - missingOnyxUpdatesQueryPromise = OnyxUpdateManagerUtils.validateAndApplyDeferredUpdates(); + missingOnyxUpdatesQueryPromise = validateAndApplyDeferredUpdates(); } type EnqueueDeferredOnyxUpdatesOptions = { diff --git a/src/libs/actions/PaymentMethods.ts b/src/libs/actions/PaymentMethods.ts index cd9bcc630d40..5c7cd4f978f8 100644 --- a/src/libs/actions/PaymentMethods.ts +++ b/src/libs/actions/PaymentMethods.ts @@ -25,7 +25,6 @@ import ONYXKEYS from '@src/ONYXKEYS'; import type {Route} from '@src/ROUTES'; import INPUT_IDS from '@src/types/form/AddPaymentCardForm'; import type {BankAccountList, FundList} from '@src/types/onyx'; -import type {AccountData} from '@src/types/onyx/Fund'; import type {PaymentMethodType} from '@src/types/onyx/OriginalMessage'; import type PaymentMethod from '@src/types/onyx/PaymentMethod'; import type {OnyxData} from '@src/types/onyx/Request'; diff --git a/src/pages/workspace/WorkspaceOverviewPage.tsx b/src/pages/workspace/WorkspaceOverviewPage.tsx index 357839e23609..f7886f362b39 100644 --- a/src/pages/workspace/WorkspaceOverviewPage.tsx +++ b/src/pages/workspace/WorkspaceOverviewPage.tsx @@ -60,8 +60,11 @@ function WorkspaceOverviewPage({policyDraft, policy: policyProp, route}: Workspa const {activeWorkspaceID, setActiveWorkspaceID} = useActiveWorkspace(); const backTo = route.params.backTo; - const [currencyList = {}] = useOnyx(ONYXKEYS.CURRENCY_LIST); - const [currentUserAccountID = -1] = useOnyx(ONYXKEYS.SESSION, {selector: (session) => session?.accountID}); + const [currencyList = {}] = useOnyx(ONYXKEYS.CURRENCY_LIST, {canBeMissing: true}); + const [currentUserAccountID = -1] = useOnyx(ONYXKEYS.SESSION, { + selector: (session) => session?.accountID, + canBeMissing: true, + }); // When we create a new workspace, the policy prop will be empty on the first render. Therefore, we have to use policyDraft until policy has been set in Onyx. const policy = policyDraft?.id ? policyDraft : policyProp; @@ -72,8 +75,11 @@ function WorkspaceOverviewPage({policyDraft, policy: policyProp, route}: Workspa // We need this to update translation for deleting a workspace when it has third party card feeds or expensify card assigned. const workspaceAccountID = policy?.workspaceAccountID ?? CONST.DEFAULT_NUMBER_ID; - const [cardFeeds] = useOnyx(`${ONYXKEYS.COLLECTION.SHARED_NVP_PRIVATE_DOMAIN_MEMBER}${workspaceAccountID}`); - const [cardsList] = useOnyx(`${ONYXKEYS.COLLECTION.WORKSPACE_CARDS_LIST}${workspaceAccountID}_${CONST.EXPENSIFY_CARD.BANK}`, {selector: filterInactiveCards}); + const [cardFeeds] = useOnyx(`${ONYXKEYS.COLLECTION.SHARED_NVP_PRIVATE_DOMAIN_MEMBER}${workspaceAccountID}`, {canBeMissing: true}); + const [cardsList] = useOnyx(`${ONYXKEYS.COLLECTION.WORKSPACE_CARDS_LIST}${workspaceAccountID}_${CONST.EXPENSIFY_CARD.BANK}`, { + selector: filterInactiveCards, + canBeMissing: true, + }); const hasCardFeedOrExpensifyCard = // eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing !isEmptyObject(cardFeeds) || !isEmptyObject(cardsList) || ((policy?.areExpensifyCardsEnabled || policy?.areCompanyCardsEnabled) && policy?.workspaceAccountID); diff --git a/src/pages/workspace/WorkspacesListPage.tsx b/src/pages/workspace/WorkspacesListPage.tsx index ea3ea204b0ba..9409a43faa52 100755 --- a/src/pages/workspace/WorkspacesListPage.tsx +++ b/src/pages/workspace/WorkspacesListPage.tsx @@ -126,13 +126,13 @@ function WorkspacesListPage() { const {isOffline} = useNetwork(); const {activeWorkspaceID, setActiveWorkspaceID} = useActiveWorkspace(); const {shouldUseNarrowLayout, isMediumScreenWidth} = useResponsiveLayout(); - const [allConnectionSyncProgresses] = useOnyx(ONYXKEYS.COLLECTION.POLICY_CONNECTION_SYNC_PROGRESS); - const [policies] = useOnyx(ONYXKEYS.COLLECTION.POLICY); - const [reimbursementAccount] = useOnyx(ONYXKEYS.REIMBURSEMENT_ACCOUNT); - const [reports] = useOnyx(ONYXKEYS.COLLECTION.REPORT); - const [session] = useOnyx(ONYXKEYS.SESSION); - const [activePolicyID] = useOnyx(ONYXKEYS.NVP_ACTIVE_POLICY_ID); - const [isLoadingApp] = useOnyx(ONYXKEYS.IS_LOADING_APP); + const [allConnectionSyncProgresses] = useOnyx(ONYXKEYS.COLLECTION.POLICY_CONNECTION_SYNC_PROGRESS, {canBeMissing: true}); + const [policies] = useOnyx(ONYXKEYS.COLLECTION.POLICY, {canBeMissing: true}); + const [reimbursementAccount] = useOnyx(ONYXKEYS.REIMBURSEMENT_ACCOUNT, {canBeMissing: true}); + const [reports] = useOnyx(ONYXKEYS.COLLECTION.REPORT, {canBeMissing: true}); + const [session] = useOnyx(ONYXKEYS.SESSION, {canBeMissing: true}); + const [activePolicyID] = useOnyx(ONYXKEYS.NVP_ACTIVE_POLICY_ID, {canBeMissing: true}); + const [isLoadingApp] = useOnyx(ONYXKEYS.IS_LOADING_APP, {canBeMissing: true}); const shouldShowLoadingIndicator = isLoadingApp && !isOffline; const route = useRoute>(); @@ -143,8 +143,11 @@ function WorkspacesListPage() { // We need this to update translation for deleting a workspace when it has third party card feeds or expensify card assigned. const workspaceAccountID = policies?.[`${ONYXKEYS.COLLECTION.POLICY}${policyIDToDelete}`]?.workspaceAccountID ?? CONST.DEFAULT_NUMBER_ID; - const [cardFeeds] = useOnyx(`${ONYXKEYS.COLLECTION.SHARED_NVP_PRIVATE_DOMAIN_MEMBER}${workspaceAccountID}`); - const [cardsList] = useOnyx(`${ONYXKEYS.COLLECTION.WORKSPACE_CARDS_LIST}${workspaceAccountID}_${CONST.EXPENSIFY_CARD.BANK}`, {selector: filterInactiveCards}); + const [cardFeeds] = useOnyx(`${ONYXKEYS.COLLECTION.SHARED_NVP_PRIVATE_DOMAIN_MEMBER}${workspaceAccountID}`, {canBeMissing: true}); + const [cardsList] = useOnyx(`${ONYXKEYS.COLLECTION.WORKSPACE_CARDS_LIST}${workspaceAccountID}_${CONST.EXPENSIFY_CARD.BANK}`, { + selector: filterInactiveCards, + canBeMissing: true, + }); const policyToDelete = getPolicy(policyIDToDelete); const hasCardFeedOrExpensifyCard = !isEmptyObject(cardFeeds) || From c679fbbe18bf0c4e44a90de5cd238c571a98dd5b Mon Sep 17 00:00:00 2001 From: Povilas Zirgulis Date: Thu, 17 Apr 2025 10:25:00 +0300 Subject: [PATCH 5/5] fix eslint --- src/components/ThreeDotsMenu/index.tsx | 2 +- src/pages/workspace/WorkspaceOverviewPage.tsx | 2 +- src/pages/workspace/WorkspacesListPage.tsx | 25 +++++++++++-------- 3 files changed, 16 insertions(+), 13 deletions(-) diff --git a/src/components/ThreeDotsMenu/index.tsx b/src/components/ThreeDotsMenu/index.tsx index 3c5957d209ac..775cb76cf298 100644 --- a/src/components/ThreeDotsMenu/index.tsx +++ b/src/components/ThreeDotsMenu/index.tsx @@ -62,7 +62,7 @@ function ThreeDotsMenu({ setPopupMenuVisible(false); }; - useImperativeHandle(threeDotsMenuRef, () => ({ + useImperativeHandle(threeDotsMenuRef as React.RefObject<{hidePopoverMenu: () => void; isPopupMenuVisible: boolean}> | undefined, () => ({ isPopupMenuVisible, hidePopoverMenu, })); diff --git a/src/pages/workspace/WorkspaceOverviewPage.tsx b/src/pages/workspace/WorkspaceOverviewPage.tsx index 9727f372e051..7246f0aebaee 100644 --- a/src/pages/workspace/WorkspaceOverviewPage.tsx +++ b/src/pages/workspace/WorkspaceOverviewPage.tsx @@ -172,7 +172,7 @@ function WorkspaceOverviewPage({policyDraft, policy: policyProp, route}: Workspa const [isDeleteModalOpen, setIsDeleteModalOpen] = useState(false); - const {setIsDeletingPaidWorkspace, isLoadingBill} = usePayAndDowngrade(setIsDeleteModalOpen); + const {setIsDeletingPaidWorkspace, isLoadingBill}: {setIsDeletingPaidWorkspace: (value: boolean) => void; isLoadingBill: boolean | undefined} = usePayAndDowngrade(setIsDeleteModalOpen); const confirmDeleteAndHideModal = useCallback(() => { if (!policy?.id || !policyName) { diff --git a/src/pages/workspace/WorkspacesListPage.tsx b/src/pages/workspace/WorkspacesListPage.tsx index 215455c2d797..65edcb67d7d8 100755 --- a/src/pages/workspace/WorkspacesListPage.tsx +++ b/src/pages/workspace/WorkspacesListPage.tsx @@ -129,20 +129,20 @@ function WorkspacesListPage() { const {isOffline} = useNetwork(); const {activeWorkspaceID, setActiveWorkspaceID} = useActiveWorkspace(); const {shouldUseNarrowLayout, isMediumScreenWidth} = useResponsiveLayout(); - const [allConnectionSyncProgresses] = useOnyx(ONYXKEYS.COLLECTION.POLICY_CONNECTION_SYNC_PROGRESS); - const [policies] = useOnyx(ONYXKEYS.COLLECTION.POLICY); - const [reimbursementAccount] = useOnyx(ONYXKEYS.REIMBURSEMENT_ACCOUNT); - const [reports] = useOnyx(ONYXKEYS.COLLECTION.REPORT); - const [session] = useOnyx(ONYXKEYS.SESSION); - const [activePolicyID] = useOnyx(ONYXKEYS.NVP_ACTIVE_POLICY_ID); - const [isLoadingApp] = useOnyx(ONYXKEYS.IS_LOADING_APP); + const [allConnectionSyncProgresses] = useOnyx(ONYXKEYS.COLLECTION.POLICY_CONNECTION_SYNC_PROGRESS, {canBeMissing: true}); + const [policies] = useOnyx(ONYXKEYS.COLLECTION.POLICY, {canBeMissing: true}); + const [reimbursementAccount] = useOnyx(ONYXKEYS.REIMBURSEMENT_ACCOUNT, {canBeMissing: true}); + const [reports] = useOnyx(ONYXKEYS.COLLECTION.REPORT, {canBeMissing: true}); + const [session] = useOnyx(ONYXKEYS.SESSION, {canBeMissing: true}); + const [activePolicyID] = useOnyx(ONYXKEYS.NVP_ACTIVE_POLICY_ID, {canBeMissing: true}); + const [isLoadingApp] = useOnyx(ONYXKEYS.IS_LOADING_APP, {canBeMissing: true}); const shouldShowLoadingIndicator = isLoadingApp && !isOffline; const route = useRoute>(); const [isDeleteModalOpen, setIsDeleteModalOpen] = useState(false); const [policyIDToDelete, setPolicyIDToDelete] = useState(); const [policyNameToDelete, setPolicyNameToDelete] = useState(); - const {setIsDeletingPaidWorkspace, isLoadingBill} = usePayAndDowngrade(setIsDeleteModalOpen); + const {setIsDeletingPaidWorkspace, isLoadingBill}: {setIsDeletingPaidWorkspace: (value: boolean) => void; isLoadingBill: boolean | undefined} = usePayAndDowngrade(setIsDeleteModalOpen); const [loadingSpinnerIconIndex, setLoadingSpinnerIconIndex] = useState(null); @@ -150,8 +150,11 @@ function WorkspacesListPage() { // We need this to update translation for deleting a workspace when it has third party card feeds or expensify card assigned. const workspaceAccountID = policies?.[`${ONYXKEYS.COLLECTION.POLICY}${policyIDToDelete}`]?.workspaceAccountID ?? CONST.DEFAULT_NUMBER_ID; - const [cardFeeds] = useOnyx(`${ONYXKEYS.COLLECTION.SHARED_NVP_PRIVATE_DOMAIN_MEMBER}${workspaceAccountID}`); - const [cardsList] = useOnyx(`${ONYXKEYS.COLLECTION.WORKSPACE_CARDS_LIST}${workspaceAccountID}_${CONST.EXPENSIFY_CARD.BANK}`, {selector: filterInactiveCards}); + const [cardFeeds] = useOnyx(`${ONYXKEYS.COLLECTION.SHARED_NVP_PRIVATE_DOMAIN_MEMBER}${workspaceAccountID}`, {canBeMissing: true}); + const [cardsList] = useOnyx(`${ONYXKEYS.COLLECTION.WORKSPACE_CARDS_LIST}${workspaceAccountID}_${CONST.EXPENSIFY_CARD.BANK}`, { + selector: filterInactiveCards, + canBeMissing: true, + }); const policyToDelete = getPolicy(policyIDToDelete); const hasCardFeedOrExpensifyCard = !isEmptyObject(cardFeeds) || @@ -180,7 +183,7 @@ function WorkspacesListPage() { } }; - const shouldCalculateBillNewDot = shouldCalculateBillNewDotFn(); + const shouldCalculateBillNewDot: boolean = shouldCalculateBillNewDotFn(); const resetLoadingSpinnerIconIndex = useCallback(() => { setLoadingSpinnerIconIndex(null);