-
Notifications
You must be signed in to change notification settings - Fork 635
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Backups V2 Follow-up Fixes / Improvements #6213
Changes from all commits
c035b9f
ea2fd09
3735f81
4afed74
fb913bc
afc42bf
6946626
9ea81dd
fd16a13
00d1bff
7016d47
5420054
c20670c
5784cb2
0c81b5f
1fadaf5
a9948af
5c5a848
6d7b6fa
9823919
7b18523
1f42ab9
466f3dc
461ee79
053231c
e1569fa
176cac6
11f079f
ebd631d
25bb9c2
664a035
f550f68
3ccb2fb
e995093
380103f
d0fd2e3
11fbc3c
109ca08
7dfd7e2
64d075b
48c346a
515691b
ee330be
869a1fe
f9249f8
308437a
7494991
1b4e81f
1091d47
fc5ee51
6ccfad1
1b149e9
ff305c6
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
import '@/languages'; | ||
import * as Sentry from '@sentry/react-native'; | ||
import React, { useCallback, useEffect, useState } from 'react'; | ||
import React, { useCallback, useEffect, useState, memo } from 'react'; | ||
import { AppRegistry, Dimensions, LogBox, StyleSheet, View } from 'react-native'; | ||
import { Toaster } from 'sonner-native'; | ||
import { MobileWalletProtocolProvider } from '@coinbase/mobile-wallet-protocol-host'; | ||
|
@@ -9,9 +9,8 @@ import { useApplicationSetup } from '@/hooks/useApplicationSetup'; | |
import { GestureHandlerRootView } from 'react-native-gesture-handler'; | ||
import { SafeAreaProvider, useSafeAreaInsets } from 'react-native-safe-area-context'; | ||
import { enableScreens } from 'react-native-screens'; | ||
import { connect, Provider as ReduxProvider } from 'react-redux'; | ||
import { connect, Provider as ReduxProvider, shallowEqual } from 'react-redux'; | ||
import { RecoilRoot } from 'recoil'; | ||
import PortalConsumer from '@/components/PortalConsumer'; | ||
import ErrorBoundary from '@/components/error-boundary/ErrorBoundary'; | ||
import { OfflineToast } from '@/components/toasts'; | ||
import { designSystemPlaygroundEnabled, reactNativeDisableYellowBox, showNetworkRequests, showNetworkResponses } from '@/config/debug'; | ||
|
@@ -24,7 +23,6 @@ import store, { AppDispatch, type AppState } from '@/redux/store'; | |
import { MainThemeProvider } from '@/theme/ThemeContext'; | ||
import { SharedValuesProvider } from '@/helpers/SharedValuesContext'; | ||
import { InitialRouteContext } from '@/navigation/initialRoute'; | ||
import { Portal } from '@/react-native-cool-modals/Portal'; | ||
import { NotificationsHandler } from '@/notifications/NotificationsHandler'; | ||
import { analyticsV2 } from '@/analytics'; | ||
import { getOrCreateDeviceId } from '@/analytics/utils'; | ||
|
@@ -39,6 +37,7 @@ import { RootStackParamList } from '@/navigation/types'; | |
import { IS_ANDROID, IS_DEV } from '@/env'; | ||
import { prefetchDefaultFavorites } from '@/resources/favorites'; | ||
import Routes from '@/navigation/Routes'; | ||
import { BackupsSync } from '@/state/sync/BackupsSync'; | ||
import { BackendNetworks } from '@/components/BackendNetworks'; | ||
import { AbsolutePortalRoot } from './components/AbsolutePortal'; | ||
|
||
|
@@ -68,28 +67,39 @@ function App({ walletReady }: AppProps) { | |
}, []); | ||
|
||
return ( | ||
<Portal> | ||
<> | ||
<View style={[sx.container, { paddingBottom: IS_ANDROID ? bottom : 0 }]}> | ||
{initialRoute && ( | ||
<InitialRouteContext.Provider value={initialRoute}> | ||
<Routes ref={handleNavigatorRef} /> | ||
<PortalConsumer /> | ||
<AbsolutePortalRoot /> | ||
</InitialRouteContext.Provider> | ||
)} | ||
<OfflineToast /> | ||
<Toaster /> | ||
</View> | ||
<NotificationsHandler walletReady={walletReady} /> | ||
<DeeplinkHandler initialRoute={initialRoute} walletReady={walletReady} /> | ||
<BackupsSync /> | ||
<BackendNetworks /> | ||
</Portal> | ||
<AbsolutePortalRoot /> | ||
</> | ||
); | ||
} | ||
|
||
const AppWithRedux = connect<AppProps, AppDispatch, AppProps, AppState>(state => ({ | ||
walletReady: state.appState.walletReady, | ||
}))(App); | ||
const AppWithRedux = connect<AppProps, AppDispatch, AppProps, AppState>( | ||
state => ({ | ||
walletReady: state.appState.walletReady, | ||
}), | ||
null, | ||
null, | ||
{ | ||
areStatesEqual: (next, prev) => { | ||
// Only update if walletReady actually changed | ||
return next.appState.walletReady === prev.appState.walletReady; | ||
}, | ||
areOwnPropsEqual: shallowEqual, | ||
} | ||
)(memo(App)); | ||
Comment on lines
+89
to
+102
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. we only really want to re-render the App when walletReady has changed.. this fixes that |
||
|
||
function Root() { | ||
const [initializing, setInitializing] = useState(true); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
import React, { PropsWithChildren, ReactNode, useEffect, useState } from 'react'; | ||
import { View } from 'react-native'; | ||
import { StyleProp, ViewStyle, View } from 'react-native'; | ||
|
||
const absolutePortal = { | ||
nodes: [] as ReactNode[], | ||
|
@@ -24,15 +24,15 @@ const absolutePortal = { | |
}, | ||
}; | ||
|
||
export const AbsolutePortalRoot = () => { | ||
export const AbsolutePortalRoot = ({ style }: { style?: StyleProp<ViewStyle> }) => { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. are you using this component? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yes |
||
const [nodes, setNodes] = useState(absolutePortal.nodes); | ||
|
||
useEffect(() => { | ||
const unsubscribe = absolutePortal.subscribe(setNodes); | ||
return () => unsubscribe(); | ||
}, []); | ||
|
||
return <View style={{ position: 'absolute', top: 0, left: 0, right: 0, bottom: 0, pointerEvents: 'box-none' }}>{nodes}</View>; | ||
return <View style={[style, { position: 'absolute', top: 0, left: 0, right: 0, bottom: 0, pointerEvents: 'box-none' }]}>{nodes}</View>; | ||
}; | ||
|
||
export const AbsolutePortal = ({ children }: PropsWithChildren) => { | ||
|
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import React, { useEffect } from 'react'; | ||
import { LoadingOverlay } from './modal'; | ||
import { sheetVerticalOffset } from '@/navigation/effects'; | ||
import { walletLoadingStore } from '@/state/walletLoading/walletLoading'; | ||
|
||
export default function WalletLoadingListener() { | ||
const loadingState = walletLoadingStore(state => state.loadingState); | ||
|
||
useEffect(() => { | ||
if (loadingState) { | ||
walletLoadingStore.getState().setComponent(<LoadingOverlay paddingTop={sheetVerticalOffset} title={loadingState} />); | ||
} | ||
return walletLoadingStore.getState().hide; | ||
}, [loadingState]); | ||
|
||
return null; | ||
} |
This file was deleted.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In charge of initial backup store sync on mount