add 'lbry-first' tag to lbry-first publishes
This commit is contained in:
parent
0f80568acd
commit
1523bbd33f
4 changed files with 52 additions and 34 deletions
24
dist/bundle.es.js
vendored
24
dist/bundle.es.js
vendored
|
@ -1261,14 +1261,17 @@ const LbryFirst = {
|
|||
upload: (params = {}) => {
|
||||
// Only upload when originally publishing for now
|
||||
if (!params.file_path) {
|
||||
return {};
|
||||
return new Promise();
|
||||
}
|
||||
const uploadParams = {};
|
||||
uploadParams.Title = params.title;
|
||||
uploadParams.Description = params.description;
|
||||
uploadParams.FilePath = params.file_path;
|
||||
uploadParams.Category = '';
|
||||
uploadParams.Keywords = '';
|
||||
|
||||
const uploadParams = {
|
||||
Title: params.title,
|
||||
Description: params.description,
|
||||
FilePath: params.file_path,
|
||||
Category: '',
|
||||
Keywords: ''
|
||||
};
|
||||
|
||||
return lbryFirstCallWithResult('youtube.Upload', uploadParams);
|
||||
},
|
||||
|
||||
|
@ -1350,7 +1353,6 @@ function apiCall$1(method, params, resolve, reject) {
|
|||
}
|
||||
|
||||
function lbryFirstCallWithResult(name, params = {}) {
|
||||
console.log(`LbryFirst: calling ${name}`);
|
||||
return new Promise((resolve, reject) => {
|
||||
apiCall$1(name, params, result => {
|
||||
resolve(result);
|
||||
|
@ -4681,6 +4683,10 @@ const doPublish = (success, fail) => (dispatch, getState) => {
|
|||
publishPayload.thumbnail_url = thumbnail;
|
||||
}
|
||||
|
||||
if (useLBRYUploader) {
|
||||
publishPayload.tags.push('lbry-first');
|
||||
}
|
||||
|
||||
// Set release time to curret date. On edits, keep original release/transaction time as release_time
|
||||
if (myClaimForUriEditing && myClaimForUriEditing.value.release_time) {
|
||||
publishPayload.release_time = Number(myClaimForUri.value.release_time);
|
||||
|
@ -4710,7 +4716,7 @@ const doPublish = (success, fail) => (dispatch, getState) => {
|
|||
// Only pass file on new uploads, not metadata only edits.
|
||||
// The sdk will figure it out
|
||||
if (filePath) publishPayload.file_path = filePath;
|
||||
// if (useLBRYUploader) return LbryFirst.upload(publishPayload);
|
||||
|
||||
return lbryProxy.publish(publishPayload).then(response => {
|
||||
if (!useLBRYUploader) {
|
||||
return success(response);
|
||||
|
|
10
flow-typed/LbryFirst.js
vendored
10
flow-typed/LbryFirst.js
vendored
|
@ -71,9 +71,9 @@ declare type UploadResponse = {
|
|||
|
||||
declare type HasYTAuthResponse = {
|
||||
HashAuth: boolean,
|
||||
}
|
||||
};
|
||||
|
||||
declare type YTSignupResponse = {}
|
||||
declare type YTSignupResponse = {};
|
||||
|
||||
//
|
||||
// Types used in the generic LbryFirst object that is exported
|
||||
|
@ -93,7 +93,7 @@ declare type LbryFirstTypes = {
|
|||
stop: () => Promise<string>,
|
||||
status: () => Promise<StatusResponse>,
|
||||
version: () => Promise<VersionResponse>,
|
||||
upload: (params: {}) => Promise<UploadResponse>,
|
||||
hasYTAuth: () =>Promise<HasYTAuthResponse>,
|
||||
ytSignup: () =>Promise<YTSignupResponse>,
|
||||
upload: any => Promise<?UploadResponse>,
|
||||
hasYTAuth: () => Promise<HasYTAuthResponse>,
|
||||
ytSignup: () => Promise<YTSignupResponse>,
|
||||
};
|
||||
|
|
|
@ -23,7 +23,8 @@ const LbryFirst: LbryFirstTypes = {
|
|||
},
|
||||
|
||||
unsetApiHeader: key => {
|
||||
Object.keys(LbryFirst.apiRequestHeaders).includes(key) && delete LbryFirst.apiRequestHeaders['key'];
|
||||
Object.keys(LbryFirst.apiRequestHeaders).includes(key) &&
|
||||
delete LbryFirst.apiRequestHeaders['key'];
|
||||
},
|
||||
// Allow overriding Lbry methods
|
||||
overrides: {},
|
||||
|
@ -40,17 +41,26 @@ const LbryFirst: LbryFirstTypes = {
|
|||
version: () => lbryFirstCallWithResult('version', {}),
|
||||
|
||||
// Upload to youtube
|
||||
upload: (params = {}) => {
|
||||
upload: (params: { title: string, description: string, file_path: ?string } = {}) => {
|
||||
// Only upload when originally publishing for now
|
||||
if (!params.file_path) {
|
||||
return {};
|
||||
return Promise.resolve();
|
||||
}
|
||||
const uploadParams = {};
|
||||
uploadParams.Title = params.title;
|
||||
uploadParams.Description = params.description;
|
||||
uploadParams.FilePath = params.file_path;
|
||||
uploadParams.Category = '';
|
||||
uploadParams.Keywords = '';
|
||||
|
||||
const uploadParams: {
|
||||
Title: string,
|
||||
Description: string,
|
||||
FilePath: string,
|
||||
Category: string,
|
||||
Keywords: string,
|
||||
} = {
|
||||
Title: params.title,
|
||||
Description: params.description,
|
||||
FilePath: params.file_path,
|
||||
Category: '',
|
||||
Keywords: '',
|
||||
};
|
||||
|
||||
return lbryFirstCallWithResult('youtube.Upload', uploadParams);
|
||||
},
|
||||
|
||||
|
@ -111,14 +121,14 @@ function checkAndParse(response) {
|
|||
|
||||
export function apiCall(method: string, params: ?{}, resolve: Function, reject: Function) {
|
||||
const counter = new Date().getTime();
|
||||
params = [params];
|
||||
const paramsArray = [params];
|
||||
const options = {
|
||||
method: 'POST',
|
||||
headers: LbryFirst.apiRequestHeaders,
|
||||
body: JSON.stringify({
|
||||
jsonrpc: '2.0',
|
||||
method,
|
||||
params,
|
||||
params: paramsArray,
|
||||
id: counter,
|
||||
}),
|
||||
};
|
||||
|
@ -137,7 +147,6 @@ export function apiCall(method: string, params: ?{}, resolve: Function, reject:
|
|||
}
|
||||
|
||||
function lbryFirstCallWithResult(name: string, params: ?{} = {}) {
|
||||
console.log(`LbryFirst: calling ${name}`);
|
||||
return new Promise((resolve, reject) => {
|
||||
apiCall(
|
||||
name,
|
||||
|
|
|
@ -323,6 +323,10 @@ export const doPublish = (success: Function, fail: Function) => (
|
|||
publishPayload.thumbnail_url = thumbnail;
|
||||
}
|
||||
|
||||
if (useLBRYUploader) {
|
||||
publishPayload.tags.push('lbry-first');
|
||||
}
|
||||
|
||||
// Set release time to curret date. On edits, keep original release/transaction time as release_time
|
||||
if (myClaimForUriEditing && myClaimForUriEditing.value.release_time) {
|
||||
publishPayload.release_time = Number(myClaimForUri.value.release_time);
|
||||
|
@ -352,9 +356,8 @@ export const doPublish = (success: Function, fail: Function) => (
|
|||
// Only pass file on new uploads, not metadata only edits.
|
||||
// The sdk will figure it out
|
||||
if (filePath) publishPayload.file_path = filePath;
|
||||
// if (useLBRYUploader) return LbryFirst.upload(publishPayload);
|
||||
return Lbry.publish(publishPayload)
|
||||
.then((response) => {
|
||||
|
||||
return Lbry.publish(publishPayload).then(response => {
|
||||
if (!useLBRYUploader) {
|
||||
return success(response);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue