Collections #383

Merged
jessopb merged 20 commits from collections into master 2021-06-08 17:51:49 +02:00
3 changed files with 214 additions and 156 deletions
Showing only changes of commit d2d9b037f0 - Show all commits

165
dist/bundle.es.js vendored
View file

@ -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

View file

@ -18,7 +18,8 @@ const getTimestamp = () => {
jessopb commented 2021-02-17 17:16:08 +01:00 (Migrated from github.com)
Review

Array/< { claimId: string, items: ?Array } >

Array/< { claimId: string, items: ?Array<GenericClaim> } >
jessopb commented 2021-02-17 17:16:08 +01:00 (Migrated from github.com)
Review

Array/< { claimId: string, items: ?Array } >

Array/< { claimId: string, items: ?Array<GenericClaim> } >
return Math.floor(Date.now() / 1000);
};
// maybe take items param
jessopb commented 2021-02-17 17:16:08 +01:00 (Migrated from github.com)
Review

Array/< { claimId: string, items: ?Array } >

Array/< { claimId: string, items: ?Array<GenericClaim> } >
const FETCH_BATCH_SIZE = 10;
jessopb commented 2021-02-17 17:16:08 +01:00 (Migrated from github.com)
Review

Array/< { claimId: string, items: ?Array } >

Array/< { claimId: string, items: ?Array<GenericClaim> } >
jessopb commented 2021-02-17 17:16:08 +01:00 (Migrated from github.com)
Review

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 = (
jessopb commented 2021-02-17 17:16:08 +01:00 (Migrated from github.com)
Review

Array/< { claimId: string, items: ?Array } >

Array/< { claimId: string, items: ?Array<GenericClaim> } >
jessopb commented 2021-02-17 17:16:08 +01:00 (Migrated from github.com)
Review

Array/< { claimId: string, items: ?Array } >

Array/< { claimId: string, items: ?Array<GenericClaim> } >
},
resolveStartedCallback?: () => void
) => async(dispatch: Dispatch, getState: GetState) => {
/*
jessopb commented 2021-02-17 17:16:08 +01:00 (Migrated from github.com)
Review

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.
jessopb commented 2021-02-17 17:16:08 +01:00 (Migrated from github.com)
Review

Array/< { claimId: string, items: ?Array } >

Array/< { claimId: string, items: ?Array<GenericClaim> } >
2) get the item claims for each
jessopb commented 2021-02-17 17:16:08 +01:00 (Migrated from github.com)
Review

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
jessopb commented 2021-02-17 17:16:08 +01:00 (Migrated from github.com)
Review

Array/< { claimId: string, items: ?Array } >

Array/< { claimId: string, items: ?Array<GenericClaim> } >
4) Build the collection objects and update collections reducer
jessopb commented 2021-02-17 17:16:08 +01:00 (Migrated from github.com)
Review

Array/< { claimId: string, items: ?Array } >

Array/< { claimId: string, items: ?Array<GenericClaim> } >
5) Update redux claims reducer
jessopb commented 2021-02-17 17:16:08 +01:00 (Migrated from github.com)
Review

Array/< { claimId: string, items: ?Array } >

Array/< { claimId: string, items: ?Array<GenericClaim> } >
*/
jessopb commented 2021-02-17 17:16:08 +01:00 (Migrated from github.com)
Review

Array/< { claimId: string, items: ?Array } >

Array/< { claimId: string, items: ?Array<GenericClaim> } >
let state = getState();
// for each collection id,
jessopb commented 2021-02-17 17:16:08 +01:00 (Migrated from github.com)
Review

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
jessopb commented 2021-02-17 17:16:08 +01:00 (Migrated from github.com)
Review

Array/< { claimId: string, items: ?Array } >

Array/< { claimId: string, items: ?Array<GenericClaim> } >
jessopb commented 2021-02-17 17:16:08 +01:00 (Migrated from github.com)
Review

Array/< { claimId: string, items: ?Array } >

Array/< { claimId: string, items: ?Array<GenericClaim> } >
const { collectionIds, pageSize } = resolveItemsOptions;
dispatch({
@ -97,18 +102,35 @@ export const doFetchItemsInCollections = (
jessopb commented 2021-02-17 17:16:08 +01:00 (Migrated from github.com)
Review

Array/< { claimId: string, items: ?Array } >

Array/< { claimId: string, items: ?Array<GenericClaim> } >
jessopb commented 2021-02-17 17:16:08 +01:00 (Migrated from github.com)
Review

Array/< { claimId: string, items: ?Array } >

Array/< { claimId: string, items: ?Array<GenericClaim> } >
if (resolveStartedCallback) resolveStartedCallback();
const collectionIdsToSearch = collectionIds.filter(claimId => !state.claims.byId[claimId]);
jessopb commented 2021-02-17 17:16:08 +01:00 (Migrated from github.com)
Review

Array/< { claimId: string, items: ?Array } >

Array/< { claimId: string, items: ?Array<GenericClaim> } >
if (collectionIdsToSearch.length) {
let claimSearchOptions = { claim_ids: collectionIdsToSearch, page: 1, page_size: 9999 };
jessopb commented 2021-02-17 17:16:08 +01:00 (Migrated from github.com)
Review

Array/< { claimId: string, items: ?Array } >

Array/< { claimId: string, items: ?Array<GenericClaim> } >
await dispatch(doClaimSearch(claimSearchOptions));
jessopb commented 2021-02-17 17:16:08 +01:00 (Migrated from github.com)
Review

Array/< { claimId: string, items: ?Array } >

Array/< { claimId: string, items: ?Array<GenericClaim> } >
await dispatch(doClaimSearch({ claim_ids: collectionIdsToSearch, page: 1, page_size: 9999 }));
jessopb commented 2021-02-17 17:16:08 +01:00 (Migrated from github.com)
Review

Array/< { claimId: string, items: ?Array } >

Array/< { claimId: string, items: ?Array<GenericClaim> } >
}
const invalidCollectionIds = [];
jessopb commented 2021-02-17 17:16:08 +01:00 (Migrated from github.com)
Review

Array/< { claimId: string, items: ?Array } >

Array/< { claimId: string, items: ?Array<GenericClaim> } >
jessopb commented 2021-02-17 17:16:08 +01:00 (Migrated from github.com)
Review

Array/< { claimId: string, items: ?Array } >

Array/< { claimId: string, items: ?Array<GenericClaim> } >
const stateAfterClaimSearch = getState();
async function resolveCollectionItems(claimId, totalItems, pageSize) {
jessopb commented 2021-02-17 17:16:08 +01:00 (Migrated from github.com)
Review

Array/< { claimId: string, items: ?Array } >

Array/< { claimId: string, items: ?Array<GenericClaim> } >
async function fetchItemsForCollectionClaim(claim: CollectionClaim, pageSize?: number) {
jessopb commented 2021-02-17 17:16:08 +01:00 (Migrated from github.com)
Review

Array/< { claimId: string, items: ?Array } >

Array/< { claimId: string, items: ?Array<GenericClaim> } >
// take [ {}, {} ], return {}
// only need items [ Claim... ] and total_items
jessopb commented 2021-02-17 17:16:08 +01:00 (Migrated from github.com)
Review

Array/< { claimId: string, items: ?Array } >

Array/< { claimId: string, items: ?Array<GenericClaim> } >
const mergeResults = (arrayOfResults: Array<{ items: any, total_items: number }>) => {
jessopb commented 2021-02-17 17:16:08 +01:00 (Migrated from github.com)
Review

Array/< { claimId: string, items: ?Array } >

Array/< { claimId: string, items: ?Array<GenericClaim> } >
const mergedResults: { items: Array<?Claim>, total_items: number } = {
jessopb commented 2021-02-17 17:16:08 +01:00 (Migrated from github.com)
Review

Array/< { claimId: string, items: ?Array } >

Array/< { claimId: string, items: ?Array<GenericClaim> } >
// only need items [ url... ] and total_items
jessopb commented 2021-02-17 17:16:08 +01:00 (Migrated from github.com)
Review

Array/< { claimId: string, items: ?Array } >

Array/< { claimId: string, items: ?Array<GenericClaim> } >
const totalItems = claim.value.claims && claim.value.claims.length;
jessopb commented 2021-02-17 17:16:08 +01:00 (Migrated from github.com)
Review

Array/< { claimId: string, items: ?Array } >

Array/< { claimId: string, items: ?Array<GenericClaim> } >
const claimId = claim.claim_id;
jessopb commented 2021-02-17 17:16:08 +01:00 (Migrated from github.com)
Review

Array/< { claimId: string, items: ?Array } >

Array/< { claimId: string, items: ?Array<GenericClaim> } >
const itemOrder = claim.value.claims;
jessopb commented 2021-02-17 17:16:08 +01:00 (Migrated from github.com)
Review

Array/< { claimId: string, items: ?Array } >

Array/< { claimId: string, items: ?Array<GenericClaim> } >
jessopb commented 2021-02-17 17:16:08 +01:00 (Migrated from github.com)
Review

Array/< { claimId: string, items: ?Array } >

Array/< { claimId: string, items: ?Array<GenericClaim> } >
const sortResults = (results: Array<Claim>, claimList) => {
jessopb commented 2021-02-17 17:16:08 +01:00 (Migrated from github.com)
Review

Array/< { claimId: string, items: ?Array } >

Array/< { claimId: string, items: ?Array<GenericClaim> } >
const newResults: Array<Claim> = [];
jessopb commented 2021-02-17 17:16:08 +01:00 (Migrated from github.com)
Review

Array/< { claimId: string, items: ?Array } >

Array/< { claimId: string, items: ?Array<GenericClaim> } >
claimList.forEach(id => {
jessopb commented 2021-02-17 17:16:08 +01:00 (Migrated from github.com)
Review

Array/< { claimId: string, items: ?Array } >

Array/< { claimId: string, items: ?Array<GenericClaim> } >
const index = results.findIndex(i => i.claim_id === id);
jessopb commented 2021-02-17 17:16:08 +01:00 (Migrated from github.com)
Review

Array/< { claimId: string, items: ?Array } >

Array/< { claimId: string, items: ?Array<GenericClaim> } >
const item = results.splice(index, 1);
jessopb commented 2021-02-17 17:16:08 +01:00 (Migrated from github.com)
Review

Array/< { claimId: string, items: ?Array } >

Array/< { claimId: string, items: ?Array<GenericClaim> } >
if (item) newResults.push(item[0]);
jessopb commented 2021-02-17 17:16:08 +01:00 (Migrated from github.com)
Review

Array/< { claimId: string, items: ?Array } >

Array/< { claimId: string, items: ?Array<GenericClaim> } >
});
jessopb commented 2021-02-17 17:16:08 +01:00 (Migrated from github.com)
Review

Array/< { claimId: string, items: ?Array } >

Array/< { claimId: string, items: ?Array<GenericClaim> } >
return newResults;
jessopb commented 2021-02-17 17:16:08 +01:00 (Migrated from github.com)
Review

Array/< { claimId: string, items: ?Array } >

Array/< { claimId: string, items: ?Array<GenericClaim> } >
};
jessopb commented 2021-02-17 17:16:08 +01:00 (Migrated from github.com)
Review

Array/< { claimId: string, items: ?Array } >

Array/< { claimId: string, items: ?Array<GenericClaim> } >
jessopb commented 2021-02-17 17:16:08 +01:00 (Migrated from github.com)
Review

Array/< { claimId: string, items: ?Array } >

Array/< { claimId: string, items: ?Array<GenericClaim> } >
const mergeBatches = (
jessopb commented 2021-02-17 17:16:08 +01:00 (Migrated from github.com)
Review

Array/< { claimId: string, items: ?Array } >

Array/< { claimId: string, items: ?Array<GenericClaim> } >
arrayOfResults: Array<{ items: Array<Claim>, total_items: number }>,
jessopb commented 2021-02-17 17:16:08 +01:00 (Migrated from github.com)
Review

Array/< { claimId: string, items: ?Array } >

Array/< { claimId: string, items: ?Array<GenericClaim> } >
claimList: Array<string>
jessopb commented 2021-02-17 17:16:08 +01:00 (Migrated from github.com)
Review

Array/< { claimId: string, items: ?Array } >

Array/< { claimId: string, items: ?Array<GenericClaim> } >
) => {
jessopb commented 2021-02-17 17:16:08 +01:00 (Migrated from github.com)
Review

Array/< { claimId: string, items: ?Array } >

Array/< { claimId: string, items: ?Array<GenericClaim> } >
const mergedResults: { items: Array<Claim>, total_items: number } = {
jessopb commented 2021-02-17 17:16:08 +01:00 (Migrated from github.com)
Review

Array/< { claimId: string, items: ?Array } >

Array/< { claimId: string, items: ?Array<GenericClaim> } >
items: [],
total_items: 0,
};
@ -116,35 +138,42 @@ export const doFetchItemsInCollections = (
jessopb commented 2021-02-17 17:16:08 +01:00 (Migrated from github.com)
Review

Array/< { claimId: string, items: ?Array } >

Array/< { claimId: string, items: ?Array<GenericClaim> } >
jessopb commented 2021-02-17 17:16:08 +01:00 (Migrated from github.com)
Review

Array/< { claimId: string, items: ?Array } >

Array/< { claimId: string, items: ?Array<GenericClaim> } >
mergedResults.items = mergedResults.items.concat(result.items);
mergedResults.total_items = result.total_items;
});
jessopb commented 2021-02-17 17:16:08 +01:00 (Migrated from github.com)
Review

Array/< { claimId: string, items: ?Array } >

Array/< { claimId: string, items: ?Array<GenericClaim> } >
mergedResults.items = sortResults(mergedResults.items, claimList);
jessopb commented 2021-02-17 17:16:08 +01:00 (Migrated from github.com)
Review

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
jessopb commented 2021-02-17 17:16:08 +01:00 (Migrated from github.com)
Review

Array/< { claimId: string, items: ?Array } >

Array/< { claimId: string, items: ?Array<GenericClaim> } >
const batches = [];
jessopb commented 2021-02-17 17:16:08 +01:00 (Migrated from github.com)
Review

Array/< { claimId: string, items: ?Array } >

Array/< { claimId: string, items: ?Array<GenericClaim> } >
let fetchResult;
jessopb commented 2021-02-17 17:16:08 +01:00 (Migrated from github.com)
Review

Array/< { claimId: string, items: ?Array } >

Array/< { claimId: string, items: ?Array<GenericClaim> } >
if (!pageSize) {
jessopb commented 2021-02-17 17:16:08 +01:00 (Migrated from github.com)
Review

Array/< { claimId: string, items: ?Array } >

Array/< { claimId: string, items: ?Array<GenericClaim> } >
// batch all
jessopb commented 2021-02-17 17:16:08 +01:00 (Migrated from github.com)
Review

Array/< { claimId: string, items: ?Array } >

Array/< { claimId: string, items: ?Array<GenericClaim> } >
for (let i = 0; i < Math.ceil(totalItems / BATCH_SIZE); i++) {
jessopb commented 2021-02-17 17:16:08 +01:00 (Migrated from github.com)
Review

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.
jessopb commented 2021-02-17 17:16:08 +01:00 (Migrated from github.com)
Review

Array/< { claimId: string, items: ?Array } >

Array/< { claimId: string, items: ?Array<GenericClaim> } >
// otherwise large lists of, ~500 channels for a homepage category failed
jessopb commented 2021-02-17 17:16:08 +01:00 (Migrated from github.com)
Review

Array/< { claimId: string, items: ?Array } >

Array/< { claimId: string, items: ?Array<GenericClaim> } >
const batchSize = pageSize || FETCH_BATCH_SIZE;
jessopb commented 2021-02-17 17:16:08 +01:00 (Migrated from github.com)
Review

Array/< { claimId: string, items: ?Array } >

Array/< { claimId: string, items: ?Array<GenericClaim> } >
const batches: Array<Promise<any>> = [];
jessopb commented 2021-02-17 17:16:08 +01:00 (Migrated from github.com)
Review

Array/< { claimId: string, items: ?Array } >

Array/< { claimId: string, items: ?Array<GenericClaim> } >
/*
jessopb commented 2021-02-17 17:16:08 +01:00 (Migrated from github.com)
Review

Array/< { claimId: string, items: ?Array } >

Array/< { claimId: string, items: ?Array<GenericClaim> } >
// this was `collection_resolve` which returns claims for collection in order
jessopb commented 2021-02-17 17:16:08 +01:00 (Migrated from github.com)
Review

Array/< { claimId: string, items: ?Array } >

Array/< { claimId: string, items: ?Array<GenericClaim> } >
// however, this fails when a claim is pending. :/
jessopb commented 2021-02-17 17:16:08 +01:00 (Migrated from github.com)
Review

Array/< { claimId: string, items: ?Array } >

Array/< { claimId: string, items: ?Array<GenericClaim> } >
for (let i = 0; i < Math.ceil(totalItems / batchSize); i++) {
jessopb commented 2021-02-17 17:16:08 +01:00 (Migrated from github.com)
Review

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,
jessopb commented 2021-02-17 17:16:08 +01:00 (Migrated from github.com)
Review

Array/< { claimId: string, items: ?Array } >

Array/< { claimId: string, items: ?Array<GenericClaim> } >
page_size: batchSize,
jessopb commented 2021-02-17 17:16:08 +01:00 (Migrated from github.com)
Review

Array/< { claimId: string, items: ?Array } >

Array/< { claimId: string, items: ?Array<GenericClaim> } >
});
}
const resultArray = await Promise.all(batches);
jessopb commented 2021-02-17 17:16:08 +01:00 (Migrated from github.com)
Review

Array/< { claimId: string, items: ?Array } >

Array/< { claimId: string, items: ?Array<GenericClaim> } >
fetchResult = mergeResults(resultArray);
jessopb commented 2021-02-17 17:16:08 +01:00 (Migrated from github.com)
Review

Array/< { claimId: string, items: ?Array } >

Array/< { claimId: string, items: ?Array<GenericClaim> } >
} else {
jessopb commented 2021-02-17 17:16:08 +01:00 (Migrated from github.com)
Review

Array/< { claimId: string, items: ?Array } >

Array/< { claimId: string, items: ?Array<GenericClaim> } >
fetchResult = await Lbry.collection_resolve({
jessopb commented 2021-02-17 17:16:08 +01:00 (Migrated from github.com)
Review

Array/< { claimId: string, items: ?Array } >

Array/< { claimId: string, items: ?Array<GenericClaim> } >
claim_id: claimId,
jessopb commented 2021-02-17 17:16:08 +01:00 (Migrated from github.com)
Review

Array/< { claimId: string, items: ?Array } >

Array/< { claimId: string, items: ?Array<GenericClaim> } >
page: 1,
jessopb commented 2021-02-17 17:16:08 +01:00 (Migrated from github.com)
Review

Array/< { claimId: string, items: ?Array } >

Array/< { claimId: string, items: ?Array<GenericClaim> } >
page_size: pageSize,
jessopb commented 2021-02-17 17:16:08 +01:00 (Migrated from github.com)
Review

Array/< { claimId: string, items: ?Array } >

Array/< { claimId: string, items: ?Array<GenericClaim> } >
*/
jessopb commented 2021-02-17 17:16:08 +01:00 (Migrated from github.com)
Review

Array/< { claimId: string, items: ?Array } >

Array/< { claimId: string, items: ?Array<GenericClaim> } >
jessopb commented 2021-02-17 17:16:08 +01:00 (Migrated from github.com)
Review

Array/< { claimId: string, items: ?Array } >

Array/< { claimId: string, items: ?Array<GenericClaim> } >
for (let i = 0; i < Math.ceil(totalItems / batchSize); i++) {
jessopb commented 2021-02-17 17:16:08 +01:00 (Migrated from github.com)
Review

Array/< { claimId: string, items: ?Array } >

Array/< { claimId: string, items: ?Array<GenericClaim> } >
batches[i] = Lbry.claim_search({
jessopb commented 2021-02-17 17:16:08 +01:00 (Migrated from github.com)
Review

Array/< { claimId: string, items: ?Array } >

Array/< { claimId: string, items: ?Array<GenericClaim> } >
claim_ids: claim.value.claims,
jessopb commented 2021-02-17 17:16:08 +01:00 (Migrated from github.com)
Review

Array/< { claimId: string, items: ?Array } >

Array/< { claimId: string, items: ?Array<GenericClaim> } >
page: i + 1,
jessopb commented 2021-02-17 17:16:08 +01:00 (Migrated from github.com)
Review

Array/< { claimId: string, items: ?Array } >

Array/< { claimId: string, items: ?Array<GenericClaim> } >
page_size: batchSize,
jessopb commented 2021-02-17 17:16:08 +01:00 (Migrated from github.com)
Review

Array/< { claimId: string, items: ?Array } >

Array/< { claimId: string, items: ?Array<GenericClaim> } >
});
}
const itemsInBatches = await Promise.all(batches);
jessopb commented 2021-02-17 17:16:08 +01:00 (Migrated from github.com)
Review

Array/< { claimId: string, items: ?Array } >

Array/< { claimId: string, items: ?Array<GenericClaim> } >
const result = mergeBatches(itemsInBatches, itemOrder);
jessopb commented 2021-02-17 17:16:08 +01:00 (Migrated from github.com)
Review

Array/< { claimId: string, items: ?Array } >

Array/< { claimId: string, items: ?Array<GenericClaim> } >
jessopb commented 2021-02-17 17:16:08 +01:00 (Migrated from github.com)
Review

Array/< { claimId: string, items: ?Array } >

Array/< { claimId: string, items: ?Array<GenericClaim> } >
// $FlowFixMe
const itemsById: { claimId: string, items?: ?Array<GenericClaim> } = { claimId: claimId };
if (fetchResult.items) {
jessopb commented 2021-02-17 17:16:08 +01:00 (Migrated from github.com)
Review

Array/< { claimId: string, items: ?Array } >

Array/< { claimId: string, items: ?Array<GenericClaim> } >
itemsById.items = fetchResult.items;
jessopb commented 2021-02-17 17:16:08 +01:00 (Migrated from github.com)
Review

Array/< { claimId: string, items: ?Array } >

Array/< { claimId: string, items: ?Array<GenericClaim> } >
if (result.items) {
jessopb commented 2021-02-17 17:16:08 +01:00 (Migrated from github.com)
Review

Array/< { claimId: string, items: ?Array } >

Array/< { claimId: string, items: ?Array<GenericClaim> } >
itemsById.items = result.items;
jessopb commented 2021-02-17 17:16:08 +01:00 (Migrated from github.com)
Review

Array/< { claimId: string, items: ?Array } >

Array/< { claimId: string, items: ?Array<GenericClaim> } >
} else {
itemsById.items = null;
}
@ -157,29 +186,8 @@ export const doFetchItemsInCollections = (
jessopb commented 2021-02-17 17:16:08 +01:00 (Migrated from github.com)
Review

Array/< { claimId: string, items: ?Array } >

Array/< { claimId: string, items: ?Array<GenericClaim> } >
jessopb commented 2021-02-17 17:16:08 +01:00 (Migrated from github.com)
Review

Array/< { claimId: string, items: ?Array } >

Array/< { claimId: string, items: ?Array<GenericClaim> } >
}
}
const promises = [];
jessopb commented 2021-02-17 17:16:08 +01:00 (Migrated from github.com)
Review

Array/< { claimId: string, items: ?Array } >

Array/< { claimId: string, items: ?Array<GenericClaim> } >
collectionIds.forEach(collectionId => {
jessopb commented 2021-02-17 17:16:08 +01:00 (Migrated from github.com)
Review

Array/< { claimId: string, items: ?Array } >

Array/< { claimId: string, items: ?Array<GenericClaim> } >
const claim = makeSelectClaimForClaimId(collectionId)(stateAfterClaimSearch);
jessopb commented 2021-02-17 17:16:08 +01:00 (Migrated from github.com)
Review

Array/< { claimId: string, items: ?Array } >

Array/< { claimId: string, items: ?Array<GenericClaim> } >
if (!claim) {
jessopb commented 2021-02-17 17:16:08 +01:00 (Migrated from github.com)
Review

Array/< { claimId: string, items: ?Array } >

Array/< { claimId: string, items: ?Array<GenericClaim> } >
invalidCollectionIds.push(collectionId);
jessopb commented 2021-02-17 17:16:08 +01:00 (Migrated from github.com)
Review

Array/< { claimId: string, items: ?Array } >

Array/< { claimId: string, items: ?Array<GenericClaim> } >
} else {
jessopb commented 2021-02-17 17:16:08 +01:00 (Migrated from github.com)
Review

Array/< { claimId: string, items: ?Array } >

Array/< { claimId: string, items: ?Array<GenericClaim> } >
const claimCount = claim.value.claims && claim.value.claims.length;
jessopb commented 2021-02-17 17:16:08 +01:00 (Migrated from github.com)
Review

Array/< { claimId: string, items: ?Array } >

Array/< { claimId: string, items: ?Array<GenericClaim> } >
if (pageSize) {
jessopb commented 2021-02-17 17:16:08 +01:00 (Migrated from github.com)
Review

Array/< { claimId: string, items: ?Array } >

Array/< { claimId: string, items: ?Array<GenericClaim> } >
promises.push(resolveCollectionItems(collectionId, claimCount, pageSize));
jessopb commented 2021-02-17 17:16:08 +01:00 (Migrated from github.com)
Review

Array/< { claimId: string, items: ?Array } >

Array/< { claimId: string, items: ?Array<GenericClaim> } >
} else {
jessopb commented 2021-02-17 17:16:08 +01:00 (Migrated from github.com)
Review

Array/< { claimId: string, items: ?Array } >

Array/< { claimId: string, items: ?Array<GenericClaim> } >
promises.push(resolveCollectionItems(collectionId, claimCount));
jessopb commented 2021-02-17 17:16:08 +01:00 (Migrated from github.com)
Review

Array/< { claimId: string, items: ?Array } >

Array/< { claimId: string, items: ?Array<GenericClaim> } >
}
jessopb commented 2021-02-17 17:16:08 +01:00 (Migrated from github.com)
Review

Array/< { claimId: string, items: ?Array } >

Array/< { claimId: string, items: ?Array<GenericClaim> } >
}
jessopb commented 2021-02-17 17:16:08 +01:00 (Migrated from github.com)
Review

Array/< { claimId: string, items: ?Array } >

Array/< { claimId: string, items: ?Array<GenericClaim> } >
});
jessopb commented 2021-02-17 17:16:08 +01:00 (Migrated from github.com)
Review

Array/< { claimId: string, items: ?Array } >

Array/< { claimId: string, items: ?Array<GenericClaim> } >
jessopb commented 2021-02-17 17:16:08 +01:00 (Migrated from github.com)
Review

Array/< { claimId: string, items: ?Array } >

Array/< { claimId: string, items: ?Array<GenericClaim> } >
// $FlowFixMe
jessopb commented 2021-02-17 17:16:08 +01:00 (Migrated from github.com)
Review

Array/< { claimId: string, items: ?Array } >

Array/< { claimId: string, items: ?Array<GenericClaim> } >
const resolvedCollectionItemsById: Array<{
jessopb commented 2021-02-17 17:16:08 +01:00 (Migrated from github.com)
Review

Array/< { claimId: string, items: ?Array } >

Array/< { claimId: string, items: ?Array<GenericClaim> } >
claimId: string,
jessopb commented 2021-02-17 17:16:08 +01:00 (Migrated from github.com)
Review

Array/< { claimId: string, items: ?Array } >

Array/< { claimId: string, items: ?Array<GenericClaim> } >
items: ?Array<GenericClaim>,
jessopb commented 2021-02-17 17:16:08 +01:00 (Migrated from github.com)
Review

Array/< { claimId: string, items: ?Array } >

Array/< { claimId: string, items: ?Array<GenericClaim> } >
}> = await Promise.all(promises);
jessopb commented 2021-02-17 17:16:08 +01:00 (Migrated from github.com)
Review

Array/< { claimId: string, items: ?Array } >

Array/< { claimId: string, items: ?Array<GenericClaim> } >
jessopb commented 2021-02-17 17:16:08 +01:00 (Migrated from github.com)
Review

Array/< { claimId: string, items: ?Array } >

Array/< { claimId: string, items: ?Array<GenericClaim> } >
function processClaims(resultClaimsByUri) {
jessopb commented 2021-02-17 17:16:08 +01:00 (Migrated from github.com)
Review

Array/< { claimId: string, items: ?Array } >

Array/< { claimId: string, items: ?Array<GenericClaim> } >
const processedClaims = {};
jessopb commented 2021-02-17 17:16:08 +01:00 (Migrated from github.com)
Review

Array/< { claimId: string, items: ?Array } >

Array/< { claimId: string, items: ?Array<GenericClaim> } >
function formatForClaimActions(resultClaimsByUri) {
jessopb commented 2021-02-17 17:16:08 +01:00 (Migrated from github.com)
Review

Array/< { claimId: string, items: ?Array } >

Array/< { claimId: string, items: ?Array<GenericClaim> } >
const formattedClaims = {};
jessopb commented 2021-02-17 17:16:08 +01:00 (Migrated from github.com)
Review

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 = (
jessopb commented 2021-02-17 17:16:08 +01:00 (Migrated from github.com)
Review

Array/< { claimId: string, items: ?Array } >

Array/< { claimId: string, items: ?Array<GenericClaim> } >
jessopb commented 2021-02-17 17:16:08 +01:00 (Migrated from github.com)
Review

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') {
jessopb commented 2021-02-17 17:16:08 +01:00 (Migrated from github.com)
Review

Array/< { claimId: string, items: ?Array } >

Array/< { claimId: string, items: ?Array<GenericClaim> } >
result.collection = uriResolveInfo;
jessopb commented 2021-02-17 17:16:08 +01:00 (Migrated from github.com)
Review

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 = (
jessopb commented 2021-02-17 17:16:08 +01:00 (Migrated from github.com)
Review

Array/< { claimId: string, items: ?Array } >

Array/< { claimId: string, items: ?Array<GenericClaim> } >
jessopb commented 2021-02-17 17:16:08 +01:00 (Migrated from github.com)
Review

Array/< { claimId: string, items: ?Array } >

Array/< { claimId: string, items: ?Array<GenericClaim> } >
}
}
// $FlowFixMe
processedClaims[uri] = result;
jessopb commented 2021-02-17 17:16:08 +01:00 (Migrated from github.com)
Review

Array/< { claimId: string, items: ?Array } >

Array/< { claimId: string, items: ?Array<GenericClaim> } >
formattedClaims[uri] = result;
jessopb commented 2021-02-17 17:16:08 +01:00 (Migrated from github.com)
Review

Array/< { claimId: string, items: ?Array } >

Array/< { claimId: string, items: ?Array<GenericClaim> } >
}
});
return processedClaims;
jessopb commented 2021-02-17 17:16:08 +01:00 (Migrated from github.com)
Review

Array/< { claimId: string, items: ?Array } >

Array/< { claimId: string, items: ?Array<GenericClaim> } >
return formattedClaims;
jessopb commented 2021-02-17 17:16:08 +01:00 (Migrated from github.com)
Review

Array/< { claimId: string, items: ?Array } >

Array/< { claimId: string, items: ?Array<GenericClaim> } >
}
const newCollectionItemsById = {};
jessopb commented 2021-02-17 17:16:08 +01:00 (Migrated from github.com)
Review

Array/< { claimId: string, items: ?Array } >

Array/< { claimId: string, items: ?Array<GenericClaim> } >
const flatResolvedCollectionItems = {};
jessopb commented 2021-02-17 17:16:08 +01:00 (Migrated from github.com)
Review

Array/< { claimId: string, items: ?Array } >

Array/< { claimId: string, items: ?Array<GenericClaim> } >
resolvedCollectionItemsById.forEach(entry => {
jessopb commented 2021-02-17 17:16:08 +01:00 (Migrated from github.com)
Review

Array/< { claimId: string, items: ?Array } >

Array/< { claimId: string, items: ?Array<GenericClaim> } >
const invalidCollectionIds = [];
jessopb commented 2021-02-17 17:16:08 +01:00 (Migrated from github.com)
Review

Array/< { claimId: string, items: ?Array } >

Array/< { claimId: string, items: ?Array<GenericClaim> } >
const promisedCollectionItemFetches = [];
jessopb commented 2021-02-17 17:16:08 +01:00 (Migrated from github.com)
Review

Array/< { claimId: string, items: ?Array } >

Array/< { claimId: string, items: ?Array<GenericClaim> } >
collectionIds.forEach(collectionId => {
jessopb commented 2021-02-17 17:16:08 +01:00 (Migrated from github.com)
Review

Array/< { claimId: string, items: ?Array } >

Array/< { claimId: string, items: ?Array<GenericClaim> } >
const claim = makeSelectClaimForClaimId(collectionId)(stateAfterClaimSearch);
jessopb commented 2021-02-17 17:16:08 +01:00 (Migrated from github.com)
Review

Array/< { claimId: string, items: ?Array } >

Array/< { claimId: string, items: ?Array<GenericClaim> } >
if (!claim) {
jessopb commented 2021-02-17 17:16:08 +01:00 (Migrated from github.com)
Review

Array/< { claimId: string, items: ?Array } >

Array/< { claimId: string, items: ?Array<GenericClaim> } >
invalidCollectionIds.push(collectionId);
jessopb commented 2021-02-17 17:16:08 +01:00 (Migrated from github.com)
Review

Array/< { claimId: string, items: ?Array } >

Array/< { claimId: string, items: ?Array<GenericClaim> } >
} else {
jessopb commented 2021-02-17 17:16:08 +01:00 (Migrated from github.com)
Review

Array/< { claimId: string, items: ?Array } >

Array/< { claimId: string, items: ?Array<GenericClaim> } >
promisedCollectionItemFetches.push(fetchItemsForCollectionClaim(claim, pageSize));
jessopb commented 2021-02-17 17:16:08 +01:00 (Migrated from github.com)
Review

Array/< { claimId: string, items: ?Array } >

Array/< { claimId: string, items: ?Array<GenericClaim> } >
}
jessopb commented 2021-02-17 17:16:08 +01:00 (Migrated from github.com)
Review

Array/< { claimId: string, items: ?Array } >

Array/< { claimId: string, items: ?Array<GenericClaim> } >
});
jessopb commented 2021-02-17 17:16:08 +01:00 (Migrated from github.com)
Review

Array/< { claimId: string, items: ?Array } >

Array/< { claimId: string, items: ?Array<GenericClaim> } >
jessopb commented 2021-02-17 17:16:08 +01:00 (Migrated from github.com)
Review

Array/< { claimId: string, items: ?Array } >

Array/< { claimId: string, items: ?Array<GenericClaim> } >
// $FlowFixMe
jessopb commented 2021-02-17 17:16:08 +01:00 (Migrated from github.com)
Review

Array/< { claimId: string, items: ?Array } >

Array/< { claimId: string, items: ?Array<GenericClaim> } >
const collectionItemsById: Array<{
jessopb commented 2021-02-17 17:16:08 +01:00 (Migrated from github.com)
Review

Array/< { claimId: string, items: ?Array } >

Array/< { claimId: string, items: ?Array<GenericClaim> } >
claimId: string,
jessopb commented 2021-02-17 17:16:08 +01:00 (Migrated from github.com)
Review

Array/< { claimId: string, items: ?Array } >

Array/< { claimId: string, items: ?Array<GenericClaim> } >
items: ?Array<GenericClaim>,
jessopb commented 2021-02-17 17:16:08 +01:00 (Migrated from github.com)
Review

Array/< { claimId: string, items: ?Array } >

Array/< { claimId: string, items: ?Array<GenericClaim> } >
}> = await Promise.all(promisedCollectionItemFetches);
jessopb commented 2021-02-17 17:16:08 +01:00 (Migrated from github.com)
Review

Array/< { claimId: string, items: ?Array } >

Array/< { claimId: string, items: ?Array<GenericClaim> } >
jessopb commented 2021-02-17 17:16:08 +01:00 (Migrated from github.com)
Review

Array/< { claimId: string, items: ?Array } >

Array/< { claimId: string, items: ?Array<GenericClaim> } >
const newCollectionObjectsById = {};
jessopb commented 2021-02-17 17:16:08 +01:00 (Migrated from github.com)
Review

Array/< { claimId: string, items: ?Array } >

Array/< { claimId: string, items: ?Array<GenericClaim> } >
const resolvedItemsByUrl = {};
jessopb commented 2021-02-17 17:16:08 +01:00 (Migrated from github.com)
Review

Array/< { claimId: string, items: ?Array } >

Array/< { claimId: string, items: ?Array<GenericClaim> } >
collectionItemsById.forEach(entry => {
jessopb commented 2021-02-17 17:16:08 +01:00 (Migrated from github.com)
Review

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 = (
jessopb commented 2021-02-17 17:16:08 +01:00 (Migrated from github.com)
Review

Array/< { claimId: string, items: ?Array } >

Array/< { claimId: string, items: ?Array<GenericClaim> } >
jessopb commented 2021-02-17 17:16:08 +01:00 (Migrated from github.com)
Review

Array/< { claimId: string, items: ?Array } >

Array/< { claimId: string, items: ?Array<GenericClaim> } >
const valueTypes = new Set();
const streamTypes = new Set();
let items = [];
jessopb commented 2021-02-17 17:16:08 +01:00 (Migrated from github.com)
Review

Array/< { claimId: string, items: ?Array } >

Array/< { claimId: string, items: ?Array<GenericClaim> } >
let newItems = [];
jessopb commented 2021-02-17 17:16:08 +01:00 (Migrated from github.com)
Review

Array/< { claimId: string, items: ?Array } >

Array/< { claimId: string, items: ?Array<GenericClaim> } >
let isPlaylist;
jessopb commented 2021-02-17 17:16:08 +01:00 (Migrated from github.com)
Review

Array/< { claimId: string, items: ?Array } >

Array/< { claimId: string, items: ?Array<GenericClaim> } >
jessopb commented 2021-02-17 17:16:08 +01:00 (Migrated from github.com)
Review

Array/< { claimId: string, items: ?Array } >

Array/< { claimId: string, items: ?Array<GenericClaim> } >
if (collectionItems) {
jessopb commented 2021-02-17 17:16:08 +01:00 (Migrated from github.com)
Review

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);
jessopb commented 2021-02-17 17:16:08 +01:00 (Migrated from github.com)
Review

Array/< { claimId: string, items: ?Array } >

Array/< { claimId: string, items: ?Array<GenericClaim> } >
newItems.push(collectionItem.permanent_url);
jessopb commented 2021-02-17 17:16:08 +01:00 (Migrated from github.com)
Review

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;
jessopb commented 2021-02-17 17:16:08 +01:00 (Migrated from github.com)
Review

Array/< { claimId: string, items: ?Array } >

Array/< { claimId: string, items: ?Array<GenericClaim> } >
resolvedItemsByUrl[collectionItem.canonical_url] = collectionItem;
jessopb commented 2021-02-17 17:16:08 +01:00 (Migrated from github.com)
Review

Array/< { claimId: string, items: ?Array } >

Array/< { claimId: string, items: ?Array<GenericClaim> } >
});
const isPlaylist =
jessopb commented 2021-02-17 17:16:08 +01:00 (Migrated from github.com)
Review

Array/< { claimId: string, items: ?Array } >

Array/< { claimId: string, items: ?Array<GenericClaim> } >
isPlaylist =
jessopb commented 2021-02-17 17:16:08 +01:00 (Migrated from github.com)
Review

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'))));
}
jessopb commented 2021-02-17 17:16:08 +01:00 (Migrated from github.com)
Review

Array/< { claimId: string, items: ?Array } >

Array/< { claimId: string, items: ?Array<GenericClaim> } >
newCollectionItemsById[collectionId] = {
jessopb commented 2021-02-17 17:16:08 +01:00 (Migrated from github.com)
Review

Array/< { claimId: string, items: ?Array } >

Array/< { claimId: string, items: ?Array<GenericClaim> } >
items,
jessopb commented 2021-02-17 17:16:08 +01:00 (Migrated from github.com)
Review

Array/< { claimId: string, items: ?Array } >

Array/< { claimId: string, items: ?Array<GenericClaim> } >
newCollectionObjectsById[collectionId] = {
jessopb commented 2021-02-17 17:16:08 +01:00 (Migrated from github.com)
Review

Array/< { claimId: string, items: ?Array } >

Array/< { claimId: string, items: ?Array<GenericClaim> } >
items: newItems,
jessopb commented 2021-02-17 17:16:08 +01:00 (Migrated from github.com)
Review

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
jessopb commented 2021-02-17 17:16:08 +01:00 (Migrated from github.com)
Review

Array/< { claimId: string, items: ?Array } >

Array/< { claimId: string, items: ?Array<GenericClaim> } >
jessopb commented 2021-02-17 17:16:08 +01:00 (Migrated from github.com)
Review

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 = (
jessopb commented 2021-02-17 17:16:08 +01:00 (Migrated from github.com)
Review

Array/< { claimId: string, items: ?Array } >

Array/< { claimId: string, items: ?Array<GenericClaim> } >
jessopb commented 2021-02-17 17:16:08 +01:00 (Migrated from github.com)
Review

Array/< { claimId: string, items: ?Array } >

Array/< { claimId: string, items: ?Array<GenericClaim> } >
});
}
} else {
// no collection items? probably in pending.
jessopb commented 2021-02-17 17:16:08 +01:00 (Migrated from github.com)
Review

Array/< { claimId: string, items: ?Array } >

Array/< { claimId: string, items: ?Array<GenericClaim> } >
invalidCollectionIds.push(collectionId);
jessopb commented 2021-02-17 17:16:08 +01:00 (Migrated from github.com)
Review

Array/< { claimId: string, items: ?Array } >

Array/< { claimId: string, items: ?Array<GenericClaim> } >
}
});
const processedClaimsByUri = processClaims(flatResolvedCollectionItems);
jessopb commented 2021-02-17 17:16:08 +01:00 (Migrated from github.com)
Review

Array/< { claimId: string, items: ?Array } >

Array/< { claimId: string, items: ?Array<GenericClaim> } >
const formattedClaimsByUri = formatForClaimActions(collectionItemsById);
jessopb commented 2021-02-17 17:16:08 +01:00 (Migrated from github.com)
Review

Array/< { claimId: string, items: ?Array } >

Array/< { claimId: string, items: ?Array<GenericClaim> } >
dispatch({
type: ACTIONS.RESOLVE_URIS_COMPLETED,
data: { resolveInfo: processedClaimsByUri },
jessopb commented 2021-02-17 17:16:08 +01:00 (Migrated from github.com)
Review

Array/< { claimId: string, items: ?Array } >

Array/< { claimId: string, items: ?Array<GenericClaim> } >
data: { resolveInfo: formattedClaimsByUri },
jessopb commented 2021-02-17 17:16:08 +01:00 (Migrated from github.com)
Review

Array/< { claimId: string, items: ?Array } >

Array/< { claimId: string, items: ?Array<GenericClaim> } >
});
dispatch({
type: ACTIONS.COLLECTION_ITEMS_RESOLVE_COMPLETED,
data: {
resolvedCollections: newCollectionItemsById,
jessopb commented 2021-02-17 17:16:08 +01:00 (Migrated from github.com)
Review

Array/< { claimId: string, items: ?Array } >

Array/< { claimId: string, items: ?Array<GenericClaim> } >
resolvedCollections: newCollectionObjectsById,
jessopb commented 2021-02-17 17:16:08 +01:00 (Migrated from github.com)
Review

Array/< { claimId: string, items: ?Array } >

Array/< { claimId: string, items: ?Array<GenericClaim> } >
failedCollectionIds: invalidCollectionIds,
},
});
@ -389,10 +420,8 @@ export const doCollectionEdit = (collectionId: string, params: CollectionEditPar
jessopb commented 2021-02-17 17:16:08 +01:00 (Migrated from github.com)
Review

Array/< { claimId: string, items: ?Array } >

Array/< { claimId: string, items: ?Array<GenericClaim> } >
jessopb commented 2021-02-17 17:16:08 +01:00 (Migrated from github.com)
Review

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(',')) {
jessopb commented 2021-02-17 17:16:08 +01:00 (Migrated from github.com)
Review

Array/< { claimId: string, items: ?Array } >

Array/< { claimId: string, items: ?Array<GenericClaim> } >
// print these
jessopb commented 2021-02-17 17:16:08 +01:00 (Migrated from github.com)
Review

Array/< { claimId: string, items: ?Array } >

Array/< { claimId: string, items: ?Array<GenericClaim> } >
jessopb commented 2021-02-17 17:16:08 +01:00 (Migrated from github.com)
Review

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(',')) {
jessopb commented 2021-02-17 17:16:08 +01:00 (Migrated from github.com)
Review

Array/< { claimId: string, items: ?Array } >

Array/< { claimId: string, items: ?Array<GenericClaim> } >
dispatch({
type: ACTIONS.COLLECTION_DELETE,
data: {

jessopb commented 2021-02-17 17:16:08 +01:00 (Migrated from github.com)
Review

Array/< { claimId: string, items: ?Array } >

Array/< { claimId: string, items: ?Array<GenericClaim> } >
jessopb commented 2021-02-17 17:16:08 +01:00 (Migrated from github.com)
Review

Array/< { claimId: string, items: ?Array } >

Array/< { claimId: string, items: ?Array<GenericClaim> } >

View file

@ -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