lbry-desktop/ui/modal/modalConfirmTransaction/index.js
jessopb a3398843c2
Optimize selectClaimIsMine (#7370)
Frequently used; top in perf profile

Most of the time, you already have the claim object in the current context. `selectClaimIsMineForUri` will retrieve the claim again, which is wasteful, even if it is memoized (looking up the cache still takes time).

Break apart the logic and added the alternative `selectClaimIsMine` for faster lookup.

Co-authored-by: infinite-persistence <inf.persistence@gmail.com>
2021-12-31 12:52:26 -05:00

20 lines
856 B
JavaScript

import { connect } from 'react-redux';
import { doSendDraftTransaction, doSendTip } from 'redux/actions/wallet';
import { selectClaimForUri } from 'redux/selectors/claims';
import { doHideModal } from 'redux/actions/app';
import ModalConfirmTransaction from './view';
import { selectActiveChannelClaim, selectIncognito } from 'redux/selectors/app';
const select = (state, props) => ({
claim: selectClaimForUri(state, props.destination)(state),
activeChannelClaim: selectActiveChannelClaim(state),
incognito: selectIncognito(state),
});
const perform = (dispatch) => ({
closeModal: () => dispatch(doHideModal()),
sendToAddress: (address, amount) => dispatch(doSendDraftTransaction(address, amount)),
sendTip: (params, isSupport) => dispatch(doSendTip(params, isSupport)),
});
export default connect(select, perform)(ModalConfirmTransaction);