fix background collection update
This commit is contained in:
parent
e83153804d
commit
d45317807e
2 changed files with 52 additions and 39 deletions
20
dist/bundle.es.js
vendored
20
dist/bundle.es.js
vendored
|
@ -4465,11 +4465,16 @@ function doCollectionPublish(options, localId) {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
function doCollectionPublishUpdate(options) {
|
function doCollectionPublishUpdate(options, isBackgroundUpdate) {
|
||||||
return dispatch => {
|
return (dispatch, getState) => {
|
||||||
// TODO: implement one click update
|
// 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),
|
bid: creditsToString(options.bid),
|
||||||
title: options.title,
|
title: options.title,
|
||||||
thumbnail_url: options.thumbnail_url,
|
thumbnail_url: options.thumbnail_url,
|
||||||
|
@ -4482,13 +4487,16 @@ function doCollectionPublishUpdate(options) {
|
||||||
clear_claims: true
|
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) {
|
if (options.tags) {
|
||||||
updateParams['tags'] = options.tags.map(tag => tag.name);
|
updateParams['tags'] = options.tags.map(tag => tag.name);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (options.claims) {
|
|
||||||
updateParams['claims'] = options.claims;
|
|
||||||
}
|
|
||||||
return new Promise(resolve => {
|
return new Promise(resolve => {
|
||||||
dispatch({
|
dispatch({
|
||||||
type: COLLECTION_PUBLISH_UPDATE_STARTED
|
type: COLLECTION_PUBLISH_UPDATE_STARTED
|
||||||
|
|
|
@ -19,7 +19,10 @@ import { creditsToString } from 'util/format-credits';
|
||||||
import { batchActions } from 'util/batch-actions';
|
import { batchActions } from 'util/batch-actions';
|
||||||
import { createNormalizedClaimSearchKey } from 'util/claim';
|
import { createNormalizedClaimSearchKey } from 'util/claim';
|
||||||
import { PAGE_SIZE } from 'constants/claim';
|
import { PAGE_SIZE } from 'constants/claim';
|
||||||
import { selectPendingCollections, makeSelectEditedCollectionForId } from 'redux/selectors/collections';
|
import {
|
||||||
|
selectPendingCollections,
|
||||||
|
makeSelectClaimIdsForCollectionId,
|
||||||
|
} from 'redux/selectors/collections';
|
||||||
import {
|
import {
|
||||||
doFetchItemsInCollection,
|
doFetchItemsInCollection,
|
||||||
doFetchItemsInCollections,
|
doFetchItemsInCollections,
|
||||||
|
@ -828,7 +831,8 @@ export function doCollectionPublish(
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
export function doCollectionPublishUpdate(options: {
|
export function doCollectionPublishUpdate(
|
||||||
|
options: {
|
||||||
bid?: string,
|
bid?: string,
|
||||||
blocking?: true,
|
blocking?: true,
|
||||||
title?: string,
|
title?: string,
|
||||||
|
@ -838,7 +842,9 @@ export function doCollectionPublishUpdate(options: {
|
||||||
tags?: Array<Tag>,
|
tags?: Array<Tag>,
|
||||||
languages?: Array<string>,
|
languages?: Array<string>,
|
||||||
claims?: Array<string>,
|
claims?: Array<string>,
|
||||||
}, isBackgroundUpdate?: boolean) {
|
},
|
||||||
|
isBackgroundUpdate?: boolean
|
||||||
|
) {
|
||||||
return (dispatch: Dispatch, getState: GetState): Promise<any> => {
|
return (dispatch: Dispatch, getState: GetState): Promise<any> => {
|
||||||
// TODO: implement one click update
|
// TODO: implement one click update
|
||||||
const state = getState();
|
const state = getState();
|
||||||
|
@ -874,16 +880,15 @@ export function doCollectionPublishUpdate(options: {
|
||||||
};
|
};
|
||||||
|
|
||||||
if (isBackgroundUpdate && updateParams.claim_id) {
|
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) {
|
if (options.tags) {
|
||||||
updateParams['tags'] = options.tags.map(tag => tag.name);
|
updateParams['tags'] = options.tags.map(tag => tag.name);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (options.claims) {
|
|
||||||
updateParams['claims'] = options.claims;
|
|
||||||
}
|
|
||||||
return new Promise(resolve => {
|
return new Promise(resolve => {
|
||||||
dispatch({
|
dispatch({
|
||||||
type: ACTIONS.COLLECTION_PUBLISH_UPDATE_STARTED,
|
type: ACTIONS.COLLECTION_PUBLISH_UPDATE_STARTED,
|
||||||
|
|
Loading…
Reference in a new issue