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
if (mode === PUBLISH_MODES.FILE) {
if (isStillEditing || !enablePublishPreview) {
publish(filePath, false);
} else {
if (enablePublishPreview) {
setPreviewing(true);
publish(filePath, true);
} else {
publish(filePath, false);
}
}
}

View file

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

View file

@ -33,6 +33,7 @@ type Props = {
closeModal: () => void,
enablePublishPreview: boolean,
setEnablePublishPreview: boolean => void,
isStillEditing: boolean,
};
class ModalPublishPreview extends React.PureComponent<Props> {
@ -44,6 +45,10 @@ class ModalPublishPreview extends React.PureComponent<Props> {
}
resolveFilePathName(filePath: string | WebFile) {
if (!filePath) {
return '---';
}
if (typeof filePath === 'string') {
return filePath;
} else {
@ -87,9 +92,11 @@ class ModalPublishPreview extends React.PureComponent<Props> {
closeModal,
enablePublishPreview,
setEnablePublishPreview,
isStillEditing,
} = 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 isOptimizeAvail = filePath && filePath !== '' && isVid && ffmpegStatus.available;
@ -150,7 +157,7 @@ class ModalPublishPreview extends React.PureComponent<Props> {
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} />
</div>
<p className="help">{__('Once the transaction is sent, it cannot be reversed.')}</p>