mirror of
https://github.com/LBRYFoundation/lbry-desktop.git
synced 2025-08-27 15:31:27 +00:00
fix: don't show two pending publish cards for edit publishes
This commit is contained in:
parent
b5aefcabad
commit
05e6fbed12
4 changed files with 38 additions and 30 deletions
|
@ -15,10 +15,9 @@ import { makeSelectCostInfoForUri } from 'redux/selectors/cost_info';
|
||||||
import { selectShowNsfw } from 'redux/selectors/settings';
|
import { selectShowNsfw } from 'redux/selectors/settings';
|
||||||
import { selectMediaPaused } from 'redux/selectors/media';
|
import { selectMediaPaused } from 'redux/selectors/media';
|
||||||
import { doOpenModal } from 'redux/actions/app';
|
import { doOpenModal } from 'redux/actions/app';
|
||||||
import FilePage from './view';
|
|
||||||
import { makeSelectCurrentParam } from 'redux/selectors/navigation';
|
|
||||||
import { selectSubscriptions } from 'redux/selectors/subscriptions';
|
import { selectSubscriptions } from 'redux/selectors/subscriptions';
|
||||||
import { doPrepareEdit } from 'redux/actions/publish';
|
import { doPrepareEdit } from 'redux/actions/publish';
|
||||||
|
import FilePage from './view';
|
||||||
|
|
||||||
const select = (state, props) => ({
|
const select = (state, props) => ({
|
||||||
claim: makeSelectClaimForUri(props.uri)(state),
|
claim: makeSelectClaimForUri(props.uri)(state),
|
||||||
|
@ -40,7 +39,7 @@ const perform = dispatch => ({
|
||||||
fetchCostInfo: uri => dispatch(doFetchCostInfoForUri(uri)),
|
fetchCostInfo: uri => dispatch(doFetchCostInfoForUri(uri)),
|
||||||
checkSubscription: subscription => dispatch(doCheckSubscription(subscription)),
|
checkSubscription: subscription => dispatch(doCheckSubscription(subscription)),
|
||||||
openModal: (modal, props) => dispatch(doOpenModal(modal, props)),
|
openModal: (modal, props) => dispatch(doOpenModal(modal, props)),
|
||||||
prepareEdit: publishData => dispatch(doPrepareEdit(publishData)),
|
prepareEdit: (publishData, uri) => dispatch(doPrepareEdit(publishData, uri)),
|
||||||
});
|
});
|
||||||
|
|
||||||
export default connect(select, perform)(FilePage);
|
export default connect(select, perform)(FilePage);
|
||||||
|
|
|
@ -9,7 +9,6 @@ import FileDetails from 'component/fileDetails';
|
||||||
import FileActions from 'component/fileActions';
|
import FileActions from 'component/fileActions';
|
||||||
import UriIndicator from 'component/uriIndicator';
|
import UriIndicator from 'component/uriIndicator';
|
||||||
import Icon from 'component/common/icon';
|
import Icon from 'component/common/icon';
|
||||||
import WalletSendTip from 'component/walletSendTip';
|
|
||||||
import DateTime from 'component/dateTime';
|
import DateTime from 'component/dateTime';
|
||||||
import * as icons from 'constants/icons';
|
import * as icons from 'constants/icons';
|
||||||
import Button from 'component/button';
|
import Button from 'component/button';
|
||||||
|
@ -72,7 +71,7 @@ class FilePage extends React.Component<Props> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
checkSubscription(props) {
|
checkSubscription = (props: Props) => {
|
||||||
if (
|
if (
|
||||||
props.subscriptions
|
props.subscriptions
|
||||||
.map(subscription => subscription.channelName)
|
.map(subscription => subscription.channelName)
|
||||||
|
@ -89,12 +88,11 @@ class FilePage extends React.Component<Props> {
|
||||||
),
|
),
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
const {
|
const {
|
||||||
claim,
|
claim,
|
||||||
fileInfo,
|
|
||||||
metadata,
|
metadata,
|
||||||
contentType,
|
contentType,
|
||||||
uri,
|
uri,
|
||||||
|
@ -109,10 +107,9 @@ class FilePage extends React.Component<Props> {
|
||||||
} = this.props;
|
} = this.props;
|
||||||
|
|
||||||
// File info
|
// File info
|
||||||
const title = metadata.title;
|
const { title, thumbnail } = metadata;
|
||||||
const isRewardContent = rewardedContentClaimIds.includes(claim.claim_id);
|
const isRewardContent = rewardedContentClaimIds.includes(claim.claim_id);
|
||||||
const shouldObscureThumbnail = obscureNsfw && metadata.nsfw;
|
const shouldObscureThumbnail = obscureNsfw && metadata.nsfw;
|
||||||
const thumbnail = metadata.thumbnail;
|
|
||||||
const { height, channel_name: channelName, value } = claim;
|
const { height, channel_name: channelName, value } = claim;
|
||||||
const mediaType = lbry.getMediaType(contentType);
|
const mediaType = lbry.getMediaType(contentType);
|
||||||
const isPlayable =
|
const isPlayable =
|
||||||
|
@ -165,7 +162,7 @@ class FilePage extends React.Component<Props> {
|
||||||
icon={icons.EDIT}
|
icon={icons.EDIT}
|
||||||
label={__('Edit')}
|
label={__('Edit')}
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
prepareEdit(claim);
|
prepareEdit(claim, uri);
|
||||||
navigate('/publish');
|
navigate('/publish');
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
|
|
|
@ -15,7 +15,6 @@ import { CHANNEL_NEW, CHANNEL_ANONYMOUS } from 'constants/claim';
|
||||||
type Action = UpdatePublishFormAction | { type: ACTIONS.CLEAR_PUBLISH };
|
type Action = UpdatePublishFormAction | { type: ACTIONS.CLEAR_PUBLISH };
|
||||||
type PromiseAction = Promise<Action>;
|
type PromiseAction = Promise<Action>;
|
||||||
type Dispatch = (action: Action | PromiseAction | Array<Action>) => any;
|
type Dispatch = (action: Action | PromiseAction | Array<Action>) => any;
|
||||||
type ThunkAction = (dispatch: Dispatch) => any;
|
|
||||||
type GetState = () => {};
|
type GetState = () => {};
|
||||||
|
|
||||||
export const doClearPublish = () => (dispatch: Dispatch): Action =>
|
export const doClearPublish = () => (dispatch: Dispatch): Action =>
|
||||||
|
@ -29,7 +28,7 @@ export const doUpdatePublishForm = (publishFormValue: UpdatePublishFormData) =>
|
||||||
data: { ...publishFormValue },
|
data: { ...publishFormValue },
|
||||||
});
|
});
|
||||||
|
|
||||||
export const doPrepareEdit = (claim: any) => (dispatch: Dispatch) => {
|
export const doPrepareEdit = (claim: any, uri: string) => (dispatch: Dispatch) => {
|
||||||
const { name, amount, channel_name: channelName, value: { stream: { metadata } } } = claim;
|
const { name, amount, channel_name: channelName, value: { stream: { metadata } } } = claim;
|
||||||
const {
|
const {
|
||||||
author,
|
author,
|
||||||
|
@ -63,12 +62,16 @@ export const doPrepareEdit = (claim: any) => (dispatch: Dispatch) => {
|
||||||
nsfw,
|
nsfw,
|
||||||
thumbnail,
|
thumbnail,
|
||||||
title,
|
title,
|
||||||
|
uri,
|
||||||
};
|
};
|
||||||
|
|
||||||
dispatch({ type: ACTIONS.DO_PREPARE_EDIT, data: publishData });
|
dispatch({ type: ACTIONS.DO_PREPARE_EDIT, data: publishData });
|
||||||
};
|
};
|
||||||
|
|
||||||
export const doPublish = (params: PublishParams): ThunkAction => {
|
export const doPublish = (params: PublishParams) => (dispatch: Dispatch, getState: () => {}) => {
|
||||||
|
const state = getState();
|
||||||
|
const myClaims = selectMyClaimsWithoutChannels(state);
|
||||||
|
|
||||||
const {
|
const {
|
||||||
name,
|
name,
|
||||||
bid,
|
bid,
|
||||||
|
@ -87,6 +90,17 @@ export const doPublish = (params: PublishParams): ThunkAction => {
|
||||||
sources,
|
sources,
|
||||||
} = params;
|
} = params;
|
||||||
|
|
||||||
|
let isEdit;
|
||||||
|
const newPublishName = channel ? `${channel}/${name}` : name;
|
||||||
|
for (let i = 0; i < myClaims.length; i += 1) {
|
||||||
|
const { channel_name: claimChannelName, name: claimName } = myClaims[i];
|
||||||
|
const contentName = claimChannelName ? `${claimChannelName}/${claimName}` : claimName;
|
||||||
|
if (contentName === newPublishName) {
|
||||||
|
isEdit = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
const channelName = channel === CHANNEL_ANONYMOUS || channel === CHANNEL_NEW ? '' : channel;
|
const channelName = channel === CHANNEL_ANONYMOUS || channel === CHANNEL_NEW ? '' : channel;
|
||||||
const fee = contentIsFree || !price.amount ? undefined : { ...price };
|
const fee = contentIsFree || !price.amount ? undefined : { ...price };
|
||||||
|
|
||||||
|
@ -120,24 +134,22 @@ export const doPublish = (params: PublishParams): ThunkAction => {
|
||||||
publishPayload.sources = sources;
|
publishPayload.sources = sources;
|
||||||
}
|
}
|
||||||
|
|
||||||
return (dispatch: Dispatch) => {
|
dispatch({ type: ACTIONS.PUBLISH_START });
|
||||||
dispatch({ type: ACTIONS.PUBLISH_START });
|
|
||||||
|
|
||||||
const success = () => {
|
const success = () => {
|
||||||
dispatch({
|
dispatch({
|
||||||
type: ACTIONS.PUBLISH_SUCCESS,
|
type: ACTIONS.PUBLISH_SUCCESS,
|
||||||
data: { pendingPublish: publishPayload },
|
data: { pendingPublish: { ...publishPayload, isEdit } },
|
||||||
});
|
});
|
||||||
dispatch(doOpenModal(MODALS.PUBLISH, { uri }));
|
dispatch(doOpenModal(MODALS.PUBLISH, { uri }));
|
||||||
};
|
|
||||||
|
|
||||||
const failure = error => {
|
|
||||||
dispatch({ type: ACTIONS.PUBLISH_FAIL });
|
|
||||||
dispatch(doOpenModal(MODALS.ERROR, { error: error.message }));
|
|
||||||
};
|
|
||||||
|
|
||||||
return Lbry.publish(publishPayload).then(success, failure);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const failure = error => {
|
||||||
|
dispatch({ type: ACTIONS.PUBLISH_FAIL });
|
||||||
|
dispatch(doOpenModal(MODALS.ERROR, { error: error.message }));
|
||||||
|
};
|
||||||
|
|
||||||
|
return Lbry.publish(publishPayload).then(success, failure);
|
||||||
};
|
};
|
||||||
|
|
||||||
// Calls claim_list_mine until any pending publishes are confirmed
|
// Calls claim_list_mine until any pending publishes are confirmed
|
||||||
|
|
|
@ -10,7 +10,7 @@ export const selectPendingPublishes = createSelector(
|
||||||
|
|
||||||
export const selectPendingPublishesLessEdits = createSelector(
|
export const selectPendingPublishesLessEdits = createSelector(
|
||||||
selectPendingPublishes,
|
selectPendingPublishes,
|
||||||
pendingPublishes => pendingPublishes.filter(pendingPublish => !pendingPublish.sources)
|
pendingPublishes => pendingPublishes.filter(pendingPublish => !pendingPublish.isEdit)
|
||||||
);
|
);
|
||||||
|
|
||||||
export const selectPublishFormValues = createSelector(selectState, state => {
|
export const selectPublishFormValues = createSelector(selectState, state => {
|
||||||
|
|
Loading…
Add table
Reference in a new issue