From e83153804d66f17bf2e3ea11d3e26ce477a07ea6 Mon Sep 17 00:00:00 2001 From: zeppi Date: Thu, 19 Aug 2021 14:22:22 -0400 Subject: [PATCH 1/3] add isBackgroundUpdate to collection update --- src/redux/actions/claims.js | 41 +++++++++++++++++++++++-------------- 1 file changed, 26 insertions(+), 15 deletions(-) diff --git a/src/redux/actions/claims.js b/src/redux/actions/claims.js index 37212a1..5e50a2b 100644 --- a/src/redux/actions/claims.js +++ b/src/redux/actions/claims.js @@ -19,7 +19,7 @@ import { creditsToString } from 'util/format-credits'; import { batchActions } from 'util/batch-actions'; import { createNormalizedClaimSearchKey } from 'util/claim'; import { PAGE_SIZE } from 'constants/claim'; -import { selectPendingCollections } from 'redux/selectors/collections'; +import { selectPendingCollections, makeSelectEditedCollectionForId } from 'redux/selectors/collections'; import { doFetchItemsInCollection, doFetchItemsInCollections, @@ -838,9 +838,10 @@ export function doCollectionPublishUpdate(options: { tags?: Array, languages?: Array, claims?: Array, -}) { - return (dispatch: Dispatch): Promise => { +}, isBackgroundUpdate?: boolean) { + return (dispatch: Dispatch, getState: GetState): Promise => { // TODO: implement one click update + const state = getState(); const updateParams: { bid?: string, @@ -853,18 +854,28 @@ export function doCollectionPublishUpdate(options: { languages?: Array, claims?: Array, clear_claims: boolean, - } = { - bid: creditsToString(options.bid), - title: options.title, - thumbnail_url: options.thumbnail_url, - description: options.description, - tags: [], - languages: options.languages || [], - locations: [], - blocking: true, - claim_id: options.claim_id, - clear_claims: true, - }; + } = isBackgroundUpdate + ? { + blocking: true, + claim_id: options.claim_id, + clear_claims: true, + } + : { + bid: creditsToString(options.bid), + title: options.title, + thumbnail_url: options.thumbnail_url, + description: options.description, + tags: [], + languages: options.languages || [], + locations: [], + blocking: true, + claim_id: options.claim_id, + clear_claims: true, + }; + + if (isBackgroundUpdate && updateParams.claim_id) { + updateParams.claims = makeSelectEditedCollectionForId(updateParams.claim_id)(state); + } if (options.tags) { updateParams['tags'] = options.tags.map(tag => tag.name); -- 2.45.2 From d45317807e07f89ece59e79cbd46062f8ef141e7 Mon Sep 17 00:00:00 2001 From: zeppi Date: Sun, 22 Aug 2021 15:52:44 -0400 Subject: [PATCH 2/3] fix background collection update --- dist/bundle.es.js | 20 +++++++---- src/redux/actions/claims.js | 71 ++++++++++++++++++++----------------- 2 files changed, 52 insertions(+), 39 deletions(-) diff --git a/dist/bundle.es.js b/dist/bundle.es.js index 9e7d8d0..33c7574 100644 --- a/dist/bundle.es.js +++ b/dist/bundle.es.js @@ -4465,11 +4465,16 @@ function doCollectionPublish(options, localId) { }; } -function doCollectionPublishUpdate(options) { - return dispatch => { +function doCollectionPublishUpdate(options, isBackgroundUpdate) { + return (dispatch, getState) => { // TODO: implement one click update + const state = getState(); - const updateParams = { + const updateParams = isBackgroundUpdate ? { + blocking: true, + claim_id: options.claim_id, + clear_claims: true + } : { bid: creditsToString(options.bid), title: options.title, thumbnail_url: options.thumbnail_url, @@ -4482,13 +4487,16 @@ function doCollectionPublishUpdate(options) { clear_claims: true }; + if (isBackgroundUpdate && updateParams.claim_id) { + updateParams['claims'] = makeSelectClaimIdsForCollectionId(updateParams.claim_id)(state); + } else if (options.claims) { + updateParams['claims'] = options.claims; + } + if (options.tags) { updateParams['tags'] = options.tags.map(tag => tag.name); } - if (options.claims) { - updateParams['claims'] = options.claims; - } return new Promise(resolve => { dispatch({ type: COLLECTION_PUBLISH_UPDATE_STARTED diff --git a/src/redux/actions/claims.js b/src/redux/actions/claims.js index 5e50a2b..d53555f 100644 --- a/src/redux/actions/claims.js +++ b/src/redux/actions/claims.js @@ -19,7 +19,10 @@ import { creditsToString } from 'util/format-credits'; import { batchActions } from 'util/batch-actions'; import { createNormalizedClaimSearchKey } from 'util/claim'; import { PAGE_SIZE } from 'constants/claim'; -import { selectPendingCollections, makeSelectEditedCollectionForId } from 'redux/selectors/collections'; +import { + selectPendingCollections, + makeSelectClaimIdsForCollectionId, +} from 'redux/selectors/collections'; import { doFetchItemsInCollection, doFetchItemsInCollections, @@ -76,7 +79,7 @@ export function doResolveUris( const collectionIds: Array = []; return Lbry.resolve({ urls: urisToResolve, ...options }).then( - async(result: ResolveResponse) => { + async (result: ResolveResponse) => { let repostedResults = {}; const repostsToResolve = []; const fallbackResolveInfo = { @@ -648,7 +651,7 @@ export function doClaimSearch( } ) { const query = createNormalizedClaimSearchKey(options); - return async(dispatch: Dispatch) => { + return async (dispatch: Dispatch) => { dispatch({ type: ACTIONS.CLAIM_SEARCH_STARTED, data: { query: query }, @@ -828,17 +831,20 @@ export function doCollectionPublish( }; } -export function doCollectionPublishUpdate(options: { - bid?: string, - blocking?: true, - title?: string, - thumbnail_url?: string, - description?: string, - claim_id: string, - tags?: Array, - languages?: Array, - claims?: Array, -}, isBackgroundUpdate?: boolean) { +export function doCollectionPublishUpdate( + options: { + bid?: string, + blocking?: true, + title?: string, + thumbnail_url?: string, + description?: string, + claim_id: string, + tags?: Array, + languages?: Array, + claims?: Array, + }, + isBackgroundUpdate?: boolean +) { return (dispatch: Dispatch, getState: GetState): Promise => { // TODO: implement one click update const state = getState(); @@ -856,34 +862,33 @@ export function doCollectionPublishUpdate(options: { clear_claims: boolean, } = isBackgroundUpdate ? { - blocking: true, - claim_id: options.claim_id, - clear_claims: true, - } + blocking: true, + claim_id: options.claim_id, + clear_claims: true, + } : { - bid: creditsToString(options.bid), - title: options.title, - thumbnail_url: options.thumbnail_url, - description: options.description, - tags: [], - languages: options.languages || [], - locations: [], - blocking: true, - claim_id: options.claim_id, - clear_claims: true, - }; + bid: creditsToString(options.bid), + title: options.title, + thumbnail_url: options.thumbnail_url, + description: options.description, + tags: [], + languages: options.languages || [], + locations: [], + blocking: true, + claim_id: options.claim_id, + clear_claims: true, + }; if (isBackgroundUpdate && updateParams.claim_id) { - updateParams.claims = makeSelectEditedCollectionForId(updateParams.claim_id)(state); + updateParams['claims'] = makeSelectClaimIdsForCollectionId(updateParams.claim_id)(state); + } else if (options.claims) { + updateParams['claims'] = options.claims; } if (options.tags) { updateParams['tags'] = options.tags.map(tag => tag.name); } - if (options.claims) { - updateParams['claims'] = options.claims; - } return new Promise(resolve => { dispatch({ type: ACTIONS.COLLECTION_PUBLISH_UPDATE_STARTED, -- 2.45.2 From 34b20795e387957b073a5beeb8e8e1725598a178 Mon Sep 17 00:00:00 2001 From: zeppi Date: Sun, 22 Aug 2021 16:22:40 -0400 Subject: [PATCH 3/3] cleanup --- dist/bundle.es.js | 2 +- src/redux/actions/claims.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/dist/bundle.es.js b/dist/bundle.es.js index 33c7574..12358cb 100644 --- a/dist/bundle.es.js +++ b/dist/bundle.es.js @@ -4468,7 +4468,6 @@ function doCollectionPublish(options, localId) { function doCollectionPublishUpdate(options, isBackgroundUpdate) { return (dispatch, getState) => { // TODO: implement one click update - const state = getState(); const updateParams = isBackgroundUpdate ? { blocking: true, @@ -4488,6 +4487,7 @@ function doCollectionPublishUpdate(options, isBackgroundUpdate) { }; if (isBackgroundUpdate && updateParams.claim_id) { + const state = getState(); updateParams['claims'] = makeSelectClaimIdsForCollectionId(updateParams.claim_id)(state); } else if (options.claims) { updateParams['claims'] = options.claims; diff --git a/src/redux/actions/claims.js b/src/redux/actions/claims.js index d53555f..f5bf190 100644 --- a/src/redux/actions/claims.js +++ b/src/redux/actions/claims.js @@ -847,7 +847,6 @@ export function doCollectionPublishUpdate( ) { return (dispatch: Dispatch, getState: GetState): Promise => { // TODO: implement one click update - const state = getState(); const updateParams: { bid?: string, @@ -880,6 +879,7 @@ export function doCollectionPublishUpdate( }; if (isBackgroundUpdate && updateParams.claim_id) { + const state = getState(); updateParams['claims'] = makeSelectClaimIdsForCollectionId(updateParams.claim_id)(state); } else if (options.claims) { updateParams['claims'] = options.claims; -- 2.45.2