From 35dd7650fb235109d4a7ab44d1f6dde63dfdf2f7 Mon Sep 17 00:00:00 2001 From: infiinte-persistence Date: Fri, 30 Apr 2021 16:22:28 +0800 Subject: [PATCH] Change how release_time is edited. - `releaseTime` is now a number instead of a string, matching `release_time`. It was getting confusing what the variable units were. - `releaseTime` will always match `release_time` for an edit. It will be used in the GUI to reset just the date to the original, instead of having to reset the entire form. - `releaseTimeEdited` will be used by `updatePublishForm` in the GUI to represent the desired new release time. Set to `undefined` if we don't want to change the date. --- dist/bundle.es.js | 10 ++++++---- src/redux/actions/publish.js | 9 +++++---- src/redux/reducers/publish.js | 4 +++- 3 files changed, 14 insertions(+), 9 deletions(-) diff --git a/dist/bundle.es.js b/dist/bundle.es.js index d4b83f9..e292bea 100644 --- a/dist/bundle.es.js +++ b/dist/bundle.es.js @@ -4786,7 +4786,8 @@ const doPrepareEdit = (claim, uri, fileInfo, fs) => dispatch => { description, fee, languages, - release_time: release_time ? Number(release_time) * 1000 : undefined, + releaseTime: release_time, + releaseTimeEdited: undefined, thumbnail: thumbnail ? thumbnail.url : null, title, uri, @@ -4837,7 +4838,7 @@ const doPublish = (success, fail, preview) => (dispatch, getState) => { filePath, description, language, - releaseTime, + releaseTimeEdited, license, licenseUrl, useLBRYUploader, @@ -4909,8 +4910,8 @@ const doPublish = (success, fail, preview) => (dispatch, getState) => { } // Set release time to curret date. On edits, keep original release/transaction time as release_time - if (releaseTime) { - publishPayload.release_time = Number(Math.round(new Date(releaseTime) / 1000)); + if (releaseTimeEdited) { + publishPayload.release_time = releaseTimeEdited; } else if (myClaimForUriEditing && myClaimForUriEditing.value.release_time) { publishPayload.release_time = Number(myClaimForUri.value.release_time); } else if (myClaimForUriEditing && myClaimForUriEditing.timestamp) { @@ -6060,6 +6061,7 @@ const defaultState$4 = { description: '', language: '', releaseTime: undefined, + releaseTimeEdited: undefined, nsfw: false, channel: CHANNEL_ANONYMOUS, channelId: '', diff --git a/src/redux/actions/publish.js b/src/redux/actions/publish.js index a17dfbc..181a378 100644 --- a/src/redux/actions/publish.js +++ b/src/redux/actions/publish.js @@ -200,7 +200,8 @@ export const doPrepareEdit = (claim: StreamClaim, uri: string, fileInfo: FileLis description, fee, languages, - releaseTime: release_time ? Number(release_time) * 1000 : undefined, + releaseTime: release_time, + releaseTimeEdited: undefined, thumbnail: thumbnail ? thumbnail.url : null, title, uri, @@ -254,7 +255,7 @@ export const doPublish = (success: Function, fail: Function, preview: Function) filePath, description, language, - releaseTime, + releaseTimeEdited, license, licenseUrl, useLBRYUploader, @@ -347,8 +348,8 @@ export const doPublish = (success: Function, fail: Function, preview: Function) } // Set release time to curret date. On edits, keep original release/transaction time as release_time - if (releaseTime) { - publishPayload.release_time = Number(Math.round(new Date(releaseTime) / 1000)); + if (releaseTimeEdited) { + publishPayload.release_time = releaseTimeEdited; } else if (myClaimForUriEditing && myClaimForUriEditing.value.release_time) { publishPayload.release_time = Number(myClaimForUri.value.release_time); } else if (myClaimForUriEditing && myClaimForUriEditing.timestamp) { diff --git a/src/redux/reducers/publish.js b/src/redux/reducers/publish.js index 39e40f5..794c43d 100644 --- a/src/redux/reducers/publish.js +++ b/src/redux/reducers/publish.js @@ -25,7 +25,8 @@ type PublishState = { thumbnailError: ?boolean, description: string, language: string, - releaseTime: ?string, + releaseTime: ?number, + releaseTimeEdited: ?number, channel: string, channelId: ?string, name: string, @@ -60,6 +61,7 @@ const defaultState: PublishState = { description: '', language: '', releaseTime: undefined, + releaseTimeEdited: undefined, nsfw: false, channel: CHANNEL_ANONYMOUS, channelId: '',