Collections #383
21
dist/bundle.es.js
vendored
|
@ -1040,8 +1040,8 @@ var shared_preferences = /*#__PURE__*/Object.freeze({
|
|||
CLIENT_SYNC_KEYS: CLIENT_SYNC_KEYS
|
||||
});
|
||||
|
||||
const COLLECTION_ID = 'colid';
|
||||
const COLLECTION_INDEX = 'colindex';
|
||||
const COLLECTION_ID = 'lid';
|
||||
const COLLECTION_INDEX = 'linx';
|
||||
|
||||
const COL_TYPE_PLAYLIST = 'playlist';
|
||||
const COL_TYPE_CHANNELS = 'channelList';
|
||||
|
@ -4662,16 +4662,21 @@ const doFetchItemsInCollections = (resolveItemsOptions, resolveStartedCallback)
|
|||
const claimId = claim.claim_id;
|
||||
const itemOrder = claim.value.claims;
|
||||
|
||||
const sortResults = function (results, claimList) {
|
||||
const newResults = [];
|
||||
const sortResults = function (items, claimList) {
|
||||
const newItems = [];
|
||||
claimList.forEach(function (id) {
|
||||
const index = results.findIndex(function (i) {
|
||||
const index = items.findIndex(function (i) {
|
||||
return i.claim_id === id;
|
||||
});
|
||||
const item = results.splice(index, 1);
|
||||
if (item) newResults.push(item[0]);
|
||||
if (index >= 0) {
|
||||
newItems.push(items[index]);
|
||||
}
|
||||
});
|
||||
return newResults;
|
||||
/*
|
||||
This will return newItems[] of length less than total_items below
|
||||
if one or more of the claims has been abandoned. That's ok for now.
|
||||
*/
|
||||
return newItems;
|
||||
};
|
||||
|
||||
const mergeBatches = function (arrayOfResults, claimList) {
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
export const COLLECTION_ID = 'colid';
|
||||
export const COLLECTION_INDEX = 'colindex';
|
||||
export const COLLECTION_ID = 'lid';
|
||||
export const COLLECTION_INDEX = 'linx';
|
||||
|
||||
export const COL_TYPE_PLAYLIST = 'playlist';
|
||||
export const COL_TYPE_CHANNELS = 'channelList';
|
||||
|
|
|
@ -93,7 +93,7 @@ export const doFetchItemsInCollections = (
|
|||
Array/< { claimId: string, items: ?Array } > Array/< { claimId: string, items: ?Array<GenericClaim> } >
|
||||
pageSize?: number,
|
||||
},
|
||||
resolveStartedCallback?: () => void
|
||||
) => async(dispatch: Dispatch, getState: GetState) => {
|
||||
Array/< { claimId: string, items: ?Array } > Array/< { claimId: string, items: ?Array<GenericClaim> } >
|
||||
) => 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.
|
||||
2) get the item claims for each
|
||||
|
@ -124,14 +124,19 @@ 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 claimId = claim.claim_id;
|
||||
const itemOrder = claim.value.claims;
|
||||
|
||||
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> } >
|
||||
const sortResults = (items: Array<Claim>, claimList) => {
|
||||
Array/< { claimId: string, items: ?Array } > Array/< { claimId: string, items: ?Array<GenericClaim> } >
|
||||
const newItems: Array<Claim> = [];
|
||||
Array/< { claimId: string, items: ?Array } > Array/< { claimId: string, items: ?Array<GenericClaim> } >
|
||||
claimList.forEach(id => {
|
||||
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> } >
|
||||
const index = items.findIndex(i => i.claim_id === id);
|
||||
Array/< { claimId: string, items: ?Array } > Array/< { claimId: string, items: ?Array<GenericClaim> } >
|
||||
if (index >= 0) {
|
||||
Array/< { claimId: string, items: ?Array } > Array/< { claimId: string, items: ?Array<GenericClaim> } >
|
||||
newItems.push(items[index]);
|
||||
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> } >
|
||||
This will return newItems[] of length less than total_items below
|
||||
Array/< { claimId: string, items: ?Array } > Array/< { claimId: string, items: ?Array<GenericClaim> } >
|
||||
if one or more of the claims has been abandoned. That's ok for now.
|
||||
Array/< { claimId: string, items: ?Array } > Array/< { claimId: string, items: ?Array<GenericClaim> } >
|
||||
*/
|
||||
Array/< { claimId: string, items: ?Array } > Array/< { claimId: string, items: ?Array<GenericClaim> } >
|
||||
return newItems;
|
||||
Array/< { claimId: string, items: ?Array } > Array/< { claimId: string, items: ?Array<GenericClaim> } >
|
||||
};
|
||||
|
||||
const mergeBatches = (
|
||||
|
@ -313,7 +318,7 @@ export const doFetchItemsInCollection = (
|
|||
Array/< { claimId: string, items: ?Array } > Array/< { claimId: string, items: ?Array<GenericClaim> } >
Array/< { claimId: string, items: ?Array } > Array/< { claimId: string, items: ?Array<GenericClaim> } >
|
||||
return doFetchItemsInCollections(newOptions, cb);
|
||||
};
|
||||
|
||||
export const doCollectionEdit = (collectionId: string, params: CollectionEditParams) => async(
|
||||
Array/< { claimId: string, items: ?Array } > Array/< { claimId: string, items: ?Array<GenericClaim> } >
|
||||
export const doCollectionEdit = (collectionId: string, params: CollectionEditParams) => async (
|
||||
Array/< { claimId: string, items: ?Array } > Array/< { claimId: string, items: ?Array<GenericClaim> } >
|
||||
dispatch: Dispatch,
|
||||
getState: GetState
|
||||
) => {
|
||||
|
|
|||
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 } >