1
1
import { PrivyProvider } from "@privy-io/expo" ;
2
-
2
+ import { DevToolsBubble } from "react-native-react-query-devtools" ;
3
+ import * as Clipboard from "expo-clipboard" ;
3
4
// This is a requirement for Privy to work, does not make any sense
4
5
// To test run yarn start --no-dev --minify
5
6
6
- import { setupStreamingSubscriptions } from "@/features/streams/streams" ;
7
7
import { configure as configureCoinbase } from "@coinbase/wallet-mobile-sdk" ;
8
- import DebugButton from "@components/DebugButton" ;
8
+ import { DebugButton } from "@components/DebugButton" ;
9
+ import {
10
+ AppState ,
11
+ Platform ,
12
+ StyleSheet ,
13
+ View ,
14
+ useColorScheme ,
15
+ } from "react-native" ;
9
16
import { Snackbars } from "@components/Snackbar/Snackbars" ;
10
17
import { BottomSheetModalProvider } from "@design-system/BottomSheet/BottomSheetModalProvider" ;
11
18
import { useReactQueryDevTools } from "@dev-plugins/react-query" ;
12
19
import { ActionSheetProvider } from "@expo/react-native-action-sheet" ;
13
- import { useAppStateHandlers } from "@hooks/useAppStateHandlers" ;
14
20
import { SmartWalletsProvider } from "@privy-io/expo/smart-wallets" ;
15
21
import { queryClient } from "@queries/queryClient" ;
16
22
import { MaterialDarkTheme , MaterialLightTheme } from "@styles/colors" ;
17
- import { QueryClientProvider } from "@tanstack/react-query" ;
23
+ import { focusManager , QueryClientProvider } from "@tanstack/react-query" ;
18
24
import { useThemeProvider } from "@theme/useAppTheme" ;
19
25
import { setupAppAttest } from "@utils/appCheck" ;
20
26
import { useCoinbaseWalletListener } from "@utils/coinbaseWallet" ;
21
27
import { converseEventEmitter } from "@utils/events" ;
22
- import logger from "@utils/logger" ;
23
28
import "expo-dev-client" ;
24
29
import React , { useCallback , useEffect , useMemo , useRef } from "react" ;
25
- import {
26
- LogBox ,
27
- Platform ,
28
- StyleSheet ,
29
- View ,
30
- useColorScheme ,
31
- } from "react-native" ;
32
30
import { GestureHandlerRootView } from "react-native-gesture-handler" ;
33
31
import { KeyboardProvider } from "react-native-keyboard-controller" ;
34
32
import { Provider as PaperProvider } from "react-native-paper" ;
@@ -38,35 +36,60 @@ import {
38
36
} from "react-native-reanimated" ;
39
37
import { ThirdwebProvider } from "thirdweb/react" ;
40
38
import { config } from "./config" ;
41
- import {
42
- TEMPORARY_ACCOUNT_NAME ,
43
- useAccountsStore ,
44
- } from "./data/store/accountsStore" ;
45
- import { setAuthStatus } from "./data/store/authStore" ;
46
- import Main from "./screens/Main" ;
47
- import { registerBackgroundFetchTask } from "./utils/background" ;
39
+ import { Main } from "./screens/Main" ;
48
40
import { initSentry } from "./utils/sentry" ;
49
41
import { saveApiURI } from "./utils/sharedData" ;
50
42
import { preventSplashScreenAutoHide } from "./utils/splash/splash" ;
51
-
52
- preventSplashScreenAutoHide ( ) ;
53
-
54
- LogBox . ignoreLogs ( [
55
- "Privy: Expected status code 200, received 400" , // Privy
56
- "Error destroying session" , // Privy
57
- 'event="noNetwork' , // ethers
58
- "[Reanimated] Reading from `value` during component render. Please ensure that you do not access the `value` property or use `get` method of a shared value while React is rendering a component." ,
59
- "Attempted to import the module" , // General module import warnings
60
- 'Attempted to import the module "/Users' , // More specific module import warnings
61
- "Falling back to file-based resolution. Consider updating the call site or asking the package maintainer(s) to expose this API" ,
62
- "Couldn't find real values for `KeyboardContext`. Please make sure you're inside of `KeyboardProvider` - otherwise functionality of `react-native-keyboard-controller` will not work. [Component Stack]" ,
43
+ import { setupStreamingSubscriptions } from "@/features/streams/streams" ;
44
+ import {
45
+ // MultiInboxClient,
46
+ useInitializeMultiInboxClient ,
47
+ } from "@/features/multi-inbox/multi-inbox.client" ;
48
+ // import { useAppStateHandlers } from "./hooks/useAppStateHandlers";
49
+ // import { useInstalledWallets } from "@/features/wallets/use-installed-wallets.hook";
50
+ import logger from "./utils/logger" ;
51
+ // import { useAccountsStore } from "./features/multi-inbox/multi-inbox.store";
52
+ // import { AuthenticateWithPasskeyProvider } from "./features/onboarding/contexts/signup-with-passkey.context";
53
+ // import { PrivyPlaygroundLandingScreen } from "./features/privy-playground/privy-playground-landing.screen";
54
+
55
+ ! ! preventSplashScreenAutoHide && preventSplashScreenAutoHide ( ) ;
56
+
57
+ const IGNORED_LOGS = [
58
+ "Couldn't find real values for `KeyboardContext" ,
59
+ "Error destroying session" ,
60
+ 'event="noNetwork' ,
61
+ "[Reanimated] Reading from `value` during component render" ,
62
+ "Attempted to import the module" ,
63
+ 'Attempted to import the module "/Users' ,
64
+ "Falling back to file-based resolution" ,
63
65
"sync worker error storage error: Pool needs to reconnect before use" ,
64
- "[Converse.debug.dylib] sync worker error storage error: Pool needs to reconnect before use" ,
65
- "Falling back to file-based resolution. Consider updating the call site or asking the package maintainer(s) to expose this API." ,
66
- ] ) ;
66
+ "Require cycle" , // This will catch all require cycle warnings
67
+ ] ;
67
68
69
+ // Workaround for console filtering in development
68
70
if ( __DEV__ ) {
69
- require ( "./ReactotronConfig.ts" ) ;
71
+ const connectConsoleTextFromArgs = ( arrayOfStrings : string [ ] ) : string =>
72
+ arrayOfStrings
73
+ . slice ( 1 )
74
+ . reduce (
75
+ ( baseString , currentString ) => baseString . replace ( "%s" , currentString ) ,
76
+ arrayOfStrings [ 0 ]
77
+ ) ;
78
+
79
+ const filterIgnoredMessages =
80
+ ( consoleLog : typeof console . log ) =>
81
+ ( ...args : any [ ] ) => {
82
+ const output = connectConsoleTextFromArgs ( args ) ;
83
+
84
+ if ( ! IGNORED_LOGS . some ( ( log ) => output . includes ( log ) ) ) {
85
+ consoleLog ( ...args ) ;
86
+ }
87
+ } ;
88
+
89
+ console . log = filterIgnoredMessages ( console . log ) ;
90
+ console . info = filterIgnoredMessages ( console . info ) ;
91
+ console . warn = filterIgnoredMessages ( console . warn ) ;
92
+ console . error = filterIgnoredMessages ( console . error ) ;
70
93
}
71
94
72
95
// This is the default configuration
@@ -101,12 +124,9 @@ const App = () => {
101
124
setupStreamingSubscriptions ( ) ;
102
125
} , [ ] ) ;
103
126
127
+ const coinbaseUrl = new URL ( `https://${ config . websiteDomain } /coinbase` ) ;
104
128
useCoinbaseWalletListener ( true , coinbaseUrl ) ;
105
129
106
- useEffect ( ( ) => {
107
- registerBackgroundFetchTask ( ) ;
108
- } , [ ] ) ;
109
-
110
130
const showDebugMenu = useCallback ( ( ) => {
111
131
if ( ! debugRef . current || ! ( debugRef . current as any ) . showDebugMenu ) {
112
132
return ;
@@ -120,28 +140,14 @@ const App = () => {
120
140
converseEventEmitter . off ( "showDebugMenu" , showDebugMenu ) ;
121
141
} ;
122
142
} , [ showDebugMenu ] ) ;
123
-
124
- // For now we use persit with zustand to get the accounts when the app launch so here is okay to see if we're logged in or not
125
143
useEffect ( ( ) => {
126
- const currentAccount = useAccountsStore . getState ( ) . currentAccount ;
127
- if ( currentAccount && currentAccount !== TEMPORARY_ACCOUNT_NAME ) {
128
- setAuthStatus ( "signedIn" ) ;
129
- } else {
130
- setAuthStatus ( "signedOut" ) ;
131
- }
144
+ AppState . addEventListener ( "change" , ( state ) => {
145
+ logger . debug ( "[App] AppState changed to" , state ) ;
146
+ focusManager . setFocused ( state === "active" ) ;
147
+ } ) ;
132
148
} , [ ] ) ;
133
149
134
- useAppStateHandlers ( {
135
- onBackground ( ) {
136
- logger . debug ( "App is in background" ) ;
137
- } ,
138
- onForeground ( ) {
139
- logger . debug ( "App is in foreground" ) ;
140
- } ,
141
- onInactive ( ) {
142
- logger . debug ( "App is inactive" ) ;
143
- } ,
144
- } ) ;
150
+ // For now we use persit with zustand to get the accounts when the app launch so here is okay to see if we're logged in or not
145
151
146
152
return (
147
153
< View style = { styles . safe } >
@@ -154,8 +160,10 @@ const App = () => {
154
160
// On Android we use the default keyboard "animation"
155
161
const AppKeyboardProvider =
156
162
Platform . OS === "ios" ? KeyboardProvider : React . Fragment ;
163
+ // import { DevToolsBubble } from "react-native-react-query-devtools";
157
164
158
- export default function AppWithProviders ( ) {
165
+ export function AppWithProviders ( ) {
166
+ useInitializeMultiInboxClient ( ) ;
159
167
const colorScheme = useColorScheme ( ) ;
160
168
161
169
const paperTheme = useMemo ( ( ) => {
@@ -167,6 +175,18 @@ export default function AppWithProviders() {
167
175
const { themeScheme, setThemeContextOverride, ThemeProvider } =
168
176
useThemeProvider ( ) ;
169
177
178
+ const onCopy = async ( text : string ) => {
179
+ try {
180
+ // For Expo:
181
+ await Clipboard . setStringAsync ( text ) ;
182
+ // OR for React Native CLI:
183
+ // await Clipboard.setString(text);
184
+ return true ;
185
+ } catch {
186
+ return false ;
187
+ }
188
+ } ;
189
+
170
190
return (
171
191
< QueryClientProvider client = { queryClient } >
172
192
< PrivyProvider
@@ -184,6 +204,10 @@ export default function AppWithProviders() {
184
204
< GestureHandlerRootView style = { { flex : 1 } } >
185
205
< BottomSheetModalProvider >
186
206
< App />
207
+ { /* <AuthenticateWithPasskeyProvider>
208
+ <PrivyPlaygroundLandingScreen />
209
+ </AuthenticateWithPasskeyProvider> */ }
210
+ { __DEV__ && < DevToolsBubble onCopy = { onCopy } /> }
187
211
< Snackbars />
188
212
</ BottomSheetModalProvider >
189
213
</ GestureHandlerRootView >
0 commit comments