Skip to content

Commit

Permalink
Merge pull request Expensify#34742 from callstack-internal/pac-guerre…
Browse files Browse the repository at this point in the history
…iro/refactor/migrate-workspacenewroompage-to-typescript

[TS migration] Migrate 'WorkspaceNewRoom' page to TypeScript
  • Loading branch information
arosiclair authored Feb 22, 2024
2 parents adef2de + 2f466c3 commit 440c43e
Show file tree
Hide file tree
Showing 6 changed files with 99 additions and 132 deletions.
1 change: 1 addition & 0 deletions src/CONST.ts
Original file line number Diff line number Diff line change
Expand Up @@ -895,6 +895,7 @@ const CONST = {
DEFAULT_TIME_ZONE: {automatic: true, selected: 'America/Los_Angeles'},
DEFAULT_ACCOUNT_DATA: {errors: null, success: '', isLoading: false},
DEFAULT_CLOSE_ACCOUNT_DATA: {errors: null, success: '', isLoading: false},
DEFAULT_NETWORK_DATA: {isOffline: false},
FORMS: {
LOGIN_FORM: 'LoginForm',
VALIDATE_CODE_FORM: 'ValidateCodeForm',
Expand Down
14 changes: 12 additions & 2 deletions src/components/ScreenWrapper.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import SafeAreaConsumer from './SafeAreaConsumer';
import TestToolsModal from './TestToolsModal';

type ChildrenProps = {
insets?: EdgeInsets;
insets: EdgeInsets;
safeAreaPaddingBottomStyle?: {
paddingBottom?: DimensionValue;
};
Expand Down Expand Up @@ -201,7 +201,17 @@ function ScreenWrapper(

return (
<SafeAreaConsumer>
{({insets, paddingTop, paddingBottom, safeAreaPaddingBottomStyle}) => {
{({
insets = {
top: 0,
bottom: 0,
left: 0,
right: 0,
},
paddingTop,
paddingBottom,
safeAreaPaddingBottomStyle,
}) => {
const paddingStyle: StyleProp<ViewStyle> = {};

if (includePaddingTop) {
Expand Down
5 changes: 3 additions & 2 deletions src/hooks/useNetwork.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,18 @@
import {useContext, useEffect, useRef} from 'react';
import {NetworkContext} from '@components/OnyxProvider';
import CONST from '@src/CONST';

type UseNetworkProps = {
onReconnect?: () => void;
};

type UseNetwork = {isOffline?: boolean};
type UseNetwork = {isOffline: boolean};

export default function useNetwork({onReconnect = () => {}}: UseNetworkProps = {}): UseNetwork {
const callback = useRef(onReconnect);
callback.current = onReconnect;

const {isOffline} = useContext(NetworkContext) ?? {};
const {isOffline} = useContext(NetworkContext) ?? CONST.DEFAULT_NETWORK_DATA;
const prevOfflineStatusRef = useRef(isOffline);
useEffect(() => {
// If we were offline before and now we are not offline then we just reconnected
Expand Down
Loading

0 comments on commit 440c43e

Please sign in to comment.