From 15934866e1d55871129c61f99511582d1fb655d1 Mon Sep 17 00:00:00 2001 From: jessop Date: Thu, 21 Nov 2019 20:36:06 -0500 Subject: [PATCH] rename claimsByChannel to paginated... --- dist/bundle.es.js | 28 ++++++++++++---------------- src/index.js | 4 ++-- src/redux/reducers/claims.js | 18 +++++++----------- src/redux/selectors/claims.js | 8 ++++---- 4 files changed, 25 insertions(+), 33 deletions(-) diff --git a/dist/bundle.es.js b/dist/bundle.es.js index 2a8303f..7566ec3 100644 --- a/dist/bundle.es.js +++ b/dist/bundle.es.js @@ -1805,7 +1805,7 @@ const selectClaimsByUri = reselect.createSelector(selectState$2, selectClaimsByI return claims; }); -const selectAllClaimsByChannel = reselect.createSelector(selectState$2, state => state.claimsByChannel || {}); +const selectAllClaimsByChannel = reselect.createSelector(selectState$2, state => state.paginatedClaimsByChannel || {}); const selectPendingById = reselect.createSelector(selectState$2, state => state.pendingById || {}); @@ -1881,7 +1881,7 @@ const makeSelectClaimIsMine = rawUri => { const selectAllFetchingChannelClaims = reselect.createSelector(selectState$2, state => state.fetchingChannelClaims || {}); const makeSelectFetchingChannelClaims = uri => reselect.createSelector(selectAllFetchingChannelClaims, fetching => fetching && fetching[uri]); -// this is actually the result of claim search + const makeSelectClaimsInChannelForPage = (uri, page) => reselect.createSelector(selectClaimsById, selectAllClaimsByChannel, (byId, allClaims) => { const byChannel = allClaims[uri] || {}; const claimIds = byChannel[page || 1]; @@ -1891,12 +1891,12 @@ const makeSelectClaimsInChannelForPage = (uri, page) => reselect.createSelector( return claimIds.map(claimId => byId[claimId]); }); -const makeSelectTotalMatchingClaimsInChannel = uri => reselect.createSelector(selectClaimsById, selectAllClaimsByChannel, (byId, allClaims) => { +const makeSelectTotalClaimsInChannelSearch = uri => reselect.createSelector(selectClaimsById, selectAllClaimsByChannel, (byId, allClaims) => { const byChannel = allClaims[uri] || {}; return byChannel['itemCount']; }); -const makeSelectTotalMatchingPaginatedPagesInChannel = uri => reselect.createSelector(selectClaimsById, selectAllClaimsByChannel, (byId, allClaims) => { +const makeSelectTotalPagesInChannelSearch = uri => reselect.createSelector(selectClaimsById, selectAllClaimsByChannel, (byId, allClaims) => { const byChannel = allClaims[uri] || {}; return byChannel['pageCount']; }); @@ -3991,7 +3991,7 @@ const reducers = {}; const defaultState = { byId: {}, claimsByUri: {}, - claimsByChannel: {}, + paginatedClaimsByChannel: {}, channelClaimCounts: {}, fetchingChannelClaims: {}, resolvingUris: [], @@ -4191,10 +4191,10 @@ reducers[FETCH_CHANNEL_CLAIMS_COMPLETED] = (state, action) => { // byChannel keeps claim_search relevant results by page. If the total changes, erase it. const channelClaimCounts = Object.assign({}, state.channelClaimCounts); - const claimsByChannel = Object.assign({}, state.claimsByChannel); + const paginatedClaimsByChannel = Object.assign({}, state.paginatedClaimsByChannel); // check if count has changed - that means cached pagination will be wrong, so clear it - const previousCount = claimsByChannel[uri] && claimsByChannel[uri]['itemCount']; - const byChannel = claimsInChannel === previousCount ? Object.assign({}, claimsByChannel[uri]) : {}; + const previousCount = paginatedClaimsByChannel[uri] && paginatedClaimsByChannel[uri]['itemCount']; + const byChannel = claimsInChannel === previousCount ? Object.assign({}, paginatedClaimsByChannel[uri]) : {}; const allClaimIds = new Set(byChannel.all); const currentPageClaimIds = []; const byId = Object.assign({}, state.byId); @@ -4210,19 +4210,15 @@ reducers[FETCH_CHANNEL_CLAIMS_COMPLETED] = (state, action) => { }); } - if (claimsInChannel) { - channelClaimCounts[uri] = claimsInChannel; - } - byChannel.all = allClaimIds; byChannel.pageCount = totalPages; byChannel.itemCount = claimsInChannel; byChannel[page] = currentPageClaimIds; - claimsByChannel[uri] = byChannel; + paginatedClaimsByChannel[uri] = byChannel; delete fetchingChannelClaims[uri]; return Object.assign({}, state, { - claimsByChannel, + paginatedClaimsByChannel, byId, fetchingChannelClaims, claimsByUri, @@ -5513,10 +5509,10 @@ exports.makeSelectSupportsForUri = makeSelectSupportsForUri; exports.makeSelectTagsForUri = makeSelectTagsForUri; exports.makeSelectThumbnailForUri = makeSelectThumbnailForUri; exports.makeSelectTitleForUri = makeSelectTitleForUri; +exports.makeSelectTotalClaimsInChannelSearch = makeSelectTotalClaimsInChannelSearch; exports.makeSelectTotalItemsForChannel = makeSelectTotalItemsForChannel; -exports.makeSelectTotalMatchingClaimsInChannel = makeSelectTotalMatchingClaimsInChannel; -exports.makeSelectTotalMatchingPaginatedPagesInChannel = makeSelectTotalMatchingPaginatedPagesInChannel; exports.makeSelectTotalPagesForChannel = makeSelectTotalPagesForChannel; +exports.makeSelectTotalPagesInChannelSearch = makeSelectTotalPagesInChannelSearch; exports.makeSelectUriIsStreamable = makeSelectUriIsStreamable; exports.normalizeURI = normalizeURI; exports.notificationsReducer = notificationsReducer; diff --git a/src/index.js b/src/index.js index 2cf47bb..41d1196 100644 --- a/src/index.js +++ b/src/index.js @@ -159,8 +159,8 @@ export { makeSelectClaimIsMine, makeSelectFetchingChannelClaims, makeSelectClaimsInChannelForPage, - makeSelectTotalMatchingPaginatedPagesInChannel, - makeSelectTotalMatchingClaimsInChannel, + makeSelectTotalPagesInChannelSearch, + makeSelectTotalClaimsInChannelSearch, makeSelectMetadataForUri, makeSelectMetadataItemForUri, makeSelectThumbnailForUri, diff --git a/src/redux/reducers/claims.js b/src/redux/reducers/claims.js index cd3a7f1..8e6b121 100644 --- a/src/redux/reducers/claims.js +++ b/src/redux/reducers/claims.js @@ -28,7 +28,7 @@ type State = { claimSearchByQuery: { [string]: Array }, claimSearchByQueryLastPageReached: { [string]: Array }, creatingChannel: boolean, - claimsByChannel: { + paginatedClaimsByChannel: { [string]: { all: Array, pageCount: number, @@ -45,7 +45,7 @@ const reducers = {}; const defaultState = { byId: {}, claimsByUri: {}, - claimsByChannel: {}, + paginatedClaimsByChannel: {}, channelClaimCounts: {}, fetchingChannelClaims: {}, resolvingUris: [], @@ -262,10 +262,10 @@ reducers[ACTIONS.FETCH_CHANNEL_CLAIMS_COMPLETED] = (state: State, action: any): // byChannel keeps claim_search relevant results by page. If the total changes, erase it. const channelClaimCounts = Object.assign({}, state.channelClaimCounts); - const claimsByChannel = Object.assign({}, state.claimsByChannel); + const paginatedClaimsByChannel = Object.assign({}, state.paginatedClaimsByChannel); // check if count has changed - that means cached pagination will be wrong, so clear it - const previousCount = claimsByChannel[uri] && claimsByChannel[uri]['itemCount']; - const byChannel = (claimsInChannel === previousCount) ? Object.assign({}, claimsByChannel[uri]) : {}; + const previousCount = paginatedClaimsByChannel[uri] && paginatedClaimsByChannel[uri]['itemCount']; + const byChannel = (claimsInChannel === previousCount) ? Object.assign({}, paginatedClaimsByChannel[uri]) : {}; const allClaimIds = new Set(byChannel.all); const currentPageClaimIds = []; const byId = Object.assign({}, state.byId); @@ -281,19 +281,15 @@ reducers[ACTIONS.FETCH_CHANNEL_CLAIMS_COMPLETED] = (state: State, action: any): }); } - if (claimsInChannel) { - channelClaimCounts[uri] = claimsInChannel; - } - byChannel.all = allClaimIds; byChannel.pageCount = totalPages; byChannel.itemCount = claimsInChannel; byChannel[page] = currentPageClaimIds; - claimsByChannel[uri] = byChannel; + paginatedClaimsByChannel[uri] = byChannel; delete fetchingChannelClaims[uri]; return Object.assign({}, state, { - claimsByChannel, + paginatedClaimsByChannel, byId, fetchingChannelClaims, claimsByUri, diff --git a/src/redux/selectors/claims.js b/src/redux/selectors/claims.js index f953d8f..2d920a5 100644 --- a/src/redux/selectors/claims.js +++ b/src/redux/selectors/claims.js @@ -54,7 +54,7 @@ export const selectClaimsByUri = createSelector( export const selectAllClaimsByChannel = createSelector( selectState, - state => state.claimsByChannel || {} + state => state.paginatedClaimsByChannel || {} ); export const selectPendingById = createSelector( @@ -177,7 +177,7 @@ export const makeSelectFetchingChannelClaims = (uri: string) => selectAllFetchingChannelClaims, fetching => fetching && fetching[uri] ); -// this is actually the result of claim search + export const makeSelectClaimsInChannelForPage = (uri: string, page?: number) => createSelector( selectClaimsById, @@ -192,7 +192,7 @@ export const makeSelectClaimsInChannelForPage = (uri: string, page?: number) => } ); -export const makeSelectTotalMatchingClaimsInChannel = (uri: string) => +export const makeSelectTotalClaimsInChannelSearch = (uri: string) => createSelector( selectClaimsById, selectAllClaimsByChannel, @@ -202,7 +202,7 @@ export const makeSelectTotalMatchingClaimsInChannel = (uri: string) => } ); -export const makeSelectTotalMatchingPaginatedPagesInChannel = (uri: string) => +export const makeSelectTotalPagesInChannelSearch = (uri: string) => createSelector( selectClaimsById, selectAllClaimsByChannel,