Skip to content

A fully open source & end-to-end encrypted note taking alternative to Evernote.

mobile: fix flash on launch on ios

ammarahm-ed1775e0bda13b
diff --git a/apps/mobile/app/app.js b/apps/mobile/app/app.js
index 8f6a8e4d3..c131aecc2 100644
--- a/apps/mobile/app/app.js
+++ b/apps/mobile/app/app.js
@@ -94,6 +94,12 @@ const App = () => {
);
};
+let currTheme =
+ useThemeStore.getState().colorScheme === "dark"
+ ? SettingsService.getProperty("darkTheme")
+ : SettingsService.getProperty("lightTheme");
+useThemeEngineStore.getState().setTheme(currTheme);
+
export const withTheme = (Element) => {
return function AppWithThemeProvider() {
const [colorScheme, darkTheme, lightTheme] = useThemeStore((state) => [
@@ -125,11 +131,13 @@ export const withTheme = (Element) => {
// eslint-disable-next-line react-hooks/exhaustive-deps
}, []);
- useEffect(() => {
+ const nextTheme = colorScheme === "dark" ? darkTheme : lightTheme;
+ if (JSON.stringify(nextTheme) !== JSON.stringify(currTheme)) {
useThemeEngineStore
.getState()
.setTheme(colorScheme === "dark" ? darkTheme : lightTheme);
- }, [colorScheme, darkTheme, lightTheme]);
+ currTheme = nextTheme;
+ }
return <Element />;
};