From e34f451025c3cdb5626e216ad863dafbf72ad3b1 Mon Sep 17 00:00:00 2001 From: zeppi Date: Wed, 19 May 2021 11:36:11 -0400 Subject: [PATCH] collections length --- dist/bundle.es.js | 16 ++++++++++------ src/redux/actions/collections.js | 2 +- src/redux/selectors/collections.js | 9 ++++++--- 3 files changed, 17 insertions(+), 10 deletions(-) diff --git a/dist/bundle.es.js b/dist/bundle.es.js index eb02084..ab4c0d0 100644 --- a/dist/bundle.es.js +++ b/dist/bundle.es.js @@ -3707,10 +3707,13 @@ const makeSelectNameForCollectionId = id => reselect.createSelector(makeSelectCo }); const makeSelectCountForCollectionId = id => reselect.createSelector(makeSelectCollectionForId(id), collection => { - if (collection.itemCount !== undefined) { - return collection.itemCount; + if (collection) { + if (collection.itemCount !== undefined) { + return collection.itemCount; + } + return collection.items.length; } - return collection.items.length; + return null; }); var _extends$5 = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; @@ -4594,7 +4597,7 @@ const doLocalCollectionCreate = (name, collectionItems, type, sourceId) => dispa }); }; -const doCollectionDelete = (id, colKey = undefined, keepLocal) => dispatch => { +const doCollectionDelete = (id, colKey = undefined) => dispatch => { return dispatch({ type: COLLECTION_DELETE, data: { @@ -4766,7 +4769,8 @@ const doFetchItemsInCollections = (resolveItemsOptions, resolveStartedCallback) const claim = makeSelectClaimForClaimId(collectionId)(stateAfterClaimSearch); const editedCollection = makeSelectEditedCollectionForId(collectionId)(stateAfterClaimSearch); - const { name, timestamp } = claim || {}; + const { name, timestamp, value } = claim || {}; + const { title } = value; const valueTypes = new Set(); const streamTypes = new Set(); @@ -4785,7 +4789,7 @@ const doFetchItemsInCollections = (resolveItemsOptions, resolveStartedCallback) newCollectionItemsById[collectionId] = { items, id: collectionId, - name: name, + name: title || name, itemCount: claim.value.claims.length, type: isPlaylist ? 'playlist' : 'collection', updatedAt: timestamp diff --git a/src/redux/actions/collections.js b/src/redux/actions/collections.js index 3b44b5e..202b516 100644 --- a/src/redux/actions/collections.js +++ b/src/redux/actions/collections.js @@ -21,7 +21,7 @@ const getTimestamp = () => { // maybe take items param export const doLocalCollectionCreate = ( name: string, - collectionItems: string, + collectionItems: Array, type: string, sourceId: string ) => (dispatch: Dispatch) => { diff --git a/src/redux/selectors/collections.js b/src/redux/selectors/collections.js index f781b91..68cdddf 100644 --- a/src/redux/selectors/collections.js +++ b/src/redux/selectors/collections.js @@ -208,9 +208,12 @@ export const makeSelectCountForCollectionId = (id: string) => createSelector( makeSelectCollectionForId(id), collection => { - if (collection.itemCount !== undefined) { - return collection.itemCount; + if (collection) { + if (collection.itemCount !== undefined) { + return collection.itemCount; + } + return collection.items.length; } - return collection.items.length; + return null; } );