fix: multiple pending publishes when editing

This commit is contained in:
Sean Yesmunt 2018-04-04 12:08:27 -04:00
parent 66b63a27c7
commit 5489d99099
5 changed files with 28 additions and 16 deletions

View file

@ -1,4 +1,3 @@
import React from 'react';
import { connect } from 'react-redux';
import { doNavigate } from 'redux/actions/navigation';
import { doResolveUri } from 'redux/actions/content';
@ -10,12 +9,10 @@ import { selectPendingPublish } from 'redux/selectors/publish';
import FileCard from './view';
const select = (state, props) => {
let claim;
let fileInfo;
let metadata;
let isResolvingUri;
const pendingPublish = selectPendingPublish(props.uri)(state);
let pendingPublish;
if (props.checkPending) {
pendingPublish = selectPendingPublish(props.uri)(state);
}
const fileCardInfo = pendingPublish || {
claim: makeSelectClaimForUri(props.uri)(state),

View file

@ -25,6 +25,7 @@ type Props = {
sortByHeight?: boolean,
claimsById: Array<{}>,
fileInfos: Array<FileInfo>,
checkPending?: boolean,
};
type State = {
@ -138,7 +139,7 @@ class FileList extends React.PureComponent<Props, State> {
}
render() {
const { fileInfos, hideFilter } = this.props;
const { fileInfos, hideFilter, checkPending } = this.props;
const { sortBy } = this.state;
const content = [];
@ -166,7 +167,7 @@ class FileList extends React.PureComponent<Props, State> {
const uri = buildURI(uriParams);
content.push(<FileCard key={uri} uri={uri} />);
content.push(<FileCard key={uri} uri={uri} checkPending={checkPending} />);
});
return (

View file

@ -1,13 +1,13 @@
import { connect } from 'react-redux';
import { selectMyClaimsWithoutChannels } from 'redux/selectors/claims';
import { selectPendingPublishes } from 'redux/selectors/publish';
import { selectPendingPublishesLessEdits } from 'redux/selectors/publish';
import { doNavigate } from 'redux/actions/navigation';
import { doCheckPendingPublishes } from 'redux/actions/publish';
import FileListPublished from './view';
const select = state => ({
claims: selectMyClaimsWithoutChannels(state),
pendingPublishes: selectPendingPublishes(state),
pendingPublishes: selectPendingPublishesLessEdits(state),
});
const perform = dispatch => ({

View file

@ -1,9 +1,17 @@
// @flow
import React from 'react';
import Button from 'component/button';
import FileList from 'component/fileList';
import Page from 'component/page';
class FileListPublished extends React.PureComponent {
type Props = {
pendingPublishes: Array<{}>,
claims: Array<{}>,
checkIfPublishesConfirmed: (Array<{}>) => void,
navigate: (string, ?{}) => void,
};
class FileListPublished extends React.PureComponent<Props> {
componentDidMount() {
const { pendingPublishes, checkIfPublishesConfirmed } = this.props;
if (pendingPublishes.length) {
@ -18,7 +26,7 @@ class FileListPublished extends React.PureComponent {
return (
<Page notContained>
{fileInfos.length ? (
<FileList fileInfos={fileInfos} sortByHeight />
<FileList checkPending fileInfos={fileInfos} sortByHeight />
) : (
<div className="page__empty">
{__("It looks like you haven't published anything to LBRY yet.")}

View file

@ -3,9 +3,15 @@ import { parseURI } from 'lbryURI';
const selectState = state => state.publish || {};
export const selectPendingPublishes = createSelector(selectState, state => {
return state.pendingPublishes.map(pendingClaim => ({ ...pendingClaim, pending: true })) || [];
});
export const selectPendingPublishes = createSelector(
selectState,
state => state.pendingPublishes.map(pendingClaim => ({ ...pendingClaim, pending: true })) || []
);
export const selectPendingPublishesLessEdits = createSelector(
selectPendingPublishes,
pendingPublishes => pendingPublishes.filter(pendingPublish => !pendingPublish.sources)
);
export const selectPublishFormValues = createSelector(selectState, state => {
const { pendingPublish, ...formValues } = state;