lbry-desktop/src/renderer/component/header/index.js

29 lines
1.1 KiB
JavaScript
Raw Normal View History

import { connect } from 'react-redux';
2018-06-25 08:07:45 +02:00
import { selectBalance, selectIsBackDisabled, selectIsForwardDisabled } from 'lbry-redux';
2018-04-18 06:03:01 +02:00
import { formatCredits } from 'util/formatCredits';
2018-06-25 08:07:45 +02:00
import { doNavigate, doHistoryBack, doHistoryForward } from 'redux/actions/navigation';
2018-03-26 23:32:43 +02:00
import { selectIsUpgradeAvailable, selectAutoUpdateDownloaded } from 'redux/selectors/app';
2018-04-18 06:03:01 +02:00
import { doDownloadUpgradeRequested } from 'redux/actions/app';
import Header from './view';
2017-04-22 15:17:01 +02:00
2017-06-06 06:21:55 +02:00
const select = state => ({
autoUpdateDownloaded: selectAutoUpdateDownloaded(state),
balance: selectBalance(state),
isUpgradeAvailable: selectIsUpgradeAvailable(state),
roundedBalance: formatCredits(selectBalance(state) || 0, 2),
2018-06-25 08:07:45 +02:00
isBackDisabled: selectIsBackDisabled(state),
isForwardDisabled: selectIsForwardDisabled(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 => ({
downloadUpgradeRequested: () => dispatch(doDownloadUpgradeRequested()),
navigate: path => dispatch(doNavigate(path)),
2018-06-25 08:07:45 +02:00
back: () => dispatch(doHistoryBack()),
forward: () => dispatch(doHistoryForward()),
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);