lbry-desktop/ui/component/header/index.js

32 lines
1.3 KiB
JavaScript
Raw Normal View History

2019-06-17 22:32:38 +02:00
import * as SETTINGS from 'constants/settings';
2019-12-18 06:27:08 +01:00
import * as MODALS from 'constants/modal_types';
import { connect } from 'react-redux';
2019-08-27 16:43:42 +02:00
import { selectBalance, formatCredits } from 'lbry-redux';
import { selectUserVerifiedEmail, selectGetSyncErrorMessage } from 'lbryinc';
2019-06-17 22:32:38 +02:00
import { doSetClientSetting } from 'redux/actions/settings';
2019-12-18 06:27:08 +01:00
import { doSignOut, doOpenModal } from 'redux/actions/app';
import { makeSelectClientSetting } from 'redux/selectors/settings';
2019-06-17 22:32:38 +02:00
import Header from './view';
2017-04-22 15:17:01 +02:00
2017-06-06 06:21:55 +02:00
const select = state => ({
balance: selectBalance(state),
2019-08-27 16:43:42 +02:00
language: makeSelectClientSetting(SETTINGS.LANGUAGE)(state), // trigger redraw on language change
roundedBalance: formatCredits(selectBalance(state) || 0, 2, true),
2019-06-17 22:32:38 +02:00
currentTheme: makeSelectClientSetting(SETTINGS.THEME)(state),
automaticDarkModeEnabled: makeSelectClientSetting(SETTINGS.AUTOMATIC_DARK_MODE_ENABLED)(state),
hideBalance: makeSelectClientSetting(SETTINGS.HIDE_BALANCE)(state),
2019-09-26 18:07:11 +02:00
email: selectUserVerifiedEmail(state),
syncError: selectGetSyncErrorMessage(state),
2017-06-06 06:21:55 +02:00
});
2017-04-22 15:17:01 +02:00
2017-06-06 06:21:55 +02:00
const perform = dispatch => ({
2019-06-17 22:32:38 +02:00
setClientSetting: (key, value) => dispatch(doSetClientSetting(key, value)),
2019-09-26 18:07:11 +02:00
signOut: () => dispatch(doSignOut()),
2019-12-18 06:27:08 +01:00
openMobileNavigation: () => dispatch(doOpenModal(MODALS.MOBILE_NAVIGATION)),
2017-06-06 06:21:55 +02:00
});
2017-04-22 15:17:01 +02:00
2018-06-25 08:07:45 +02:00
export default connect(
select,
perform
)(Header);