diff --git a/src/renderer/component/publishForm/view.jsx b/src/renderer/component/publishForm/view.jsx index 43ce868cc..7fa13d98e 100644 --- a/src/renderer/component/publishForm/view.jsx +++ b/src/renderer/component/publishForm/view.jsx @@ -177,25 +177,13 @@ class PublishForm extends React.PureComponent { handlePublish() { const { - publish, filePath, - bid, - title, - thumbnail, - description, - language, - nsfw, + copyrightNotice, licenseType, licenseUrl, otherLicenseDescription, - copyrightNotice, - name, - contentIsFree, - price, - uri, myClaimForUri, - channel, - isStillEditing + publish, } = this.props; let publishingLicense; @@ -214,22 +202,22 @@ class PublishForm extends React.PureComponent { const publishParams = { filePath, - bid, - title, - thumbnail, - description, - language, - nsfw, + bid: this.props.bid, + title: this.props.title, + thumbnail: this.props.thumbnail, + description: this.props.description, + language: this.props.language, + nsfw: this.props.nsfw, license: publishingLicense, licenseUrl: publishingLicenseUrl, otherLicenseDescription, copyrightNotice, - name, - contentIsFree, - price, - uri, - channel, - isStillEditing + name: this.props.name, + contentIsFree: this.props.contentIsFree, + price: this.props.price, + uri: this.props.uri, + channel: this.props.channel, + isStillEditing: this.props.isStillEditing, }; // Editing a claim diff --git a/src/renderer/page/publish/index.js b/src/renderer/page/publish/index.js index f365ede0e..6cf2e5403 100644 --- a/src/renderer/page/publish/index.js +++ b/src/renderer/page/publish/index.js @@ -35,7 +35,7 @@ const select = state => { // ex: "you own this, for 5 more lbc you will win this claim" const claimsByUri = selectClaimsByUri(state); claimForUri = claimsByUri[uri]; - winningBidForClaimUri = claimForUri ? claimForUri.effective_amount : undefined; + winningBidForClaimUri = claimForUri ? claimForUri.effective_amount : null; } return { @@ -59,7 +59,7 @@ const perform = dispatch => ({ resolveUri: uri => dispatch(doResolveUri(uri)), publish: params => dispatch(doPublish(params)), navigate: path => dispatch(doNavigate(path)), - prepareEdit: claim => dispatch(doPrepareEdit(claim)), + prepareEdit: (claim, uri) => dispatch(doPrepareEdit(claim, uri)), resetThumbnailStatus: () => dispatch(doResetThumbnailStatus()), }); diff --git a/src/renderer/redux/actions/publish.js b/src/renderer/redux/actions/publish.js index a99383135..b739c47db 100644 --- a/src/renderer/redux/actions/publish.js +++ b/src/renderer/redux/actions/publish.js @@ -2,7 +2,6 @@ import { ACTIONS, Lbry, - selectMyClaimsWithoutChannels, doNotify, MODALS, selectMyChannelClaims, @@ -168,7 +167,6 @@ export const doPrepareEdit = (claim: any, uri: string) => (dispatch: Dispatch) = export const doPublish = (params: PublishParams) => (dispatch: Dispatch, getState: () => {}) => { const state = getState(); - const myClaims = selectMyClaimsWithoutChannels(state); const myChannels = selectMyChannelClaims(state); const { @@ -233,7 +231,6 @@ export const doPublish = (params: PublishParams) => (dispatch: Dispatch, getStat data: { pendingPublish: { ...publishPayload, isEdit: isStillEditing } }, }); dispatch(doNotify({ id: MODALS.PUBLISH }, { uri })); - dispatch(doCheckPendingPublishes()); }; const failure = error => { @@ -258,25 +255,29 @@ export const doCheckPendingPublishes = () => (dispatch: Dispatch, getState: GetS pendingPublishMap[name] = name; }); + const actions = []; claims.forEach(claim => { if (pendingPublishMap[claim.name]) { - dispatch({ + actions.push({ type: ACTIONS.REMOVE_PENDING_PUBLISH, data: { name: claim.name, }, }); - dispatch({ - type: ACTIONS.FETCH_CLAIM_LIST_MINE_COMPLETED, - data: { - claims, - }, - }); delete pendingPublishMap[claim.name]; } }); + actions.push({ + type: ACTIONS.FETCH_CLAIM_LIST_MINE_COMPLETED, + data: { + claims, + }, + }); + + dispatch(batchActions(...actions)); + if (!pendingPublishes.length) { clearInterval(publishCheckInterval); } diff --git a/src/renderer/redux/reducers/publish.js b/src/renderer/redux/reducers/publish.js index 6372b8410..da2b347cf 100644 --- a/src/renderer/redux/reducers/publish.js +++ b/src/renderer/redux/reducers/publish.js @@ -169,6 +169,7 @@ export default handleActions( }; }, [ACTIONS.DO_PREPARE_EDIT]: (state: PublishState, action) => { + const { pendingPublishes } = state; const { ...publishData } = action.data; const { channel, name, uri } = publishData; @@ -182,6 +183,7 @@ export default handleActions( return { ...defaultState, ...publishData, + pendingPublishes, editingURI: uri, uri: shortUri, }; diff --git a/src/renderer/redux/selectors/publish.js b/src/renderer/redux/selectors/publish.js index 770aafb02..4f34871a5 100644 --- a/src/renderer/redux/selectors/publish.js +++ b/src/renderer/redux/selectors/publish.js @@ -1,10 +1,5 @@ import { createSelector } from 'reselect'; -import { - parseURI, - selectClaimsById, - selectMyClaims, - selectMyClaimsWithoutChannels, -} from 'lbry-redux'; +import { parseURI, selectClaimsById, selectMyClaimsWithoutChannels } from 'lbry-redux'; const selectState = state => state.publish || {}; @@ -66,36 +61,31 @@ export const selectIsStillEditing = createSelector(selectPublishFormValues, publ // Depending on the previous/current use of a channel, we need to compare different things // ex: going from a channel to anonymous, the new uri won't return contentName, so we need to use claimName - if (!currentIsChannel && editIsChannel) { - return currentClaimName === editContentName; - } else if (currentIsChannel && !editIsChannel) { - return currentContentName === editClaimName; - } else if (!currentIsChannel && !editIsChannel) { - return currentClaimName === editClaimName; - } - return currentContentName === editContentName; + const currentName = currentIsChannel ? currentContentName : currentClaimName; + const editName = editIsChannel ? editContentName : editClaimName; + return currentName === editName; }); export const selectMyClaimForUri = createSelector( selectPublishFormValues, selectIsStillEditing, selectClaimsById, - selectMyClaims, + selectMyClaimsWithoutChannels, ({ editingURI, uri }, isStillEditing, claimsById, myClaims) => { - const { contentName: currentContentName } = parseURI(uri); + const { contentName, claimName } = parseURI(uri); const { claimId: editClaimId } = parseURI(editingURI); - let myClaimForUri; - if (isStillEditing) { - // They clicked "edit" from the file page - // They haven't changed the channel/name after clicking edit - // Get the claim so they can edit without re-uploading a new file - myClaimForUri = claimsById[editClaimId]; - } else { - // Check if they have a previous claim based on the channel/name - myClaimForUri = myClaims.find(claim => claim.name === currentContentName); - } - - return myClaimForUri; + // If isStillEditing + // They clicked "edit" from the file page + // They haven't changed the channel/name after clicking edit + // Get the claim so they can edit without re-uploading a new file + return isStillEditing + ? claimsById[editClaimId] + : myClaims.find( + claim => + !contentName + ? claim.name === claimName + : claim.name === contentName || claim.name === claimName + ); } );