Skip to content

Commit

Permalink
fix: ui refresh migration (#1266)
Browse files Browse the repository at this point in the history
  • Loading branch information
tyleroooo authored Nov 7, 2024
1 parent 372ab05 commit 45daeb0
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 1 deletion.
26 changes: 25 additions & 1 deletion src/App.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { lazy, Suspense, useMemo } from 'react';
import { lazy, Suspense, useEffect, useMemo } from 'react';

import isPropValid from '@emotion/is-prop-valid';
import { FunkitProvider } from '@funkit/connect';
Expand Down Expand Up @@ -46,11 +46,13 @@ import { config, privyConfig } from '@/lib/wagmi';
import { RestrictionWarning } from './components/RestrictionWarning';
import { ComplianceStates } from './constants/compliance';
import { funkitConfig, funkitTheme } from './constants/funkit';
import { LocalStorageKey } from './constants/localStorage';
import { useAnalytics } from './hooks/useAnalytics';
import { useBreakpoints } from './hooks/useBreakpoints';
import { useCommandMenu } from './hooks/useCommandMenu';
import { useComplianceState } from './hooks/useComplianceState';
import { useInitializePage } from './hooks/useInitializePage';
import { useLocalStorage } from './hooks/useLocalStorage';
import { usePrefetchedQueries } from './hooks/usePrefetchedQueries';
import { useReferralCode } from './hooks/useReferralCode';
import { useShouldShowFooter } from './hooks/useShouldShowFooter';
Expand All @@ -61,6 +63,9 @@ import LaunchMarket from './pages/LaunchMarket';
import { AffiliatesPage } from './pages/affiliates/AffiliatesPage';
import { persistor } from './state/_store';
import { appQueryClient } from './state/appQueryClient';
import { useAppDispatch, useAppSelector } from './state/appTypes';
import { AppTheme, setAppThemeSetting } from './state/appUiConfigs';
import { getAppThemeSetting } from './state/appUiConfigsSelectors';
import breakpoints from './styles/breakpoints';
import { CommunityChartContainer } from './views/Affiliates/community-chart/ProgramChartContainer';

Expand Down Expand Up @@ -101,6 +106,7 @@ const Content = () => {
}, [location.hash]);

const { dialogAreaRef } = useDialogArea() ?? {};
useUiRefreshMigrations();

return (
<>
Expand Down Expand Up @@ -178,6 +184,24 @@ const Content = () => {
);
};

function useUiRefreshMigrations() {
const themeSetting = useAppSelector(getAppThemeSetting);
const dispatch = useAppDispatch();
const { uiRefresh } = testFlags;
const [seenUiRefresh, setSeenUiRefresh] = useLocalStorage({
key: LocalStorageKey.HasSeenUiRefresh,
defaultValue: false,
});
useEffect(() => {
if (uiRefresh && !seenUiRefresh) {
setSeenUiRefresh(true);
if (themeSetting === AppTheme.Classic) {
dispatch(setAppThemeSetting(AppTheme.Dark));
}
}
}, [themeSetting, seenUiRefresh, uiRefresh, dispatch, setSeenUiRefresh]);
}

const wrapProvider = (Component: React.ComponentType<any>, props?: any) => {
// eslint-disable-next-line react/display-name
return ({ children }: { children: React.ReactNode }) => (
Expand Down
1 change: 1 addition & 0 deletions src/constants/localStorage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ export enum LocalStorageKey {
SelectedNetwork = 'dydx.SelectedNetwork',
SelectedTradeLayout = 'dydx.SelectedTradeLayout',

HasSeenUiRefresh = 'dydx.HasSeenUiRefresh',
// Discoverability
HasSeenElectionBannerTRUMPWIN = 'dydx.HasSeenElectionBannerTRUMPWIN',
HasSeenTradeFormMessageTRUMPWIN = 'dydx.HasSeenTradeFormMessageTRUMPWIN',
Expand Down

0 comments on commit 45daeb0

Please sign in to comment.