2019-06-17 16:32:38 -04:00
|
|
|
import * as SETTINGS from 'constants/settings';
|
2019-12-18 00:27:08 -05:00
|
|
|
import * as MODALS from 'constants/modal_types';
|
2017-12-21 18:08:54 -03:00
|
|
|
import { connect } from 'react-redux';
|
2019-08-27 10:43:42 -04:00
|
|
|
import { selectBalance, formatCredits } from 'lbry-redux';
|
2020-01-03 14:34:17 -05:00
|
|
|
import { selectUserVerifiedEmail, selectGetSyncErrorMessage, selectUserEmail } from 'lbryinc';
|
2019-06-17 16:32:38 -04:00
|
|
|
import { doSetClientSetting } from 'redux/actions/settings';
|
2019-12-18 00:27:08 -05:00
|
|
|
import { doSignOut, doOpenModal } from 'redux/actions/app';
|
2019-09-26 12:28:08 -04:00
|
|
|
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 => ({
|
2018-04-17 08:14:14 +03:00
|
|
|
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),
|
2019-07-29 11:37:29 -04:00
|
|
|
hideBalance: makeSelectClientSetting(SETTINGS.HIDE_BALANCE)(state),
|
2020-01-03 14:34:17 -05:00
|
|
|
authenticated: selectUserVerifiedEmail(state),
|
|
|
|
email: selectUserEmail(state),
|
2019-11-01 12:19:28 -04:00
|
|
|
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()),
|
2019-12-18 00:27:08 -05:00
|
|
|
openMobileNavigation: () => dispatch(doOpenModal(MODALS.MOBILE_NAVIGATION)),
|
2020-01-03 14:11:47 -05:00
|
|
|
openChannelCreate: () => dispatch(doOpenModal(MODALS.CREATE_CHANNEL)),
|
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);
|