Skip to content

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

mobile: fix theme gets reset on opening share extension

ammarahm-edf157229e00c1
diff --git a/apps/mobile/share/store.js b/apps/mobile/share/store.js
index 2d2f0b2b7..c638b9f57 100644
--- a/apps/mobile/share/store.js
+++ b/apps/mobile/share/store.js
@@ -42,20 +42,23 @@ let appSettings = MMKV.getString(StorageKeys.appSettings);
if (appSettings) {
appSettings = JSON.parse(appSettings);
}
-const theme =
- Appearance.getColorScheme() !== "dark"
- ? appSettings?.darkThem
- : appSettings?.lightTheme;
-useThemeEngineStore
- .getState()
- .setTheme(
- theme || (Appearance.getColorScheme() === "dark" ? ThemeDark : ThemeLight)
- );
+const systemColorScheme = Appearance.getColorScheme();
+const appColorScheme = appSettings.colorScheme;
+const useSystemTheme = appSettings.useSystemTheme;
+const currentColorScheme = useSystemTheme ? systemColorScheme : appColorScheme;
+
+const theme = currentColorScheme
+ ? appSettings?.darkTheme
+ : appSettings?.lightTheme;
+
+const currentTheme =
+ theme || (currentColorScheme === "dark" ? ThemeDark : ThemeLight);
+
+useThemeEngineStore.getState().setTheme(currentTheme);
export const useShareStore = create((set) => ({
- theme:
- theme || (Appearance.getColorScheme() === "dark" ? ThemeDark : ThemeLight),
+ theme: currentTheme,
appendNote: null,
setAppendNote: (note) => {
MMKV.setItem(StorageKeys.appendNote, JSON.stringify(note));