diff --git a/src/hooks/usePreferedTheme.ts b/src/hooks/usePreferedTheme.ts index c661082a2f..a8f7e7cd97 100644 --- a/src/hooks/usePreferedTheme.ts +++ b/src/hooks/usePreferedTheme.ts @@ -1,5 +1,6 @@ import { useState, useEffect } from 'react' import { useCustomWallpaperContext } from './useCustomWallpaperContext' +import { useClient } from 'cozy-client' const getHomeThemeCssVariable = (): string => { return getComputedStyle(document.getElementsByTagName('body')[0]) @@ -11,17 +12,21 @@ export const usePreferedTheme = (): string => { const { data: { wallpaperLink, binaryCustomWallpaper } } = useCustomWallpaperContext() + const client = useClient() const [preferedTheme, setPreferedTheme] = useState('inverted') - + // @ts-expect-error client is not typed + const { cozyDefaultWallpaper } = client.getInstanceOptions() useEffect(() => { const preferedTheme = getHomeThemeCssVariable() - if (wallpaperLink || binaryCustomWallpaper) { + if ( + (wallpaperLink && wallpaperLink !== cozyDefaultWallpaper) || + binaryCustomWallpaper + ) { setPreferedTheme('inverted') } else { setPreferedTheme(preferedTheme || 'inverted') } - }, [wallpaperLink, binaryCustomWallpaper]) - + }, [wallpaperLink, binaryCustomWallpaper, cozyDefaultWallpaper]) return preferedTheme }