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
6 changes: 3 additions & 3 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@
"react-native-pdf": "6.7.3",
"react-native-performance": "^5.1.0",
"react-native-permissions": "^3.9.3",
"react-native-picker-select": "git+https://github.com/Expensify/react-native-picker-select.git#7a407cd4174d9838a944c1c2e1cb4a9737ac69c5",
"react-native-picker-select": "git+https://github.com/Expensify/react-native-picker-select.git#42b334d0c4e71d225601f72828d3dedd0bc22212",
Comment thread
mkhutornyi marked this conversation as resolved.
Resolved
"react-native-plaid-link-sdk": "10.8.0",
"react-native-qrcode-svg": "^6.2.0",
"react-native-quick-sqlite": "^8.0.0-beta.2",
Expand Down
17 changes: 6 additions & 11 deletions src/App.js → src/App.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import {PortalProvider} from '@gorhom/portal';
import PropTypes from 'prop-types';
import React from 'react';
import {LogBox} from 'react-native';
import {GestureHandlerRootView} from 'react-native-gesture-handler';
Expand Down Expand Up @@ -32,14 +31,11 @@ import * as Session from './libs/actions/Session';
import * as Environment from './libs/Environment/Environment';
import InitialUrlContext from './libs/InitialUrlContext';
import {ReportAttachmentsProvider} from './pages/home/report/ReportAttachmentsContext';
import type {Route} from './ROUTES';

const propTypes = {
/** Initial url that may be passed as deeplink from Hybrid App */
url: PropTypes.string,
};

const defaultProps = {
url: undefined,
type AppProps = {
/** If we have an authToken this is true */
url?: Route;
};

// For easier debugging and development, when we are in web we expose Onyx to the window, so you can more easily set data into Onyx
Expand All @@ -57,7 +53,7 @@ LogBox.ignoreLogs([

const fill = {flex: 1};

function App({url}) {
function App({url}: AppProps) {
useDefaultDragAndDrop();
OnyxUpdateManager();
return (
Expand Down Expand Up @@ -88,6 +84,7 @@ function App({url}) {
<CustomStatusBarAndBackground />
<ErrorBoundary errorMessage="NewExpensify crash caught by error boundary">
<ColorSchemeWrapper>
{/* @ts-expect-error TODO: Remove this once Expensify (https://github.com/Expensify/App/issues/25231) is migrated to TypeScript. */}
<Expensify />
</ColorSchemeWrapper>
</ErrorBoundary>
Expand All @@ -97,8 +94,6 @@ function App({url}) {
);
}

App.propTypes = propTypes;
App.defaultProps = defaultProps;
App.displayName = 'App';

export default App;
2 changes: 1 addition & 1 deletion src/components/CustomStatusBarAndBackground/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import updateStatusBarAppearance from './updateStatusBarAppearance';
type CustomStatusBarAndBackgroundProps = {
/** Whether the CustomStatusBar is nested within another CustomStatusBar.
* A nested CustomStatusBar will disable the "root" CustomStatusBar. */
isNested: boolean;
isNested?: boolean;
};

function CustomStatusBarAndBackground({isNested = false}: CustomStatusBarAndBackgroundProps) {
Expand Down
8 changes: 0 additions & 8 deletions src/components/ThemeProvider.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
/* eslint-disable react/jsx-props-no-spreading */
import PropTypes from 'prop-types';
import React, {useEffect, useMemo} from 'react';
import useThemePreferenceWithStaticOverride from '@hooks/useThemePreferenceWithStaticOverride';
import DomUtils from '@libs/DomUtils';
Expand All @@ -8,11 +6,6 @@ import themes from '@styles/theme';
import ThemeContext from '@styles/theme/context/ThemeContext';
import type {ThemePreferenceWithoutSystem} from '@styles/theme/types';

const propTypes = {
/** Rendered child component */
children: PropTypes.node.isRequired,
};

type ThemeProviderProps = React.PropsWithChildren & {
theme?: ThemePreferenceWithoutSystem;
};
Expand All @@ -29,7 +22,6 @@ function ThemeProvider({children, theme: staticThemePreference}: ThemeProviderPr
return <ThemeContext.Provider value={theme}>{children}</ThemeContext.Provider>;
}

ThemeProvider.propTypes = propTypes;
ThemeProvider.displayName = 'ThemeProvider';

export default ThemeProvider;
Original file line number Diff line number Diff line change
@@ -1,17 +1,20 @@
import PropTypes from 'prop-types';
import React, {useEffect, useMemo, useRef} from 'react';
import useCurrentReportID from '@hooks/useCurrentReportID';
import type ChildrenProps from '@src/types/utils/ChildrenProps';

const ReportAttachmentsContext = React.createContext();

const propTypes = {
/** Rendered child component */
children: PropTypes.node.isRequired,
type ReportAttachmentsContextValue = {
isAttachmentHidden: (reportActionID: string) => boolean;
updateHiddenAttachments: (reportActionID: string, isHidden: boolean) => void;
};

function ReportAttachmentsProvider(props) {
const ReportAttachmentsContext = React.createContext<ReportAttachmentsContextValue>({
isAttachmentHidden: () => false,
updateHiddenAttachments: () => {},
});

function ReportAttachmentsProvider({children}: ChildrenProps) {
const currentReportID = useCurrentReportID();
const hiddenAttachments = useRef({});
const hiddenAttachments = useRef<Record<string, boolean>>({});

useEffect(() => {
// We only want to store the attachment visibility for the current report.
Expand All @@ -21,8 +24,8 @@ function ReportAttachmentsProvider(props) {

const contextValue = useMemo(
() => ({
isAttachmentHidden: (reportActionID) => hiddenAttachments.current[reportActionID],
updateHiddenAttachments: (reportActionID, value) => {
isAttachmentHidden: (reportActionID: string) => hiddenAttachments.current[reportActionID],
updateHiddenAttachments: (reportActionID: string, value: boolean) => {
hiddenAttachments.current = {
...hiddenAttachments.current,
[reportActionID]: value,
Expand All @@ -32,10 +35,9 @@ function ReportAttachmentsProvider(props) {
[],
);

return <ReportAttachmentsContext.Provider value={contextValue}>{props.children}</ReportAttachmentsContext.Provider>;
return <ReportAttachmentsContext.Provider value={contextValue}>{children}</ReportAttachmentsContext.Provider>;
}

ReportAttachmentsProvider.propTypes = propTypes;
ReportAttachmentsProvider.displayName = 'ReportAttachmentsProvider';

export default ReportAttachmentsContext;
Expand Down
4 changes: 1 addition & 3 deletions src/types/global.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,7 @@ declare module '*.lottie' {
export default value;
}

// Global methods for Onyx key management for debugging purposes
// eslint-disable-next-line @typescript-eslint/consistent-type-definitions
interface Window {
enableMemoryOnlyKeys: () => void;
disableMemoryOnlyKeys: () => void;
setSupportToken: (token: string, email: string, accountID: number) => void;
}
11 changes: 11 additions & 0 deletions src/types/modules/react-native-onyx.d.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import type Onyx from 'react-native-onyx';
import type {OnyxCollectionKey, OnyxKey, OnyxValues} from '@src/ONYXKEYS';

declare module 'react-native-onyx' {
Expand All @@ -8,3 +9,13 @@ declare module 'react-native-onyx' {
values: OnyxValues;
}
}

declare global {
// Global methods for Onyx key management for debugging purposes
// eslint-disable-next-line @typescript-eslint/consistent-type-definitions
interface Window {
enableMemoryOnlyKeys: () => void;
disableMemoryOnlyKeys: () => void;
Onyx: typeof Onyx;
}
}