diff --git a/.eslintrc.json b/.eslintrc.json index 6a992f8bf..a8f285504 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -43,6 +43,7 @@ "class-methods-use-this": 0, "jsx-a11y/interactive-supports-focus": 0, "jsx-a11y/click-events-have-key-events": 0, - "consistent-return": 0 + "consistent-return": 0, + "flowtype/space-after-type-colon": [ 2, "always", { "allowLineBreak": true } ] } } diff --git a/src/renderer/page/fileListPublished/index.js b/src/renderer/page/fileListPublished/index.js index d3b4e90fd..1826fb78d 100644 --- a/src/renderer/page/fileListPublished/index.js +++ b/src/renderer/page/fileListPublished/index.js @@ -1,6 +1,9 @@ import { connect } from 'react-redux'; -import { selectPendingPublishes } from 'redux/selectors/publish'; -import { selectIsFetchingClaimListMine, selectFileListPublishedSort, selectMyClaimsWithoutChannels } from 'lbry-redux'; +import { + selectIsFetchingClaimListMine, + selectFileListPublishedSort, + selectMyClaimsWithoutChannels, +} from 'lbry-redux'; import { doNavigate } from 'redux/actions/navigation'; import { doCheckPendingPublishes } from 'redux/actions/publish'; import FileListPublished from './view'; diff --git a/src/renderer/page/fileListPublished/view.jsx b/src/renderer/page/fileListPublished/view.jsx index 338da3b60..478a79999 100644 --- a/src/renderer/page/fileListPublished/view.jsx +++ b/src/renderer/page/fileListPublished/view.jsx @@ -22,7 +22,6 @@ class FileListPublished extends React.PureComponent { render() { const { fetching, claims, navigate, sortBy } = this.props; - return ( {claims && claims.length ? ( diff --git a/src/renderer/redux/actions/publish.js b/src/renderer/redux/actions/publish.js index af0e9709a..22e930213 100644 --- a/src/renderer/redux/actions/publish.js +++ b/src/renderer/redux/actions/publish.js @@ -16,6 +16,7 @@ import { batchActions, creditsToString, selectPendingById, + selectMyClaimsWithoutChannels, } from 'lbry-redux'; import { selectosNotificationsEnabled } from 'redux/selectors/settings'; import { doNavigate } from 'redux/actions/navigation'; @@ -199,6 +200,7 @@ export const doPublish = (params: PublishParams) => ( ) => { const state = getState(); const myChannels = selectMyChannelClaims(state); + const myClaims = selectMyClaimsWithoutChannels(state); const { name, @@ -223,7 +225,7 @@ export const doPublish = (params: PublishParams) => ( const channelId = namedChannelClaim ? namedChannelClaim.claim_id : ''; const fee = contentIsFree || !price.amount ? undefined : { ...price }; - const metadata = { + const metadata: Metadata = { title, nsfw, license, @@ -262,11 +264,30 @@ export const doPublish = (params: PublishParams) => ( dispatch({ type: ACTIONS.PUBLISH_START }); - const success = () => { - dispatch({ + const success = pendingClaim => { + const actions = []; + + actions.push({ type: ACTIONS.PUBLISH_SUCCESS, }); - dispatch(doNotify({ id: MODALS.PUBLISH }, { uri })); + + actions.push(doNotify({ id: MODALS.PUBLISH }, { uri })); + + // We have to fake a temp claim until the new pending one is returned by claim_list_mine + // We can't rely on claim_list_mine because there might be some delay before the new claims are returned + // Doing this allows us to show the pending claim immediately, it will get overwritten by the real one + const myNewClaims = myClaims.map( + claim => (claim.claim_id === pendingClaim.claim_id ? pendingClaim.output : claim) + ); + + actions.push({ + type: ACTIONS.FETCH_CLAIM_LIST_MINE_COMPLETED, + data: { + claims: myNewClaims, + }, + }); + + dispatch(batchActions(...actions)); }; const failure = error => { @@ -281,7 +302,8 @@ export const doPublish = (params: PublishParams) => ( export const doCheckPendingPublishes = () => (dispatch: Dispatch, getState: GetState) => { const state = getState(); const pendingById = selectPendingById(state); - if (!Object.keys(pendingById)) { + + if (!Object.keys(pendingById).length) { return; } @@ -290,7 +312,7 @@ export const doCheckPendingPublishes = () => (dispatch: Dispatch, getSta const checkFileList = () => { Lbry.claim_list_mine().then(claims => { claims.forEach(claim => { - // If it's confirmed, check that it wasn't pending previously + // If it's confirmed, check if it was pending previously if (claim.confirmations > 0 && pendingById[claim.claim_id]) { delete pendingById[claim.claim_id]; @@ -326,7 +348,6 @@ export const doCheckPendingPublishes = () => (dispatch: Dispatch, getSta }); }; - checkFileList(); publishCheckInterval = setInterval(() => { checkFileList(); }, 30000); diff --git a/src/renderer/types/claim.js b/src/renderer/types/claim.js index dcc8fef1e..a7b86a39e 100644 --- a/src/renderer/types/claim.js +++ b/src/renderer/types/claim.js @@ -14,6 +14,18 @@ export type Metadata = { title: string, thumbnail: ?string, description: ?string, + fee?: + | { + amount: number, // should be a string https://github.com/lbryio/lbry/issues/1576 + currency: string, + address: string, + version: string, + } + | { + // We don't include a version or address in the metadata field when publishing + amount: number, + currency: string, + }, }; // Actual claim type has more values than this