ca0cd2ca75
- selectMyChannelClaims depends on `byId`, which currently is always invalidated per update, so it is not memoized. - Most of the use-cases just needs the ID or the length of the array anyways, so avoid generating a Claim array (in selectMyChannelClaims) unnecessarily -- the client need to reduce it back down to IDs again :/ - The simpler boolean also removes the need to memoize the selector, which saves a bit of memory. Co-authored-by: infinite-persistence <inf.persistence@gmail.com>
80 lines
3.2 KiB
JavaScript
80 lines
3.2 KiB
JavaScript
import { connect } from 'react-redux';
|
|
import {
|
|
doResetThumbnailStatus,
|
|
doClearPublish,
|
|
doUpdatePublishForm,
|
|
doPrepareEdit,
|
|
doPublishDesktop,
|
|
} from 'redux/actions/publish';
|
|
import { doResolveUri, doCheckPublishNameAvailability } from 'redux/actions/claims';
|
|
import {
|
|
selectTakeOverAmount,
|
|
selectPublishFormValues,
|
|
selectIsStillEditing,
|
|
makeSelectPublishFormValue,
|
|
selectIsResolvingPublishUris,
|
|
selectMyClaimForUri,
|
|
} from 'redux/selectors/publish';
|
|
import * as RENDER_MODES from 'constants/file_render_modes';
|
|
import * as SETTINGS from 'constants/settings';
|
|
import { doClaimInitialRewards } from 'redux/actions/rewards';
|
|
import {
|
|
selectUnclaimedRewardValue,
|
|
selectIsClaimingInitialRewards,
|
|
selectHasClaimedInitialRewards,
|
|
} from 'redux/selectors/rewards';
|
|
import {
|
|
selectModal,
|
|
selectActiveChannelClaim,
|
|
selectIncognito,
|
|
selectActiveChannelStakedLevel,
|
|
} from 'redux/selectors/app';
|
|
import { makeSelectClientSetting } from 'redux/selectors/settings';
|
|
import { makeSelectFileRenderModeForUri } from 'redux/selectors/content';
|
|
import { selectUser } from 'redux/selectors/user';
|
|
import PublishForm from './view';
|
|
|
|
const select = (state) => {
|
|
const myClaimForUri = selectMyClaimForUri(state);
|
|
const permanentUrl = (myClaimForUri && myClaimForUri.permanent_url) || '';
|
|
const isPostClaim = makeSelectFileRenderModeForUri(permanentUrl)(state) === RENDER_MODES.MARKDOWN;
|
|
|
|
return {
|
|
...selectPublishFormValues(state),
|
|
user: selectUser(state),
|
|
// The winning claim for a short lbry uri
|
|
amountNeededForTakeover: selectTakeOverAmount(state),
|
|
isPostClaim,
|
|
permanentUrl,
|
|
// My previously published claims under this short lbry uri
|
|
myClaimForUri,
|
|
// If I clicked the "edit" button, have I changed the uri?
|
|
// Need this to make it easier to find the source on previously published content
|
|
isStillEditing: selectIsStillEditing(state),
|
|
filePath: makeSelectPublishFormValue('filePath')(state),
|
|
remoteUrl: makeSelectPublishFormValue('remoteFileUrl')(state),
|
|
publishSuccess: makeSelectPublishFormValue('publishSuccess')(state),
|
|
isResolvingUri: selectIsResolvingPublishUris(state),
|
|
totalRewardValue: selectUnclaimedRewardValue(state),
|
|
modal: selectModal(state),
|
|
enablePublishPreview: makeSelectClientSetting(SETTINGS.ENABLE_PUBLISH_PREVIEW)(state),
|
|
activeChannelClaim: selectActiveChannelClaim(state),
|
|
incognito: selectIncognito(state),
|
|
activeChannelStakedLevel: selectActiveChannelStakedLevel(state),
|
|
isClaimingInitialRewards: selectIsClaimingInitialRewards(state),
|
|
hasClaimedInitialRewards: selectHasClaimedInitialRewards(state),
|
|
};
|
|
};
|
|
|
|
const perform = (dispatch) => ({
|
|
updatePublishForm: (value) => dispatch(doUpdatePublishForm(value)),
|
|
clearPublish: () => dispatch(doClearPublish()),
|
|
resolveUri: (uri) => dispatch(doResolveUri(uri)),
|
|
publish: (filePath, preview) => dispatch(doPublishDesktop(filePath, preview)),
|
|
prepareEdit: (claim, uri) => dispatch(doPrepareEdit(claim, uri)),
|
|
resetThumbnailStatus: () => dispatch(doResetThumbnailStatus()),
|
|
checkAvailability: (name) => dispatch(doCheckPublishNameAvailability(name)),
|
|
claimInitialRewards: () => dispatch(doClaimInitialRewards()),
|
|
});
|
|
|
|
export default connect(select, perform)(PublishForm);
|