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

42 lines
2.1 KiB
JavaScript
Raw Normal View History

2019-12-18 06:27:08 +01:00
import * as MODALS from 'constants/modal_types';
import * as SETTINGS from 'constants/settings';
import { connect } from 'react-redux';
import { selectTotalBalance, selectBalance } from 'redux/selectors/wallet';
import { formatCredits } from 'util/format-credits';
2020-10-02 17:03:25 +02:00
import { selectGetSyncErrorMessage } from 'redux/selectors/sync';
2020-09-29 22:15:35 +02:00
import { selectUserVerifiedEmail, selectUserEmail, selectEmailToVerify, selectUser } from 'redux/selectors/user';
import { doClearEmailEntry, doClearPasswordEntry } from 'redux/actions/user';
2020-09-04 17:02:30 +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, selectLanguage } from 'redux/selectors/settings';
import { selectHasNavigated, selectActiveChannelClaim, selectActiveChannelStakedLevel } from 'redux/selectors/app';
2019-06-17 22:32:38 +02:00
import Header from './view';
2017-04-22 15:17:01 +02:00
const select = (state) => ({
language: selectLanguage(state),
balance: selectBalance(state),
roundedSpendableBalance: formatCredits(selectBalance(state), 2, true),
roundedBalance: formatCredits(selectTotalBalance(state), 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),
authenticated: selectUserVerifiedEmail(state),
email: selectUserEmail(state),
syncError: selectGetSyncErrorMessage(state),
emailToVerify: selectEmailToVerify(state),
hasNavigated: selectHasNavigated(state),
2020-09-29 22:15:35 +02:00
user: selectUser(state),
activeChannelClaim: selectActiveChannelClaim(state),
activeChannelStakedLevel: selectActiveChannelStakedLevel(state),
2017-06-06 06:21:55 +02:00
});
2017-04-22 15:17:01 +02:00
const perform = (dispatch) => ({
2020-09-04 17:02:30 +02:00
setClientSetting: (key, value, push) => dispatch(doSetClientSetting(key, value, push)),
2019-09-26 18:07:11 +02:00
signOut: () => dispatch(doSignOut()),
openSignOutModal: () => dispatch(doOpenModal(MODALS.SIGN_OUT)),
clearEmailEntry: () => dispatch(doClearEmailEntry()),
clearPasswordEntry: () => dispatch(doClearPasswordEntry()),
2017-06-06 06:21:55 +02:00
});
2017-04-22 15:17:01 +02:00
export default connect(select, perform)(Header);