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