From 32a139fb22d5b54e210ce37a4408bbaf67f92952 Mon Sep 17 00:00:00 2001 From: Edvin CANDON Date: Mon, 18 Nov 2024 14:51:19 +0100 Subject: [PATCH] Improve theme fallback during account switch --- packages/pass/components/Onboarding/OnboardingThemeSelect.tsx | 5 +++-- packages/pass/components/Settings/PassThemeCardList.tsx | 5 +++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/packages/pass/components/Onboarding/OnboardingThemeSelect.tsx b/packages/pass/components/Onboarding/OnboardingThemeSelect.tsx index c87f93bd4e..33d3c70c61 100644 --- a/packages/pass/components/Onboarding/OnboardingThemeSelect.tsx +++ b/packages/pass/components/Onboarding/OnboardingThemeSelect.tsx @@ -7,9 +7,9 @@ import { Icon, Info, RadioGroup } from '@proton/components'; import automaticThemeImg from '@proton/pass/assets/settings/theme-automatic.svg'; import darkThemeImg from '@proton/pass/assets/settings/theme-dark.svg'; import lightThemeImg from '@proton/pass/assets/settings/theme-light.svg'; +import { usePassCore } from '@proton/pass/components/Core/PassCoreProvider'; import { PassThemeOption } from '@proton/pass/components/Layout/Theme/types'; import type { PassThemeCardProps } from '@proton/pass/components/Settings/PassThemeCard'; -import { PASS_DEFAULT_THEME } from '@proton/pass/constants'; import { settingsEditIntent } from '@proton/pass/store/actions'; import { selectTheme } from '@proton/pass/store/selectors'; import { PASS_APP_NAME } from '@proton/shared/lib/constants'; @@ -41,8 +41,9 @@ const getThemeCards = (): PassThemeCardProps[] => [ ]; export const OnboardingThemeSelect: FC = () => { + const core = usePassCore(); const dispatch = useDispatch(); - const currentTheme = useSelector(selectTheme) ?? PASS_DEFAULT_THEME; + const currentTheme = useSelector(selectTheme) ?? core.theme; const onChange = (theme: PassThemeOption) => dispatch(settingsEditIntent('theme', { theme }, true)); return ( diff --git a/packages/pass/components/Settings/PassThemeCardList.tsx b/packages/pass/components/Settings/PassThemeCardList.tsx index 80f7bfd098..1dacc894aa 100644 --- a/packages/pass/components/Settings/PassThemeCardList.tsx +++ b/packages/pass/components/Settings/PassThemeCardList.tsx @@ -7,10 +7,10 @@ import { Info } from '@proton/components'; import automaticThemeImg from '@proton/pass/assets/settings/theme-automatic.svg'; import darkThemeImg from '@proton/pass/assets/settings/theme-dark.svg'; import lightThemeImg from '@proton/pass/assets/settings/theme-light.svg'; +import { usePassCore } from '@proton/pass/components/Core/PassCoreProvider'; import { PassThemeOption } from '@proton/pass/components/Layout/Theme/types'; import type { PassThemeCardProps } from '@proton/pass/components/Settings/PassThemeCard'; import { PassThemeCard } from '@proton/pass/components/Settings/PassThemeCard'; -import { PASS_DEFAULT_THEME } from '@proton/pass/constants'; import { settingsEditIntent } from '@proton/pass/store/actions'; import { selectTheme } from '@proton/pass/store/selectors'; import { PASS_APP_NAME } from '@proton/shared/lib/constants'; @@ -42,7 +42,8 @@ const getThemeCards = (): PassThemeCardProps[] => [ export const PassThemeCardList: FC = () => { const dispatch = useDispatch(); - const currentTheme = useSelector(selectTheme) ?? PASS_DEFAULT_THEME; + const core = usePassCore(); + const currentTheme = useSelector(selectTheme) ?? core.theme; const onChange = (theme: PassThemeOption) => dispatch(settingsEditIntent('theme', { theme }, true)); return ( -- 2.11.4.GIT