2021-12-20 13:29:51 +01:00
|
|
|
import { connect } from 'react-redux';
|
|
|
|
import { doSetClientSetting } from 'redux/actions/settings';
|
|
|
|
import { selectClientSetting } from 'redux/selectors/settings';
|
|
|
|
import * as SETTINGS from 'constants/settings';
|
|
|
|
import HeaderMenuButtons from './view';
|
2022-03-09 19:05:37 +01:00
|
|
|
import { selectUserVerifiedEmail, selectUser, selectOdyseeMembershipName } from 'redux/selectors/user';
|
|
|
|
import { doOpenModal } from 'redux/actions/app';
|
2021-12-20 13:29:51 +01:00
|
|
|
|
|
|
|
const select = (state) => ({
|
|
|
|
authenticated: selectUserVerifiedEmail(state),
|
|
|
|
automaticDarkModeEnabled: selectClientSetting(state, SETTINGS.AUTOMATIC_DARK_MODE_ENABLED),
|
|
|
|
currentTheme: selectClientSetting(state, SETTINGS.THEME),
|
|
|
|
user: selectUser(state),
|
2022-03-09 19:05:37 +01:00
|
|
|
odyseeMembership: selectOdyseeMembershipName(state),
|
2021-12-20 13:29:51 +01:00
|
|
|
});
|
|
|
|
|
|
|
|
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));
|
|
|
|
},
|
2022-03-09 19:05:37 +01:00
|
|
|
doOpenModal: (id, params) => dispatch(doOpenModal(id, params)),
|
2021-12-20 13:29:51 +01:00
|
|
|
});
|
|
|
|
|
|
|
|
export default connect(select, perform)(HeaderMenuButtons);
|