properly setting redux isDarkTheme and setTheme separatly to differ between active and saved state

This commit is contained in:
Nouman Tahir 2022-04-16 02:27:14 +05:00
parent 5bde1928e6
commit 1ba07401e0

View File

@ -1,5 +1,5 @@
import React, { Component } from 'react';
import { Platform, Alert } from 'react-native';
import { Platform, Alert, Appearance } from 'react-native';
import { connect } from 'react-redux';
import { Client } from '@hiveio/dhive';
import VersionNumber from 'react-native-version-number';
@ -7,6 +7,8 @@ import Config from 'react-native-config';
import { injectIntl } from 'react-intl';
import messaging from '@react-native-firebase/messaging';
import { languageRestart } from '../../../utils/I18nUtils';
import THEME_OPTIONS from '../../../constants/options/theme';
// Realm
import {
getExistUser,
@ -22,6 +24,7 @@ import {
setAuthStatus,
setExistUser,
removeAllUserData,
getTheme,
} from '../../../realm/realm';
// Services and Actions
@ -119,6 +122,21 @@ class SettingsContainer extends Component {
setNsfw2DB(action);
break;
case 'theme':
let setting = THEME_OPTIONS[action].value;
const systemTheme = Appearance.getColorScheme();
dispatch(isDarkTheme(setting === null
? systemTheme === 'dark'
: setting
));
setTheme(setting);
this.setState({
themeSetting:setting
})
break;
default:
break;
}
@ -208,11 +226,6 @@ class SettingsContainer extends Component {
this._handleNotification(action, actionType);
break;
case 'theme':
dispatch(isDarkTheme(action));
setTheme(action);
break;
case 'default_footer':
dispatch(isDefaultFooter(action));
// setDefaultFooter(action);