fix: show pending publishes immediately

This commit is contained in:
Sean Yesmunt 2018-11-01 09:30:04 -04:00
parent c3ef95daaa
commit abb5917329
5 changed files with 47 additions and 11 deletions

View file

@ -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 } ]
}
}

View file

@ -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';

View file

@ -22,7 +22,6 @@ class FileListPublished extends React.PureComponent<Props> {
render() {
const { fetching, claims, navigate, sortBy } = this.props;
return (
<Page notContained loading={fetching}>
{claims && claims.length ? (

View file

@ -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<Action>, 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<Action>, 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<Action>, getSta
});
};
checkFileList();
publishCheckInterval = setInterval(() => {
checkFileList();
}, 30000);

View file

@ -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