2022-01-26 20:54:58 +01:00
|
|
|
import { connect } from 'react-redux';
|
|
|
|
import { doSetClientSetting } from 'redux/actions/settings';
|
|
|
|
import { selectActiveChannelStakedLevel } from 'redux/selectors/app';
|
|
|
|
import { selectClientSetting } from 'redux/selectors/settings';
|
|
|
|
import * as SETTINGS from 'constants/settings';
|
|
|
|
import HeaderMenuButtons from './view';
|
2022-07-08 20:51:53 +02:00
|
|
|
import { selectUser } from 'redux/selectors/user';
|
2022-01-26 20:54:58 +01:00
|
|
|
|
|
|
|
const select = (state) => ({
|
|
|
|
activeChannelStakedLevel: selectActiveChannelStakedLevel(state),
|
|
|
|
automaticDarkModeEnabled: selectClientSetting(state, SETTINGS.AUTOMATIC_DARK_MODE_ENABLED),
|
|
|
|
currentTheme: selectClientSetting(state, SETTINGS.THEME),
|
|
|
|
user: selectUser(state),
|
|
|
|
});
|
|
|
|
|
|
|
|
const perform = (dispatch) => ({
|
|
|
|
handleThemeToggle: (automaticDarkModeEnabled, currentTheme) => {
|
|
|
|
if (automaticDarkModeEnabled) dispatch(doSetClientSetting(SETTINGS.AUTOMATIC_DARK_MODE_ENABLED, false));
|
|
|
|
dispatch(doSetClientSetting(SETTINGS.THEME, currentTheme === 'dark' ? 'light' : 'dark', true));
|
|
|
|
},
|
|
|
|
});
|
|
|
|
|
|
|
|
export default connect(select, perform)(HeaderMenuButtons);
|