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
2 changes: 1 addition & 1 deletion src/components/HTMLEngineProvider/htmlEngineUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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};
2 changes: 1 addition & 1 deletion src/components/InputBlurContext/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,4 @@ function useInputBlurContext() {
return useContext(InputBlurContext);
}

export {InputBlurContext, useInputBlurContext, InputBlurContextProvider};
export {useInputBlurContext, InputBlurContextProvider};
4 changes: 2 additions & 2 deletions src/components/MultiGestureCanvas/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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};
8 changes: 4 additions & 4 deletions src/components/OptionListContextProvider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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) {
Expand All @@ -202,4 +202,4 @@ const useOptionsList = (options?: {shouldInitialize: boolean}) => {

export default OptionsListContextProvider;

export {useOptionsListContext, useOptionsList, OptionsListContext};
export {useOptionsList, OptionsListContext};
2 changes: 1 addition & 1 deletion src/components/ThreeDotsMenu/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ function ThreeDotsMenu({
setPopupMenuVisible(false);
};

useImperativeHandle(threeDotsMenuRef, () => ({
useImperativeHandle(threeDotsMenuRef as React.RefObject<{hidePopoverMenu: () => void; isPopupMenuVisible: boolean}> | undefined, () => ({
isPopupMenuVisible,
hidePopoverMenu,
}));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,9 @@ function BaseValidateCodeForm({
const [formError, setFormError] = useState<ValidateCodeFormError>({});
const [validateCode, setValidateCode] = useState('');
const inputValidateCodeRef = useRef<MagicCodeInputHandle>(null);
const [account = {}] = useOnyx(ONYXKEYS.ACCOUNT, {canBeMissing: true});
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<NodeJS.Timeout | null>(null);
Expand Down
32 changes: 5 additions & 27 deletions src/components/withEnvironment.tsx
Original file line number Diff line number Diff line change
@@ -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 {getEnvironment, getEnvironmentURL} from '@libs/Environment/Environment';
import CONST from '@src/CONST';

type EnvironmentProviderProps = {
Expand Down Expand Up @@ -30,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(
Expand All @@ -47,26 +46,5 @@ function EnvironmentProvider({children}: EnvironmentProviderProps): ReactElement

EnvironmentProvider.displayName = 'EnvironmentProvider';

export default function withEnvironment<TProps extends EnvironmentContextValue, TRef>(
WrappedComponent: ComponentType<TProps & RefAttributes<TRef>>,
): (props: Omit<TProps, keyof EnvironmentContextValue> & React.RefAttributes<TRef>) => ReactElement | null {
function WithEnvironment(props: Omit<TProps, keyof EnvironmentContextValue>, ref: ForwardedRef<TRef>): ReactElement {
const {environment, environmentURL} = useContext(EnvironmentContext);
return (
<WrappedComponent
// eslint-disable-next-line react/jsx-props-no-spreading
{...(props as TProps)}
ref={ref}
environment={environment}
environmentURL={environmentURL}
/>
);
}

WithEnvironment.displayName = `withEnvironment(${getComponentDisplayName(WrappedComponent)})`;

return forwardRef(WithEnvironment);
}

export {EnvironmentContext, EnvironmentProvider};
export type {EnvironmentContextValue};

This file was deleted.

1 change: 0 additions & 1 deletion src/libs/API/parameters/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,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';
Expand Down
2 changes: 0 additions & 2 deletions src/libs/API/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down Expand Up @@ -776,7 +775,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;
Expand Down
34 changes: 0 additions & 34 deletions src/libs/CardUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 %<bank> - <lastFourPAN || Not Activated>%.
Expand All @@ -92,10 +84,6 @@ function isCard(item: Card | Record<string, string>): 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);
}
Expand Down Expand Up @@ -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<string, Card>): 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, '');
}
Expand Down Expand Up @@ -610,16 +580,13 @@ function getFundIdFromSettingsKey(key: string) {

export {
isExpensifyCard,
isCorporateCard,
getDomainCards,
formatCardExpiration,
getMonthFromExpirationDateString,
getYearFromExpirationDateString,
maskCard,
maskCardNumber,
getCardDescription,
findPhysicalCard,
hasDetectedFraud,
getMCardNumberString,
getTranslationKeyForLimitType,
getEligibleBankAccountsForCard,
Expand All @@ -641,7 +608,6 @@ export {
mergeCardListWithWorkspaceFeeds,
isCard,
getAllCardsForWorkspace,
isCardIssued,
isCardHiddenFromSearch,
getFeedType,
flatAllCardsList,
Expand Down
6 changes: 2 additions & 4 deletions src/libs/ComponentUtils/index.native.ts
Original file line number Diff line number Diff line change
@@ -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';

/**
Expand All @@ -17,4 +15,4 @@ function forceClearInput(animatedInputRef: AnimatedRef<Component>) {
dispatchCommand(animatedInputRef, 'clear');
}

export {PASSWORD_AUTOCOMPLETE_TYPE, ACCESSIBILITY_ROLE_FORM, NEW_PASSWORD_AUTOCOMPLETE_TYPE, forceClearInput};
export {ACCESSIBILITY_ROLE_FORM, forceClearInput};
6 changes: 2 additions & 4 deletions src/libs/ComponentUtils/index.ts
Original file line number Diff line number Diff line change
@@ -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<Component>) {
Expand All @@ -18,4 +16,4 @@ function forceClearInput(animatedInputRef: AnimatedRef<Component>) {
}
}

export {PASSWORD_AUTOCOMPLETE_TYPE, ACCESSIBILITY_ROLE_FORM, NEW_PASSWORD_AUTOCOMPLETE_TYPE, forceClearInput};
export {ACCESSIBILITY_ROLE_FORM, forceClearInput};
4 changes: 1 addition & 3 deletions src/libs/ComponentUtils/types.ts
Original file line number Diff line number Diff line change
@@ -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;
4 changes: 2 additions & 2 deletions src/libs/E2E/reactNativeLaunchingTest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -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!');
}

Expand Down
8 changes: 0 additions & 8 deletions src/libs/EmojiUtils.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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
*/
Expand Down Expand Up @@ -687,7 +680,6 @@ export {
containsOnlyEmojis,
replaceEmojis,
suggestEmojis,
trimEmojiUnicode,
getEmojiCodeWithSkinColor,
getPreferredSkinToneIndex,
getPreferredEmojiCode,
Expand Down
9 changes: 2 additions & 7 deletions src/libs/Metrics/index.native.ts
Original file line number Diff line number Diff line change
@@ -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;
7 changes: 2 additions & 5 deletions src/libs/Metrics/index.ts
Original file line number Diff line number Diff line change
@@ -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;
3 changes: 1 addition & 2 deletions src/libs/Metrics/types.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
type CanCapturePerformanceMetrics = () => boolean;
type CanCaptureOnyxMetrics = () => boolean;

export type {CanCapturePerformanceMetrics, CanCaptureOnyxMetrics};
export default CanCapturePerformanceMetrics;
30 changes: 1 addition & 29 deletions src/libs/MoneyRequestUtils.ts
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -82,29 +79,4 @@ function replaceAllDigits(text: string, convertFn: (char: string) => string): st
.join('');
}

/**
* Check if distance expense or not
*/
function isDistanceRequest(iouType: IOUType, selectedTab: OnyxEntry<SelectedTabRequest>): 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,
stripSpacesFromAmount,
replaceCommasWithPeriod,
validateAmount,
validatePercentage,
};
export {addLeadingZero, replaceAllDigits, stripCommaFromAmount, stripDecimalsFromAmount, stripSpacesFromAmount, replaceCommasWithPeriod, validateAmount, validatePercentage};
Loading