From 31e00c9353eae03df407082204006c46541b603d Mon Sep 17 00:00:00 2001 From: Sean Yesmunt Date: Tue, 3 Apr 2018 00:21:33 -0400 Subject: [PATCH] fix: allow editing free claims --- src/renderer/redux/actions/publish.js | 93 ++++++++++++++------------- 1 file changed, 48 insertions(+), 45 deletions(-) diff --git a/src/renderer/redux/actions/publish.js b/src/renderer/redux/actions/publish.js index ba93acb2b..ba0da04b8 100644 --- a/src/renderer/redux/actions/publish.js +++ b/src/renderer/redux/actions/publish.js @@ -34,7 +34,12 @@ export const doPrepareEdit = (claim: any) => (dispatch: Dispatch) => { const { author, description, - fee, + // use same values as default state + // fee will be undefined for free content + fee = { + amount: 0, + currency: 'LBC', + }, language, license, licenseUrl, @@ -67,7 +72,7 @@ export const doPublish = (params: PublishParams): ThunkAction => { const { name, bid, - filePath: file_path, + filePath, description, language, license, @@ -102,7 +107,7 @@ export const doPublish = (params: PublishParams): ThunkAction => { } const publishPayload = { - file_path, + file_path: filePath, name, channel_name: channelName, bid, @@ -130,52 +135,50 @@ export const doPublish = (params: PublishParams): ThunkAction => { }; // Calls claim_list_mine until any pending publishes are confirmed -export const doCheckPendingPublishes = () => { - return (dispatch: Dispatch, getState: GetState) => { - const state = getState(); - const pendingPublishes = selectPendingPublishes(state); - const myClaims = selectMyClaimsWithoutChannels(state); +export const doCheckPendingPublishes = () => (dispatch: Dispatch, getState: GetState) => { + const state = getState(); + const pendingPublishes = selectPendingPublishes(state); + const myClaims = selectMyClaimsWithoutChannels(state); - let publishCheckInterval; + let publishCheckInterval; - const checkFileList = () => { - Lbry.claim_list_mine().then(claims => { - const claimsWithoutChannels = claims.filter(claim => !claim.name.match(/^@/)); - if (myClaims.length !== claimsWithoutChannels.length) { - const pendingPublishMap = {}; - pendingPublishes.forEach(({ name }) => { - pendingPublishMap[name] = name; - }); + const checkFileList = () => { + Lbry.claim_list_mine().then(claims => { + const claimsWithoutChannels = claims.filter(claim => !claim.name.match(/^@/)); + if (myClaims.length !== claimsWithoutChannels.length) { + const pendingPublishMap = {}; + pendingPublishes.forEach(({ name }) => { + pendingPublishMap[name] = name; + }); - claims.forEach(claim => { - if (pendingPublishMap[claim.name]) { - dispatch({ - type: ACTIONS.REMOVE_PENDING_PUBLISH, - data: { - name: claim.name, - }, - }); - dispatch({ - type: ACTIONS.FETCH_CLAIM_LIST_MINE_COMPLETED, - data: { - claims, - }, - }); + claims.forEach(claim => { + if (pendingPublishMap[claim.name]) { + dispatch({ + type: ACTIONS.REMOVE_PENDING_PUBLISH, + data: { + name: claim.name, + }, + }); + dispatch({ + type: ACTIONS.FETCH_CLAIM_LIST_MINE_COMPLETED, + data: { + claims, + }, + }); - delete pendingPublishMap[claim.name]; - } - }); + delete pendingPublishMap[claim.name]; + } + }); - clearInterval(publishCheckInterval); - } - }); - }; - - if (pendingPublishes.length) { - checkFileList(); - publishCheckInterval = setInterval(() => { - checkFileList(); - }, 10000); - } + clearInterval(publishCheckInterval); + } + }); }; + + if (pendingPublishes.length) { + checkFileList(); + publishCheckInterval = setInterval(() => { + checkFileList(); + }, 10000); + } };