2019-12-18 06:27:08 +01:00
|
|
|
import * as MODALS from 'constants/modal_types';
|
2017-12-21 22:08:54 +01:00
|
|
|
import { connect } from 'react-redux';
|
2020-10-05 19:38:40 +02:00
|
|
|
import { selectBalance, formatCredits, selectMyChannelClaims, SETTINGS } from 'lbry-redux';
|
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';
|
2020-06-15 22:33:03 +02:00
|
|
|
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';
|
2020-11-20 14:21:31 +01:00
|
|
|
import { makeSelectClientSetting, selectLanguage } from 'redux/selectors/settings';
|
2020-10-28 22:42:53 +01:00
|
|
|
import { selectCommentChannel } from 'redux/selectors/comments';
|
2019-06-17 22:32:38 +02:00
|
|
|
import Header from './view';
|
2020-07-10 23:04:36 +02:00
|
|
|
import { selectHasNavigated } from 'redux/selectors/app';
|
2017-04-22 15:17:01 +02:00
|
|
|
|
2017-06-06 06:21:55 +02:00
|
|
|
const select = state => ({
|
2018-04-17 07:14:14 +02:00
|
|
|
balance: selectBalance(state),
|
2020-11-20 14:21:31 +01:00
|
|
|
language: selectLanguage(state),
|
2020-05-26 20:39:40 +02:00
|
|
|
roundedBalance: formatCredits(selectBalance(state), 2, true),
|
2019-06-17 22:32:38 +02:00
|
|
|
currentTheme: makeSelectClientSetting(SETTINGS.THEME)(state),
|
|
|
|
automaticDarkModeEnabled: makeSelectClientSetting(SETTINGS.AUTOMATIC_DARK_MODE_ENABLED)(state),
|
2019-07-29 17:37:29 +02:00
|
|
|
hideBalance: makeSelectClientSetting(SETTINGS.HIDE_BALANCE)(state),
|
2020-01-03 20:34:17 +01:00
|
|
|
authenticated: selectUserVerifiedEmail(state),
|
|
|
|
email: selectUserEmail(state),
|
2019-11-01 17:19:28 +01:00
|
|
|
syncError: selectGetSyncErrorMessage(state),
|
2020-04-13 21:16:07 +02:00
|
|
|
emailToVerify: selectEmailToVerify(state),
|
2020-07-10 23:04:36 +02:00
|
|
|
hasNavigated: selectHasNavigated(state),
|
2020-09-29 22:15:35 +02:00
|
|
|
user: selectUser(state),
|
2020-10-05 19:38:40 +02:00
|
|
|
myChannels: selectMyChannelClaims(state),
|
2020-10-28 22:42:53 +01:00
|
|
|
commentChannel: selectCommentChannel(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 => ({
|
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()),
|
2020-01-03 20:11:47 +01:00
|
|
|
openChannelCreate: () => dispatch(doOpenModal(MODALS.CREATE_CHANNEL)),
|
2020-03-14 00:00:22 +01:00
|
|
|
openSignOutModal: () => dispatch(doOpenModal(MODALS.SIGN_OUT)),
|
2020-04-13 21:16:07 +02:00
|
|
|
clearEmailEntry: () => dispatch(doClearEmailEntry()),
|
|
|
|
clearPasswordEntry: () => dispatch(doClearPasswordEntry()),
|
2017-06-06 06:21:55 +02:00
|
|
|
});
|
2017-04-22 15:17:01 +02:00
|
|
|
|
2020-03-14 00:00:22 +01:00
|
|
|
export default connect(select, perform)(Header);
|