publish, edit, remote_url publish

This commit is contained in:
zeppi 2021-03-26 17:03:52 -04:00 committed by jessopb
parent c546589cc5
commit 713109167c
6 changed files with 38 additions and 17 deletions

View file

@ -5,6 +5,7 @@ import {
makeSelectClaimForUri,
doPrepareEdit,
selectMyChannelClaims,
makeSelectClaimIsStreamPlaceholder,
} from 'lbry-redux';
import { makeSelectCostInfoForUri } from 'lbryinc';
import { doSetPlayingUri } from 'redux/actions/content';
@ -21,6 +22,7 @@ const select = (state, props) => ({
renderMode: makeSelectFileRenderModeForUri(props.uri)(state),
costInfo: makeSelectCostInfoForUri(props.uri)(state),
myChannels: selectMyChannelClaims(state),
isLivestreamClaim: makeSelectClaimIsStreamPlaceholder(props.uri)(state),
});
const perform = (dispatch) => ({

View file

@ -25,6 +25,7 @@ type Props = {
myChannels: ?Array<ChannelClaim>,
doToast: ({ message: string }) => void,
clearPlayingUri: () => void,
isLivestreamClaim: boolean,
};
function FileActions(props: Props) {
@ -40,6 +41,7 @@ function FileActions(props: Props) {
myChannels,
clearPlayingUri,
doToast,
isLivestreamClaim,
} = props;
const {
push,
@ -112,7 +114,18 @@ function FileActions(props: Props) {
className="button--file-action"
icon={ICONS.EDIT}
label={__('Edit')}
navigate="/$/upload"
navigate="/$/upload?type=livestream"
onClick={() => {
prepareEdit(claim, editUri, fileInfo);
}}
/>
)}
{claimIsMine && isLivestreamClaim && (
<Button
className="button--file-action"
icon={ICONS.PUBLISH}
label={__('Publish Replay')}
navigate="/$/upload?type=file"
onClick={() => {
prepareEdit(claim, editUri, fileInfo);
}}

View file

@ -338,7 +338,7 @@ function PublishFile(props: Props) {
{publishing && <Spinner type={'small'} />}
{inProgress && (
<div>
<Button button="close" label={__('Cancel')} icon={ICONS.REMOVE} onClick={clearPublish} />
<Button button="close" label={__('New')} icon={ICONS.REFRESH} onClick={clearPublish} />
</div>
)}
</div>

View file

@ -18,9 +18,9 @@ import { selectUnclaimedRewardValue } from 'redux/selectors/rewards';
import { selectModal, selectActiveChannelClaim, selectIncognito } from 'redux/selectors/app';
import { makeSelectClientSetting } from 'redux/selectors/settings';
import PublishPage from './view';
import { selectUser } from '../../redux/selectors/user';
import { selectUser } from 'redux/selectors/user';
const select = state => ({
const select = (state) => ({
...selectPublishFormValues(state),
user: selectUser(state),
// The winning claim for a short lbry uri
@ -38,14 +38,14 @@ const select = state => ({
incognito: selectIncognito(state),
});
const perform = dispatch => ({
updatePublishForm: value => dispatch(doUpdatePublishForm(value)),
const perform = (dispatch) => ({
updatePublishForm: (value) => dispatch(doUpdatePublishForm(value)),
clearPublish: () => dispatch(doClearPublish()),
resolveUri: uri => dispatch(doResolveUri(uri)),
resolveUri: (uri) => dispatch(doResolveUri(uri)),
publish: (filePath, preview) => dispatch(doPublishDesktop(filePath, preview)),
prepareEdit: (claim, uri) => dispatch(doPrepareEdit(claim, uri)),
resetThumbnailStatus: () => dispatch(doResetThumbnailStatus()),
checkAvailability: name => dispatch(doCheckPublishNameAvailability(name)),
checkAvailability: (name) => dispatch(doCheckPublishNameAvailability(name)),
});
export default connect(select, perform)(PublishPage);

View file

@ -478,7 +478,7 @@ function PublishForm(props: Props) {
previewing
}
/>
<Button button="link" onClick={clearPublish} label={__('Cancel')} />
<Button button="link" onClick={clearPublish} label={__('New')} />
</div>
<p className="help">
{!formDisabled && !formValid ? (

View file

@ -16,13 +16,13 @@ export default function apiPublishCallViaWeb(
connectionString: string,
token: string,
method: string,
params: { file_path: string, preview: boolean },
params: { file_path: string, preview: boolean, remote_url?: string }, // new param for remoteUrl
resolve: Function,
reject: Function
) {
const { file_path: filePath, preview } = params;
const { file_path: filePath, preview, remote_url: remoteUrl } = params;
if (!filePath) {
if (!filePath && !remoteUrl) {
return apiCall(method, params, resolve, reject);
}
@ -37,7 +37,14 @@ export default function apiPublishCallViaWeb(
// Putting a dummy value here, the server is going to process the POSTed file
// and set the file_path itself
params.file_path = '__POST_FILE__';
const body = new FormData();
if (fileField) {
body.append('file', fileField);
params.file_path = '__POST_FILE__';
} else if (remoteUrl) {
body.append('remote_url', remoteUrl);
}
const jsonPayload = JSON.stringify({
jsonrpc: '2.0',
@ -45,8 +52,7 @@ export default function apiPublishCallViaWeb(
params,
id: counter,
});
const body = new FormData();
body.append('file', fileField);
// no fileData? do the livestream remote publish
body.append('json_payload', jsonPayload);
function makeRequest(connectionString, method, token, body, params) {
@ -55,7 +61,7 @@ export default function apiPublishCallViaWeb(
xhr.open(method, connectionString);
xhr.setRequestHeader(X_LBRY_AUTH_TOKEN, token);
xhr.responseType = 'json';
xhr.upload.onprogress = e => {
xhr.upload.onprogress = (e) => {
let percentComplete = Math.ceil((e.loaded / e.total) * 100);
window.store.dispatch(doUpdateUploadProgress(percentComplete, params, xhr));
};
@ -76,7 +82,7 @@ export default function apiPublishCallViaWeb(
}
return makeRequest(connectionString, 'POST', token, body, params)
.then(xhr => {
.then((xhr) => {
let error;
if (xhr && xhr.response) {
if (xhr.status >= 200 && xhr.status < 300 && !xhr.response.error) {