Enable "Publish Preview" on Edit Mode as well.

This commit is contained in:
infiinte-persistence 2020-08-12 09:24:41 +08:00 committed by Sean Yesmunt
parent 16b1605a35
commit abeb7a852c
3 changed files with 19 additions and 6 deletions

View file

@ -289,11 +289,11 @@ function PublishForm(props: Props) {
} }
// Publish file // Publish file
if (mode === PUBLISH_MODES.FILE) { if (mode === PUBLISH_MODES.FILE) {
if (isStillEditing || !enablePublishPreview) { if (enablePublishPreview) {
publish(filePath, false);
} else {
setPreviewing(true); setPreviewing(true);
publish(filePath, true); publish(filePath, true);
} else {
publish(filePath, false);
} }
} }
} }

View file

@ -1,7 +1,12 @@
import { connect } from 'react-redux'; import { connect } from 'react-redux';
import { doHideModal } from 'redux/actions/app'; import { doHideModal } from 'redux/actions/app';
import ModalPublishPreview from './view'; import ModalPublishPreview from './view';
import { makeSelectPublishFormValue, selectPublishFormValues, SETTINGS } from 'lbry-redux'; import {
makeSelectPublishFormValue,
selectPublishFormValues,
selectIsStillEditing,
SETTINGS,
} from 'lbry-redux';
import { selectFfmpegStatus, makeSelectClientSetting } from 'redux/selectors/settings'; import { selectFfmpegStatus, makeSelectClientSetting } from 'redux/selectors/settings';
import { doPublishDesktop } from 'redux/actions/publish'; import { doPublishDesktop } from 'redux/actions/publish';
import { doSetClientSetting } from 'redux/actions/settings'; import { doSetClientSetting } from 'redux/actions/settings';
@ -9,6 +14,7 @@ import { doSetClientSetting } from 'redux/actions/settings';
const select = state => ({ const select = state => ({
...selectPublishFormValues(state), ...selectPublishFormValues(state),
isVid: makeSelectPublishFormValue('fileVid')(state), isVid: makeSelectPublishFormValue('fileVid')(state),
isStillEditing: selectIsStillEditing(state),
ffmpegStatus: selectFfmpegStatus(state), ffmpegStatus: selectFfmpegStatus(state),
enablePublishPreview: makeSelectClientSetting(SETTINGS.ENABLE_PUBLISH_PREVIEW)(state), enablePublishPreview: makeSelectClientSetting(SETTINGS.ENABLE_PUBLISH_PREVIEW)(state),
}); });

View file

@ -33,6 +33,7 @@ type Props = {
closeModal: () => void, closeModal: () => void,
enablePublishPreview: boolean, enablePublishPreview: boolean,
setEnablePublishPreview: boolean => void, setEnablePublishPreview: boolean => void,
isStillEditing: boolean,
}; };
class ModalPublishPreview extends React.PureComponent<Props> { class ModalPublishPreview extends React.PureComponent<Props> {
@ -44,6 +45,10 @@ class ModalPublishPreview extends React.PureComponent<Props> {
} }
resolveFilePathName(filePath: string | WebFile) { resolveFilePathName(filePath: string | WebFile) {
if (!filePath) {
return '---';
}
if (typeof filePath === 'string') { if (typeof filePath === 'string') {
return filePath; return filePath;
} else { } else {
@ -87,9 +92,11 @@ class ModalPublishPreview extends React.PureComponent<Props> {
closeModal, closeModal,
enablePublishPreview, enablePublishPreview,
setEnablePublishPreview, setEnablePublishPreview,
isStillEditing,
} = this.props; } = this.props;
const modalTitle = __('Confirm Publish'); const modalTitle = isStillEditing ? __('Confirm Edit') : __('Confirm Publish');
const confirmBtnText = isStillEditing ? __('Save') : __('Publish');
const txFee = previewResponse ? previewResponse['total_fee'] : null; const txFee = previewResponse ? previewResponse['total_fee'] : null;
const isOptimizeAvail = filePath && filePath !== '' && isVid && ffmpegStatus.available; const isOptimizeAvail = filePath && filePath !== '' && isVid && ffmpegStatus.available;
@ -150,7 +157,7 @@ class ModalPublishPreview extends React.PureComponent<Props> {
actions={ actions={
<> <>
<div className="section__actions"> <div className="section__actions">
<Button autoFocus button="primary" label={__('Publish')} onClick={() => this.onConfirmed()} /> <Button autoFocus button="primary" label={confirmBtnText} onClick={() => this.onConfirmed()} />
<Button button="link" label={__('Cancel')} onClick={closeModal} /> <Button button="link" label={__('Cancel')} onClick={closeModal} />
</div> </div>
<p className="help">{__('Once the transaction is sent, it cannot be reversed.')}</p> <p className="help">{__('Once the transaction is sent, it cannot be reversed.')}</p>