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

30 lines
1.2 KiB
JavaScript
Raw Normal View History

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