lbry-desktop/ui/component/headerMenuButtons/index.js
Rave | 図書館猫 2762d43224
Restructure header navigation (#1611)
* Restructure header navigation

* Hide theme button in guest mode

* Update channel selector width and navigation top in header
2022-06-03 09:43:31 -04:00

24 lines
1.1 KiB
JavaScript

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';
import { selectUserVerifiedEmail, selectUser } from 'redux/selectors/user';
import { doOpenModal } from 'redux/actions/app';
const select = (state) => ({
authenticated: selectUserVerifiedEmail(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));
},
doOpenModal: (id, params) => dispatch(doOpenModal(id, params)),
});
export default connect(select, perform)(HeaderMenuButtons);