doPublishDesktop: Call the "preview" modal before doing the actual publish.

This requires an accompanying change in lbry-redux. Search for "SETTINGS.ENABLE_PUBLISH_PREVIEW" in the commit message to find the commit.

In Edit Mode, the preview will not appear. Not sure if it's needed, plus there are more things to handle in Edit mode (e.g. which items are changed)
This commit is contained in:
infiinte-persistence 2020-07-31 21:33:49 +08:00 committed by Sean Yesmunt
parent 4c3728a20f
commit 48787a1feb
3 changed files with 21 additions and 4 deletions

View file

@ -33,7 +33,7 @@ const perform = dispatch => ({
updatePublishForm: value => dispatch(doUpdatePublishForm(value)),
clearPublish: () => dispatch(doClearPublish()),
resolveUri: uri => dispatch(doResolveUri(uri)),
publish: filePath => dispatch(doPublishDesktop(filePath)),
publish: (filePath, preview) => dispatch(doPublishDesktop(filePath, preview)),
prepareEdit: (claim, uri) => dispatch(doPrepareEdit(claim, uri)),
resetThumbnailStatus: () => dispatch(doResetThumbnailStatus()),
checkAvailability: name => dispatch(doCheckPublishNameAvailability(name)),

View file

@ -37,7 +37,7 @@ const MODES = Object.values(PUBLISH_MODES);
type Props = {
disabled: boolean,
tags: Array<Tag>,
publish: (source?: string | File) => void,
publish: (source?: string | File, ?boolean) => void,
filePath: string | File,
fileText: string,
bid: ?number,
@ -274,7 +274,11 @@ function PublishForm(props: Props) {
}
// Publish file
if (mode === PUBLISH_MODES.FILE) {
publish(filePath);
if (isStillEditing) {
publish(filePath, false);
} else {
publish(filePath, true);
}
}
}

View file

@ -15,7 +15,15 @@ import { push } from 'connected-react-router';
import analytics from 'analytics';
import { doOpenModal } from './app';
export const doPublishDesktop = (filePath: string) => (dispatch: Dispatch, getState: () => {}) => {
export const doPublishDesktop = (filePath: string, preview?: boolean) => (dispatch: Dispatch, getState: () => {}) => {
const publishPreview = previewResponse => {
dispatch(
doOpenModal(MODALS.PUBLISH_PREVIEW, {
previewResponse,
})
);
};
const publishSuccess = (successResponse, lbryFirstError) => {
const state = getState();
const myClaims = selectMyClaims(state);
@ -74,6 +82,11 @@ export const doPublishDesktop = (filePath: string) => (dispatch: Dispatch, getSt
dispatch(batchActions(...actions));
};
if (preview) {
dispatch(doPublish(publishSuccess, publishFail, publishPreview));
return;
}
// Redirect on web immediately because we have a file upload progress componenet
// on the publishes page. This doesn't exist on desktop so wait until we get a response
// from the SDK