fix: show pending publishes immediately
This commit is contained in:
parent
c3ef95daaa
commit
abb5917329
5 changed files with 47 additions and 11 deletions
|
@ -43,6 +43,7 @@
|
||||||
"class-methods-use-this": 0,
|
"class-methods-use-this": 0,
|
||||||
"jsx-a11y/interactive-supports-focus": 0,
|
"jsx-a11y/interactive-supports-focus": 0,
|
||||||
"jsx-a11y/click-events-have-key-events": 0,
|
"jsx-a11y/click-events-have-key-events": 0,
|
||||||
"consistent-return": 0
|
"consistent-return": 0,
|
||||||
|
"flowtype/space-after-type-colon": [ 2, "always", { "allowLineBreak": true } ]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,9 @@
|
||||||
import { connect } from 'react-redux';
|
import { connect } from 'react-redux';
|
||||||
import { selectPendingPublishes } from 'redux/selectors/publish';
|
import {
|
||||||
import { selectIsFetchingClaimListMine, selectFileListPublishedSort, selectMyClaimsWithoutChannels } from 'lbry-redux';
|
selectIsFetchingClaimListMine,
|
||||||
|
selectFileListPublishedSort,
|
||||||
|
selectMyClaimsWithoutChannels,
|
||||||
|
} from 'lbry-redux';
|
||||||
import { doNavigate } from 'redux/actions/navigation';
|
import { doNavigate } from 'redux/actions/navigation';
|
||||||
import { doCheckPendingPublishes } from 'redux/actions/publish';
|
import { doCheckPendingPublishes } from 'redux/actions/publish';
|
||||||
import FileListPublished from './view';
|
import FileListPublished from './view';
|
||||||
|
|
|
@ -22,7 +22,6 @@ class FileListPublished extends React.PureComponent<Props> {
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
const { fetching, claims, navigate, sortBy } = this.props;
|
const { fetching, claims, navigate, sortBy } = this.props;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Page notContained loading={fetching}>
|
<Page notContained loading={fetching}>
|
||||||
{claims && claims.length ? (
|
{claims && claims.length ? (
|
||||||
|
|
|
@ -16,6 +16,7 @@ import {
|
||||||
batchActions,
|
batchActions,
|
||||||
creditsToString,
|
creditsToString,
|
||||||
selectPendingById,
|
selectPendingById,
|
||||||
|
selectMyClaimsWithoutChannels,
|
||||||
} from 'lbry-redux';
|
} from 'lbry-redux';
|
||||||
import { selectosNotificationsEnabled } from 'redux/selectors/settings';
|
import { selectosNotificationsEnabled } from 'redux/selectors/settings';
|
||||||
import { doNavigate } from 'redux/actions/navigation';
|
import { doNavigate } from 'redux/actions/navigation';
|
||||||
|
@ -199,6 +200,7 @@ export const doPublish = (params: PublishParams) => (
|
||||||
) => {
|
) => {
|
||||||
const state = getState();
|
const state = getState();
|
||||||
const myChannels = selectMyChannelClaims(state);
|
const myChannels = selectMyChannelClaims(state);
|
||||||
|
const myClaims = selectMyClaimsWithoutChannels(state);
|
||||||
|
|
||||||
const {
|
const {
|
||||||
name,
|
name,
|
||||||
|
@ -223,7 +225,7 @@ export const doPublish = (params: PublishParams) => (
|
||||||
const channelId = namedChannelClaim ? namedChannelClaim.claim_id : '';
|
const channelId = namedChannelClaim ? namedChannelClaim.claim_id : '';
|
||||||
const fee = contentIsFree || !price.amount ? undefined : { ...price };
|
const fee = contentIsFree || !price.amount ? undefined : { ...price };
|
||||||
|
|
||||||
const metadata = {
|
const metadata: Metadata = {
|
||||||
title,
|
title,
|
||||||
nsfw,
|
nsfw,
|
||||||
license,
|
license,
|
||||||
|
@ -262,11 +264,30 @@ export const doPublish = (params: PublishParams) => (
|
||||||
|
|
||||||
dispatch({ type: ACTIONS.PUBLISH_START });
|
dispatch({ type: ACTIONS.PUBLISH_START });
|
||||||
|
|
||||||
const success = () => {
|
const success = pendingClaim => {
|
||||||
dispatch({
|
const actions = [];
|
||||||
|
|
||||||
|
actions.push({
|
||||||
type: ACTIONS.PUBLISH_SUCCESS,
|
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 => {
|
const failure = error => {
|
||||||
|
@ -281,7 +302,8 @@ export const doPublish = (params: PublishParams) => (
|
||||||
export const doCheckPendingPublishes = () => (dispatch: Dispatch<Action>, getState: GetState) => {
|
export const doCheckPendingPublishes = () => (dispatch: Dispatch<Action>, getState: GetState) => {
|
||||||
const state = getState();
|
const state = getState();
|
||||||
const pendingById = selectPendingById(state);
|
const pendingById = selectPendingById(state);
|
||||||
if (!Object.keys(pendingById)) {
|
|
||||||
|
if (!Object.keys(pendingById).length) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -290,7 +312,7 @@ export const doCheckPendingPublishes = () => (dispatch: Dispatch<Action>, getSta
|
||||||
const checkFileList = () => {
|
const checkFileList = () => {
|
||||||
Lbry.claim_list_mine().then(claims => {
|
Lbry.claim_list_mine().then(claims => {
|
||||||
claims.forEach(claim => {
|
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]) {
|
if (claim.confirmations > 0 && pendingById[claim.claim_id]) {
|
||||||
delete pendingById[claim.claim_id];
|
delete pendingById[claim.claim_id];
|
||||||
|
|
||||||
|
@ -326,7 +348,6 @@ export const doCheckPendingPublishes = () => (dispatch: Dispatch<Action>, getSta
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
checkFileList();
|
|
||||||
publishCheckInterval = setInterval(() => {
|
publishCheckInterval = setInterval(() => {
|
||||||
checkFileList();
|
checkFileList();
|
||||||
}, 30000);
|
}, 30000);
|
||||||
|
|
|
@ -14,6 +14,18 @@ export type Metadata = {
|
||||||
title: string,
|
title: string,
|
||||||
thumbnail: ?string,
|
thumbnail: ?string,
|
||||||
description: ?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
|
// Actual claim type has more values than this
|
||||||
|
|
Loading…
Add table
Reference in a new issue