Skip to content

Commit

Permalink
Merge pull request #4265 from tloncorp/lb/store-from-context
Browse files Browse the repository at this point in the history
store: add provider for accessing within ui components
  • Loading branch information
latter-bolden authored Dec 9, 2024
2 parents ca81904 + 89f58f2 commit 6d28e1d
Show file tree
Hide file tree
Showing 10 changed files with 275 additions and 192 deletions.
69 changes: 37 additions & 32 deletions apps/tlon-mobile/src/App.main.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import { finishingSelfHostedLogin as selfHostedLoginStatus } from '@tloncorp/sha
import {
LoadingSpinner,
PortalProvider,
StoreProvider,
Text,
View,
usePreloadedEmojis,
Expand Down Expand Up @@ -127,39 +128,43 @@ export default function ConnectedApp() {
theme={isDarkMode ? DarkTheme : DefaultTheme}
ref={navigationContainerRef}
>
<BranchProvider>
<PostHogProvider
client={posthogAsync}
autocapture={{
captureTouches: false,
}}
options={{
enable:
process.env.NODE_ENV !== 'test' ||
!!process.env.POST_HOG_IN_DEV,
}}
>
<GestureHandlerRootView style={{ flex: 1 }}>
<SafeAreaProvider>
<MigrationCheck>
<QueryClientProvider client={queryClient}>
<SignupProvider>
<PortalProvider>
<App />
</PortalProvider>
<StoreProvider>
<BranchProvider>
<PostHogProvider
client={posthogAsync}
autocapture={{
captureTouches: false,
}}
options={{
enable:
process.env.NODE_ENV !== 'test' ||
!!process.env.POST_HOG_IN_DEV,
}}
>
<GestureHandlerRootView style={{ flex: 1 }}>
<SafeAreaProvider>
<MigrationCheck>
<QueryClientProvider client={queryClient}>
<SignupProvider>
<PortalProvider>
<App />
</PortalProvider>

{__DEV__ && (
<DevTools
navigationContainerRef={navigationContainerRef}
/>
)}
</SignupProvider>
</QueryClientProvider>
</MigrationCheck>
</SafeAreaProvider>
</GestureHandlerRootView>
</PostHogProvider>
</BranchProvider>
{__DEV__ && (
<DevTools
navigationContainerRef={
navigationContainerRef
}
/>
)}
</SignupProvider>
</QueryClientProvider>
</MigrationCheck>
</SafeAreaProvider>
</GestureHandlerRootView>
</PostHogProvider>
</BranchProvider>
</StoreProvider>
</NavigationContainer>
</ShipProvider>
</TamaguiProvider>
Expand Down
6 changes: 4 additions & 2 deletions apps/tlon-mobile/src/fixtures/cosmos.decorator.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
import { TamaguiProvider, config } from '@tloncorp/ui';
import { StoreProvider, TamaguiProvider, config } from '@tloncorp/ui';
import React from 'react';
import { SafeAreaProvider } from 'react-native-safe-area-context';

// eslint-disable-next-line
export default ({ children }: { children: React.ReactNode }) => (
<TamaguiProvider defaultTheme={'light'} config={config}>
<SafeAreaProvider>{children}</SafeAreaProvider>
<StoreProvider stub>
<SafeAreaProvider>{children}</SafeAreaProvider>
</StoreProvider>
</TamaguiProvider>
);
28 changes: 15 additions & 13 deletions apps/tlon-web-new/src/app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import { Provider as TamaguiProvider } from '@tloncorp/app/provider';
import { AppDataProvider } from '@tloncorp/app/provider/AppDataProvider';
import { sync } from '@tloncorp/shared';
import * as store from '@tloncorp/shared/store';
import { LoadingSpinner, View } from '@tloncorp/ui';
import { LoadingSpinner, StoreProvider, View } from '@tloncorp/ui';
import cookies from 'browser-cookies';
import { usePostHog } from 'posthog-js/react';
import React, { PropsWithChildren, useEffect, useState } from 'react';
Expand Down Expand Up @@ -184,18 +184,20 @@ const App = React.memo(function AppComponent() {
<MigrationCheck>
<SafeAreaProvider>
<TamaguiProvider defaultTheme={isDarkMode ? 'dark' : 'light'}>
{dbIsLoaded ? (
<AppRoutes isLoaded={dbIsLoaded} />
) : (
<View
height="100%"
width="100%"
justifyContent="center"
alignItems="center"
>
<LoadingSpinner />
</View>
)}
<StoreProvider>
{dbIsLoaded ? (
<AppRoutes isLoaded={dbIsLoaded} />
) : (
<View
height="100%"
width="100%"
justifyContent="center"
alignItems="center"
>
<LoadingSpinner />
</View>
)}
</StoreProvider>
</TamaguiProvider>
</SafeAreaProvider>
</MigrationCheck>
Expand Down
Loading

0 comments on commit 6d28e1d

Please sign in to comment.