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

View file

@ -25,6 +25,7 @@ type Props = {
myChannels: ?Array<ChannelClaim>, myChannels: ?Array<ChannelClaim>,
doToast: ({ message: string }) => void, doToast: ({ message: string }) => void,
clearPlayingUri: () => void, clearPlayingUri: () => void,
isLivestreamClaim: boolean,
}; };
function FileActions(props: Props) { function FileActions(props: Props) {
@ -40,6 +41,7 @@ function FileActions(props: Props) {
myChannels, myChannels,
clearPlayingUri, clearPlayingUri,
doToast, doToast,
isLivestreamClaim,
} = props; } = props;
const { const {
push, push,
@ -112,7 +114,18 @@ function FileActions(props: Props) {
className="button--file-action" className="button--file-action"
icon={ICONS.EDIT} icon={ICONS.EDIT}
label={__('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={() => { onClick={() => {
prepareEdit(claim, editUri, fileInfo); prepareEdit(claim, editUri, fileInfo);
}} }}

View file

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

View file

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

View file

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

View file

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