From 48787a1feb78c59b5101da29d5e9f8e555f191a2 Mon Sep 17 00:00:00 2001 From: infiinte-persistence Date: Fri, 31 Jul 2020 21:33:49 +0800 Subject: [PATCH] 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) --- ui/component/publishForm/index.js | 2 +- ui/component/publishForm/view.jsx | 8 ++++++-- ui/redux/actions/publish.js | 15 ++++++++++++++- 3 files changed, 21 insertions(+), 4 deletions(-) diff --git a/ui/component/publishForm/index.js b/ui/component/publishForm/index.js index effcdf9d2..6351fcbc4 100644 --- a/ui/component/publishForm/index.js +++ b/ui/component/publishForm/index.js @@ -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)), diff --git a/ui/component/publishForm/view.jsx b/ui/component/publishForm/view.jsx index 8b47c069b..8048719b7 100644 --- a/ui/component/publishForm/view.jsx +++ b/ui/component/publishForm/view.jsx @@ -37,7 +37,7 @@ const MODES = Object.values(PUBLISH_MODES); type Props = { disabled: boolean, tags: Array, - 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); + } } } diff --git a/ui/redux/actions/publish.js b/ui/redux/actions/publish.js index 8a0435d98..ba9f1177c 100644 --- a/ui/redux/actions/publish.js +++ b/ui/redux/actions/publish.js @@ -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