Skip to content

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

fix darkmode button

ammarahm-ed32b1fbb6632e
diff --git a/apps/mobile/src/services/SettingsService.js b/apps/mobile/src/services/SettingsService.js
index bb629afae..ff8f52f32 100644
--- a/apps/mobile/src/services/SettingsService.js
+++ b/apps/mobile/src/services/SettingsService.js
@@ -7,7 +7,9 @@ import {MMKV} from '../utils/mmkv';
import {scale, updateSize} from '../utils/SizeUtils';
import {enabled} from 'react-native-privacy-snapshot';
import {Platform} from 'react-native';
+
let settings = defaultState.settings;
+
let appLoaded = false;
function setAppLoaded() {
@@ -62,10 +64,11 @@ const setTheme = async () => {
async function set(name, value) {
settings[name] = value;
await MMKV.setStringAsync('appSettings', JSON.stringify(settings));
- updateEvent({type: Actions.SETTINGS, settings: settings});
+ updateEvent({type: Actions.SETTINGS, settings: {...settings}});
}
function get() {
+ console.log(settings.useSystemTheme,'getting')
return settings;
}
diff --git a/apps/mobile/src/views/Settings/index.js b/apps/mobile/src/views/Settings/index.js
index 9742cc902..b2c639017 100644
--- a/apps/mobile/src/views/Settings/index.js
+++ b/apps/mobile/src/views/Settings/index.js
@@ -550,8 +550,8 @@ const SettingsUserSection = () => {
const SettingsAppearanceSection = () => {
const [state, dispatch] = useTracked();
- const {colors, settings} = state;
-
+ const {colors} = state;
+ const settings = {...state.settings};
function changeColorScheme(colors = COLOR_SCHEME, accent = ACCENT) {
let newColors = setColorScheme(colors, accent);
dispatch({type: Actions.THEME, colors: newColors});
@@ -565,9 +565,11 @@ const SettingsAppearanceSection = () => {
const switchTheme = async () => {
await PremiumService.verify(async () => {
- await SettingsService.set('useSystemTheme', !settings.useSystemTheme);
-
- if (!settings.useSystemTheme) {
+ await SettingsService.set(
+ 'useSystemTheme',
+ SettingsService.get().useSystemTheme ? false : true,
+ );
+ if (SettingsService.get().useSystemTheme) {
await MMKV.setStringAsync(
'theme',
JSON.stringify({night: Appearance.getColorScheme() === 'dark'}),