refactor fetch to fix pending

This commit is contained in:
zeppi 2021-05-25 08:59:56 -04:00 committed by jessopb
parent f8ff4cfc8f
commit 06ce8c623c
3 changed files with 214 additions and 156 deletions

179
dist/bundle.es.js vendored
View file

@ -4580,7 +4580,8 @@ const getTimestamp = () => {
return Math.floor(Date.now() / 1000); return Math.floor(Date.now() / 1000);
}; };
// maybe take items param const FETCH_BATCH_SIZE = 10;
const doLocalCollectionCreate = (name, collectionItems, type, sourceId) => dispatch => { const doLocalCollectionCreate = (name, collectionItems, type, sourceId) => dispatch => {
return dispatch({ return dispatch({
type: COLLECTION_NEW, type: COLLECTION_NEW,
@ -4633,11 +4634,26 @@ const doCollectionDelete = (id, colKey = undefined) => dispatch => {
const doFetchItemsInCollections = (resolveItemsOptions, resolveStartedCallback) => (() => { const doFetchItemsInCollections = (resolveItemsOptions, resolveStartedCallback) => (() => {
var _ref = _asyncToGenerator$2(function* (dispatch, getState) { var _ref = _asyncToGenerator$2(function* (dispatch, getState) {
let resolveCollectionItems = (() => { let fetchItemsForCollectionClaim = (() => {
var _ref2 = _asyncToGenerator$2(function* (claimId, totalItems, pageSize) { var _ref2 = _asyncToGenerator$2(function* (claim, pageSize) {
// take [ {}, {} ], return {} // take [ {}, {} ], return {}
// only need items [ Claim... ] and total_items // only need items [ url... ] and total_items
const mergeResults = function (arrayOfResults) { const totalItems = claim.value.claims && claim.value.claims.length;
const claimId = claim.claim_id;
const itemOrder = claim.value.claims;
const sortResults = function (results, claimList) {
const newResults = [];
claimList.forEach(function (id) {
const item = results.pop(function (i) {
return i.claim_id === id;
});
if (item) newResults.push(item);
});
return newResults;
};
const mergeBatches = function (arrayOfResults, claimList) {
const mergedResults = { const mergedResults = {
items: [], items: [],
total_items: 0 total_items: 0
@ -4646,35 +4662,42 @@ const doFetchItemsInCollections = (resolveItemsOptions, resolveStartedCallback)
mergedResults.items = mergedResults.items.concat(result.items); mergedResults.items = mergedResults.items.concat(result.items);
mergedResults.total_items = result.total_items; mergedResults.total_items = result.total_items;
}); });
mergedResults.items = sortResults(mergedResults.items, claimList);
return mergedResults; return mergedResults;
}; };
try { try {
const BATCH_SIZE = 10; // up batch size when sdk bug fixed // sdk had a strange bug that would only return so many, so this had to be batched.
// otherwise large lists of, ~500 channels for a homepage category failed
const batchSize = pageSize || FETCH_BATCH_SIZE;
const batches = []; const batches = [];
let fetchResult; /*
if (!pageSize) { // this was `collection_resolve` which returns claims for collection in order
// batch all // however, this fails when a claim is pending. :/
for (let i = 0; i < Math.ceil(totalItems / BATCH_SIZE); i++) { for (let i = 0; i < Math.ceil(totalItems / batchSize); i++) {
batches[i] = lbryProxy.collection_resolve({ batches[i] = Lbry.collection_resolve({
claim_id: claimId, claim_id: claimId,
page: i + 1, page: i + 1,
page_size: BATCH_SIZE page_size: batchSize,
}); });
} }
const resultArray = yield Promise.all(batches); */
fetchResult = mergeResults(resultArray);
} else { for (let i = 0; i < Math.ceil(totalItems / batchSize); i++) {
fetchResult = yield lbryProxy.collection_resolve({ batches[i] = lbryProxy.claim_search({
claim_id: claimId, claim_ids: claim.value.claims,
page: 1, page: i + 1,
page_size: pageSize page_size: batchSize
}); });
} }
const itemsInBatches = yield Promise.all(batches);
const result = mergeBatches(itemsInBatches, itemOrder);
// $FlowFixMe // $FlowFixMe
const itemsById = { claimId: claimId }; const itemsById = { claimId: claimId };
if (fetchResult.items) { if (result.items) {
itemsById.items = fetchResult.items; itemsById.items = result.items;
} else { } else {
itemsById.items = null; itemsById.items = null;
} }
@ -4687,15 +4710,19 @@ const doFetchItemsInCollections = (resolveItemsOptions, resolveStartedCallback)
} }
}); });
return function resolveCollectionItems(_x3, _x4, _x5) { return function fetchItemsForCollectionClaim(_x3, _x4) {
return _ref2.apply(this, arguments); return _ref2.apply(this, arguments);
}; };
})(); })();
/*
1) make sure all the collection claims are loaded into claims reducer, search/resolve if necessary.
2) get the item claims for each
3) format and make sure they're in the order as in the claim
4) Build the collection objects and update collections reducer
5) Update redux claims reducer
*/
let state = getState(); let state = getState();
// for each collection id,
// make sure the collection is resolved, the items are resolved, and build the collection objects
const { collectionIds, pageSize } = resolveItemsOptions; const { collectionIds, pageSize } = resolveItemsOptions;
dispatch({ dispatch({
@ -4708,33 +4735,15 @@ const doFetchItemsInCollections = (resolveItemsOptions, resolveStartedCallback)
const collectionIdsToSearch = collectionIds.filter(function (claimId) { const collectionIdsToSearch = collectionIds.filter(function (claimId) {
return !state.claims.byId[claimId]; return !state.claims.byId[claimId];
}); });
if (collectionIdsToSearch.length) { if (collectionIdsToSearch.length) {
let claimSearchOptions = { claim_ids: collectionIdsToSearch, page: 1, page_size: 9999 }; yield dispatch(doClaimSearch({ claim_ids: collectionIdsToSearch, page: 1, page_size: 9999 }));
yield dispatch(doClaimSearch(claimSearchOptions));
} }
const invalidCollectionIds = [];
const stateAfterClaimSearch = getState(); const stateAfterClaimSearch = getState();
const promises = []; function formatForClaimActions(resultClaimsByUri) {
collectionIds.forEach(function (collectionId) { const formattedClaims = {};
const claim = makeSelectClaimForClaimId(collectionId)(stateAfterClaimSearch);
if (!claim) {
invalidCollectionIds.push(collectionId);
} else {
const claimCount = claim.value.claims && claim.value.claims.length;
if (pageSize) {
promises.push(resolveCollectionItems(collectionId, claimCount, pageSize));
} else {
promises.push(resolveCollectionItems(collectionId, claimCount));
}
}
});
// $FlowFixMe
const resolvedCollectionItemsById = yield Promise.all(promises);
function processClaims(resultClaimsByUri) {
const processedClaims = {};
Object.entries(resultClaimsByUri).forEach(([uri, uriResolveInfo]) => { Object.entries(resultClaimsByUri).forEach(([uri, uriResolveInfo]) => {
// Flow has terrible Object.entries support // Flow has terrible Object.entries support
// https://github.com/facebook/flow/issues/2221 // https://github.com/facebook/flow/issues/2221
@ -4745,6 +4754,8 @@ const doFetchItemsInCollections = (resolveItemsOptions, resolveStartedCallback)
// $FlowFixMe // $FlowFixMe
result.claimsInChannel = uriResolveInfo.meta.claims_in_channel; result.claimsInChannel = uriResolveInfo.meta.claims_in_channel;
// ALSO SKIP COLLECTIONS // ALSO SKIP COLLECTIONS
} else if (uriResolveInfo.value_type === 'collection') {
result.collection = uriResolveInfo;
} else { } else {
result.stream = uriResolveInfo; result.stream = uriResolveInfo;
if (uriResolveInfo.signing_channel) { if (uriResolveInfo.signing_channel) {
@ -4753,15 +4764,29 @@ const doFetchItemsInCollections = (resolveItemsOptions, resolveStartedCallback)
} }
} }
// $FlowFixMe // $FlowFixMe
processedClaims[uri] = result; formattedClaims[uri] = result;
} }
}); });
return processedClaims; return formattedClaims;
} }
const newCollectionItemsById = {}; const invalidCollectionIds = [];
const flatResolvedCollectionItems = {}; const promisedCollectionItemFetches = [];
resolvedCollectionItemsById.forEach(function (entry) { collectionIds.forEach(function (collectionId) {
const claim = makeSelectClaimForClaimId(collectionId)(stateAfterClaimSearch);
if (!claim) {
invalidCollectionIds.push(collectionId);
} else {
promisedCollectionItemFetches.push(fetchItemsForCollectionClaim(claim, pageSize));
}
});
// $FlowFixMe
const collectionItemsById = yield Promise.all(promisedCollectionItemFetches);
const newCollectionObjectsById = {};
const resolvedItemsByUrl = {};
collectionItemsById.forEach(function (entry) {
// $FlowFixMe // $FlowFixMe
const collectionItems = entry.items; const collectionItems = entry.items;
const collectionId = entry.claimId; const collectionId = entry.claimId;
@ -4774,27 +4799,31 @@ const doFetchItemsInCollections = (resolveItemsOptions, resolveStartedCallback)
const valueTypes = new Set(); const valueTypes = new Set();
const streamTypes = new Set(); const streamTypes = new Set();
let items = []; let newItems = [];
collectionItems.forEach(function (collectionItem) { let isPlaylist;
// here's where we would just items.push(collectionItem.permanent_url
items.push(collectionItem.permanent_url);
valueTypes.add(collectionItem.value_type);
if (collectionItem.value.stream_type) {
streamTypes.add(collectionItem.value.stream_type);
}
flatResolvedCollectionItems[collectionItem.canonical_url] = collectionItem;
});
const isPlaylist = valueTypes.size === 1 && valueTypes.has('stream') && (streamTypes.size === 1 && (streamTypes.has('audio') || streamTypes.has('video')) || streamTypes.size === 2 && streamTypes.has('audio') && streamTypes.has('video'));
newCollectionItemsById[collectionId] = { if (collectionItems) {
items, collectionItems.forEach(function (collectionItem) {
// here's where we would just items.push(collectionItem.permanent_url
newItems.push(collectionItem.permanent_url);
valueTypes.add(collectionItem.value_type);
if (collectionItem.value.stream_type) {
streamTypes.add(collectionItem.value.stream_type);
}
resolvedItemsByUrl[collectionItem.canonical_url] = collectionItem;
});
isPlaylist = valueTypes.size === 1 && valueTypes.has('stream') && (streamTypes.size === 1 && (streamTypes.has('audio') || streamTypes.has('video')) || streamTypes.size === 2 && streamTypes.has('audio') && streamTypes.has('video'));
}
newCollectionObjectsById[collectionId] = {
items: newItems,
id: collectionId, id: collectionId,
name: title || name, name: title || name,
itemCount: claim.value.claims.length, itemCount: claim.value.claims.length,
type: isPlaylist ? 'playlist' : 'collection', type: isPlaylist ? 'playlist' : 'collection',
updatedAt: timestamp updatedAt: timestamp
}; };
// clear any stale edits
if (editedCollection && timestamp > editedCollection['updatedAt']) { if (editedCollection && timestamp > editedCollection['updatedAt']) {
dispatch({ dispatch({
type: COLLECTION_DELETE, type: COLLECTION_DELETE,
@ -4804,19 +4833,21 @@ const doFetchItemsInCollections = (resolveItemsOptions, resolveStartedCallback)
} }
}); });
} }
} else {
invalidCollectionIds.push(collectionId);
} }
}); });
const processedClaimsByUri = processClaims(flatResolvedCollectionItems); const formattedClaimsByUri = formatForClaimActions(collectionItemsById);
dispatch({ dispatch({
type: RESOLVE_URIS_COMPLETED, type: RESOLVE_URIS_COMPLETED,
data: { resolveInfo: processedClaimsByUri } data: { resolveInfo: formattedClaimsByUri }
}); });
dispatch({ dispatch({
type: COLLECTION_ITEMS_RESOLVE_COMPLETED, type: COLLECTION_ITEMS_RESOLVE_COMPLETED,
data: { data: {
resolvedCollections: newCollectionItemsById, resolvedCollections: newCollectionObjectsById,
failedCollectionIds: invalidCollectionIds failedCollectionIds: invalidCollectionIds
} }
}); });
@ -4924,10 +4955,8 @@ const doCollectionEdit = (collectionId, params) => (() => {
// console.log('p&e', publishedCollection.items, newItems, publishedCollection.items.join(','), newItems.join(',')) // console.log('p&e', publishedCollection.items, newItems, publishedCollection.items.join(','), newItems.join(','))
if (editedCollection) { if (editedCollection) {
// delete edited if newItems are the same as publishedItems
if (publishedCollection.items.join(',') === newItems.join(',')) { if (publishedCollection.items.join(',') === newItems.join(',')) {
// print these
// delete edited if newItems are the same as publishedItems
dispatch({ dispatch({
type: COLLECTION_DELETE, type: COLLECTION_DELETE,
data: { data: {
@ -5000,7 +5029,7 @@ const doCollectionEdit = (collectionId, params) => (() => {
return true; return true;
}); });
return function (_x6, _x7) { return function (_x5, _x6) {
return _ref3.apply(this, arguments); return _ref3.apply(this, arguments);
}; };
})(); })();
@ -7597,7 +7626,7 @@ const collectionsReducer = handleActions({
const newUnpublishedList = Object.assign({}, unpublishedList); const newUnpublishedList = Object.assign({}, unpublishedList);
const newPendingList = Object.assign({}, pendingList); const newPendingList = Object.assign({}, pendingList);
const isEdit = editList[localId]; const isEdit = editList[localId || claimId];
if (localId) { if (localId) {
// pending from unpublished -> published // pending from unpublished -> published
// delete from local // delete from local

View file

@ -18,7 +18,8 @@ const getTimestamp = () => {
return Math.floor(Date.now() / 1000); return Math.floor(Date.now() / 1000);
}; };
// maybe take items param const FETCH_BATCH_SIZE = 10;
export const doLocalCollectionCreate = ( export const doLocalCollectionCreate = (
name: string, name: string,
collectionItems: Array<string>, collectionItems: Array<string>,
@ -83,10 +84,14 @@ export const doFetchItemsInCollections = (
}, },
resolveStartedCallback?: () => void resolveStartedCallback?: () => void
) => async(dispatch: Dispatch, getState: GetState) => { ) => async(dispatch: Dispatch, getState: GetState) => {
/*
1) make sure all the collection claims are loaded into claims reducer, search/resolve if necessary.
2) get the item claims for each
3) format and make sure they're in the order as in the claim
4) Build the collection objects and update collections reducer
5) Update redux claims reducer
*/
let state = getState(); let state = getState();
// for each collection id,
// make sure the collection is resolved, the items are resolved, and build the collection objects
const { collectionIds, pageSize } = resolveItemsOptions; const { collectionIds, pageSize } = resolveItemsOptions;
dispatch({ dispatch({
@ -97,18 +102,35 @@ export const doFetchItemsInCollections = (
if (resolveStartedCallback) resolveStartedCallback(); if (resolveStartedCallback) resolveStartedCallback();
const collectionIdsToSearch = collectionIds.filter(claimId => !state.claims.byId[claimId]); const collectionIdsToSearch = collectionIds.filter(claimId => !state.claims.byId[claimId]);
if (collectionIdsToSearch.length) { if (collectionIdsToSearch.length) {
let claimSearchOptions = { claim_ids: collectionIdsToSearch, page: 1, page_size: 9999 }; await dispatch(doClaimSearch({ claim_ids: collectionIdsToSearch, page: 1, page_size: 9999 }));
await dispatch(doClaimSearch(claimSearchOptions));
} }
const invalidCollectionIds = [];
const stateAfterClaimSearch = getState(); const stateAfterClaimSearch = getState();
async function resolveCollectionItems(claimId, totalItems, pageSize) { async function fetchItemsForCollectionClaim(claim: CollectionClaim, pageSize?: number) {
// take [ {}, {} ], return {} // take [ {}, {} ], return {}
// only need items [ Claim... ] and total_items // only need items [ url... ] and total_items
const mergeResults = (arrayOfResults: Array<{ items: any, total_items: number }>) => { const totalItems = claim.value.claims && claim.value.claims.length;
const mergedResults: { items: Array<?Claim>, total_items: number } = { const claimId = claim.claim_id;
const itemOrder = claim.value.claims;
const sortResults = (results: Array<Claim>, claimList) => {
const newResults: Array<Claim> = [];
claimList.forEach(id => {
const index = results.findIndex(i => i.claim_id === id);
const item = results.splice(index, 1);
if (item) newResults.push(item[0]);
});
return newResults;
};
const mergeBatches = (
arrayOfResults: Array<{ items: Array<Claim>, total_items: number }>,
claimList: Array<string>
) => {
const mergedResults: { items: Array<Claim>, total_items: number } = {
items: [], items: [],
total_items: 0, total_items: 0,
}; };
@ -116,35 +138,42 @@ export const doFetchItemsInCollections = (
mergedResults.items = mergedResults.items.concat(result.items); mergedResults.items = mergedResults.items.concat(result.items);
mergedResults.total_items = result.total_items; mergedResults.total_items = result.total_items;
}); });
mergedResults.items = sortResults(mergedResults.items, claimList);
return mergedResults; return mergedResults;
}; };
try { try {
const BATCH_SIZE = 10; // up batch size when sdk bug fixed // sdk had a strange bug that would only return so many, so this had to be batched.
const batches = []; // otherwise large lists of, ~500 channels for a homepage category failed
let fetchResult; const batchSize = pageSize || FETCH_BATCH_SIZE;
if (!pageSize) { const batches: Array<Promise<any>> = [];
// batch all /*
for (let i = 0; i < Math.ceil(totalItems / BATCH_SIZE); i++) { // this was `collection_resolve` which returns claims for collection in order
// however, this fails when a claim is pending. :/
for (let i = 0; i < Math.ceil(totalItems / batchSize); i++) {
batches[i] = Lbry.collection_resolve({ batches[i] = Lbry.collection_resolve({
claim_id: claimId, claim_id: claimId,
page: i + 1, page: i + 1,
page_size: BATCH_SIZE, page_size: batchSize,
}); });
} }
const resultArray = await Promise.all(batches); */
fetchResult = mergeResults(resultArray);
} else { for (let i = 0; i < Math.ceil(totalItems / batchSize); i++) {
fetchResult = await Lbry.collection_resolve({ batches[i] = Lbry.claim_search({
claim_id: claimId, claim_ids: claim.value.claims,
page: 1, page: i + 1,
page_size: pageSize, page_size: batchSize,
}); });
} }
const itemsInBatches = await Promise.all(batches);
const result = mergeBatches(itemsInBatches, itemOrder);
// $FlowFixMe // $FlowFixMe
const itemsById: { claimId: string, items?: ?Array<GenericClaim> } = { claimId: claimId }; const itemsById: { claimId: string, items?: ?Array<GenericClaim> } = { claimId: claimId };
if (fetchResult.items) { if (result.items) {
itemsById.items = fetchResult.items; itemsById.items = result.items;
} else { } else {
itemsById.items = null; itemsById.items = null;
} }
@ -157,29 +186,8 @@ export const doFetchItemsInCollections = (
} }
} }
const promises = []; function formatForClaimActions(resultClaimsByUri) {
collectionIds.forEach(collectionId => { const formattedClaims = {};
const claim = makeSelectClaimForClaimId(collectionId)(stateAfterClaimSearch);
if (!claim) {
invalidCollectionIds.push(collectionId);
} else {
const claimCount = claim.value.claims && claim.value.claims.length;
if (pageSize) {
promises.push(resolveCollectionItems(collectionId, claimCount, pageSize));
} else {
promises.push(resolveCollectionItems(collectionId, claimCount));
}
}
});
// $FlowFixMe
const resolvedCollectionItemsById: Array<{
claimId: string,
items: ?Array<GenericClaim>,
}> = await Promise.all(promises);
function processClaims(resultClaimsByUri) {
const processedClaims = {};
Object.entries(resultClaimsByUri).forEach(([uri, uriResolveInfo]) => { Object.entries(resultClaimsByUri).forEach(([uri, uriResolveInfo]) => {
// Flow has terrible Object.entries support // Flow has terrible Object.entries support
// https://github.com/facebook/flow/issues/2221 // https://github.com/facebook/flow/issues/2221
@ -190,6 +198,8 @@ export const doFetchItemsInCollections = (
// $FlowFixMe // $FlowFixMe
result.claimsInChannel = uriResolveInfo.meta.claims_in_channel; result.claimsInChannel = uriResolveInfo.meta.claims_in_channel;
// ALSO SKIP COLLECTIONS // ALSO SKIP COLLECTIONS
} else if (uriResolveInfo.value_type === 'collection') {
result.collection = uriResolveInfo;
} else { } else {
result.stream = uriResolveInfo; result.stream = uriResolveInfo;
if (uriResolveInfo.signing_channel) { if (uriResolveInfo.signing_channel) {
@ -201,15 +211,32 @@ export const doFetchItemsInCollections = (
} }
} }
// $FlowFixMe // $FlowFixMe
processedClaims[uri] = result; formattedClaims[uri] = result;
} }
}); });
return processedClaims; return formattedClaims;
} }
const newCollectionItemsById = {}; const invalidCollectionIds = [];
const flatResolvedCollectionItems = {}; const promisedCollectionItemFetches = [];
resolvedCollectionItemsById.forEach(entry => { collectionIds.forEach(collectionId => {
const claim = makeSelectClaimForClaimId(collectionId)(stateAfterClaimSearch);
if (!claim) {
invalidCollectionIds.push(collectionId);
} else {
promisedCollectionItemFetches.push(fetchItemsForCollectionClaim(claim, pageSize));
}
});
// $FlowFixMe
const collectionItemsById: Array<{
claimId: string,
items: ?Array<GenericClaim>,
}> = await Promise.all(promisedCollectionItemFetches);
const newCollectionObjectsById = {};
const resolvedItemsByUrl = {};
collectionItemsById.forEach(entry => {
// $FlowFixMe // $FlowFixMe
const collectionItems: Array<any> = entry.items; const collectionItems: Array<any> = entry.items;
const collectionId = entry.claimId; const collectionId = entry.claimId;
@ -222,31 +249,35 @@ export const doFetchItemsInCollections = (
const valueTypes = new Set(); const valueTypes = new Set();
const streamTypes = new Set(); const streamTypes = new Set();
let items = []; let newItems = [];
collectionItems.forEach(collectionItem => { let isPlaylist;
// here's where we would just items.push(collectionItem.permanent_url
items.push(collectionItem.permanent_url);
valueTypes.add(collectionItem.value_type);
if (collectionItem.value.stream_type) {
streamTypes.add(collectionItem.value.stream_type);
}
flatResolvedCollectionItems[collectionItem.canonical_url] = collectionItem;
});
const isPlaylist =
valueTypes.size === 1 &&
valueTypes.has('stream') &&
((streamTypes.size === 1 && (streamTypes.has('audio') || streamTypes.has('video'))) ||
(streamTypes.size === 2 && (streamTypes.has('audio') && streamTypes.has('video'))));
newCollectionItemsById[collectionId] = { if (collectionItems) {
items, collectionItems.forEach(collectionItem => {
// here's where we would just items.push(collectionItem.permanent_url
newItems.push(collectionItem.permanent_url);
valueTypes.add(collectionItem.value_type);
if (collectionItem.value.stream_type) {
streamTypes.add(collectionItem.value.stream_type);
}
resolvedItemsByUrl[collectionItem.canonical_url] = collectionItem;
});
isPlaylist =
valueTypes.size === 1 &&
valueTypes.has('stream') &&
((streamTypes.size === 1 && (streamTypes.has('audio') || streamTypes.has('video'))) ||
(streamTypes.size === 2 && (streamTypes.has('audio') && streamTypes.has('video'))));
}
newCollectionObjectsById[collectionId] = {
items: newItems,
id: collectionId, id: collectionId,
name: title || name, name: title || name,
itemCount: claim.value.claims.length, itemCount: claim.value.claims.length,
type: isPlaylist ? 'playlist' : 'collection', type: isPlaylist ? 'playlist' : 'collection',
updatedAt: timestamp, updatedAt: timestamp,
}; };
// clear any stale edits
if (editedCollection && timestamp > editedCollection['updatedAt']) { if (editedCollection && timestamp > editedCollection['updatedAt']) {
dispatch({ dispatch({
type: ACTIONS.COLLECTION_DELETE, type: ACTIONS.COLLECTION_DELETE,
@ -257,20 +288,20 @@ export const doFetchItemsInCollections = (
}); });
} }
} else { } else {
// no collection items? probably in pending. invalidCollectionIds.push(collectionId);
} }
}); });
const processedClaimsByUri = processClaims(flatResolvedCollectionItems); const formattedClaimsByUri = formatForClaimActions(collectionItemsById);
dispatch({ dispatch({
type: ACTIONS.RESOLVE_URIS_COMPLETED, type: ACTIONS.RESOLVE_URIS_COMPLETED,
data: { resolveInfo: processedClaimsByUri }, data: { resolveInfo: formattedClaimsByUri },
}); });
dispatch({ dispatch({
type: ACTIONS.COLLECTION_ITEMS_RESOLVE_COMPLETED, type: ACTIONS.COLLECTION_ITEMS_RESOLVE_COMPLETED,
data: { data: {
resolvedCollections: newCollectionItemsById, resolvedCollections: newCollectionObjectsById,
failedCollectionIds: invalidCollectionIds, failedCollectionIds: invalidCollectionIds,
}, },
}); });
@ -389,10 +420,8 @@ export const doCollectionEdit = (collectionId: string, params: CollectionEditPar
// console.log('p&e', publishedCollection.items, newItems, publishedCollection.items.join(','), newItems.join(',')) // console.log('p&e', publishedCollection.items, newItems, publishedCollection.items.join(','), newItems.join(','))
if (editedCollection) { if (editedCollection) {
// delete edited if newItems are the same as publishedItems
if (publishedCollection.items.join(',') === newItems.join(',')) { if (publishedCollection.items.join(',') === newItems.join(',')) {
// print these
// delete edited if newItems are the same as publishedItems
dispatch({ dispatch({
type: ACTIONS.COLLECTION_DELETE, type: ACTIONS.COLLECTION_DELETE,
data: { data: {

View file

@ -99,7 +99,7 @@ const collectionsReducer = handleActions(
const newUnpublishedList = Object.assign({}, unpublishedList); const newUnpublishedList = Object.assign({}, unpublishedList);
const newPendingList = Object.assign({}, pendingList); const newPendingList = Object.assign({}, pendingList);
const isEdit = editList[localId]; const isEdit = editList[localId || claimId];
if (localId) { if (localId) {
// pending from unpublished -> published // pending from unpublished -> published
// delete from local // delete from local