rename claimsByChannel to paginated...
This commit is contained in:
parent
d96aeb7e71
commit
15934866e1
4 changed files with 25 additions and 33 deletions
28
dist/bundle.es.js
vendored
28
dist/bundle.es.js
vendored
|
@ -1805,7 +1805,7 @@ const selectClaimsByUri = reselect.createSelector(selectState$2, selectClaimsByI
|
||||||
return claims;
|
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 || {});
|
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 selectAllFetchingChannelClaims = reselect.createSelector(selectState$2, state => state.fetchingChannelClaims || {});
|
||||||
|
|
||||||
const makeSelectFetchingChannelClaims = uri => reselect.createSelector(selectAllFetchingChannelClaims, fetching => fetching && fetching[uri]);
|
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 makeSelectClaimsInChannelForPage = (uri, page) => reselect.createSelector(selectClaimsById, selectAllClaimsByChannel, (byId, allClaims) => {
|
||||||
const byChannel = allClaims[uri] || {};
|
const byChannel = allClaims[uri] || {};
|
||||||
const claimIds = byChannel[page || 1];
|
const claimIds = byChannel[page || 1];
|
||||||
|
@ -1891,12 +1891,12 @@ const makeSelectClaimsInChannelForPage = (uri, page) => reselect.createSelector(
|
||||||
return claimIds.map(claimId => byId[claimId]);
|
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] || {};
|
const byChannel = allClaims[uri] || {};
|
||||||
return byChannel['itemCount'];
|
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] || {};
|
const byChannel = allClaims[uri] || {};
|
||||||
return byChannel['pageCount'];
|
return byChannel['pageCount'];
|
||||||
});
|
});
|
||||||
|
@ -3991,7 +3991,7 @@ const reducers = {};
|
||||||
const defaultState = {
|
const defaultState = {
|
||||||
byId: {},
|
byId: {},
|
||||||
claimsByUri: {},
|
claimsByUri: {},
|
||||||
claimsByChannel: {},
|
paginatedClaimsByChannel: {},
|
||||||
channelClaimCounts: {},
|
channelClaimCounts: {},
|
||||||
fetchingChannelClaims: {},
|
fetchingChannelClaims: {},
|
||||||
resolvingUris: [],
|
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.
|
// byChannel keeps claim_search relevant results by page. If the total changes, erase it.
|
||||||
const channelClaimCounts = Object.assign({}, state.channelClaimCounts);
|
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
|
// check if count has changed - that means cached pagination will be wrong, so clear it
|
||||||
const previousCount = claimsByChannel[uri] && claimsByChannel[uri]['itemCount'];
|
const previousCount = paginatedClaimsByChannel[uri] && paginatedClaimsByChannel[uri]['itemCount'];
|
||||||
const byChannel = claimsInChannel === previousCount ? Object.assign({}, claimsByChannel[uri]) : {};
|
const byChannel = claimsInChannel === previousCount ? Object.assign({}, paginatedClaimsByChannel[uri]) : {};
|
||||||
const allClaimIds = new Set(byChannel.all);
|
const allClaimIds = new Set(byChannel.all);
|
||||||
const currentPageClaimIds = [];
|
const currentPageClaimIds = [];
|
||||||
const byId = Object.assign({}, state.byId);
|
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.all = allClaimIds;
|
||||||
byChannel.pageCount = totalPages;
|
byChannel.pageCount = totalPages;
|
||||||
byChannel.itemCount = claimsInChannel;
|
byChannel.itemCount = claimsInChannel;
|
||||||
byChannel[page] = currentPageClaimIds;
|
byChannel[page] = currentPageClaimIds;
|
||||||
claimsByChannel[uri] = byChannel;
|
paginatedClaimsByChannel[uri] = byChannel;
|
||||||
delete fetchingChannelClaims[uri];
|
delete fetchingChannelClaims[uri];
|
||||||
|
|
||||||
return Object.assign({}, state, {
|
return Object.assign({}, state, {
|
||||||
claimsByChannel,
|
paginatedClaimsByChannel,
|
||||||
byId,
|
byId,
|
||||||
fetchingChannelClaims,
|
fetchingChannelClaims,
|
||||||
claimsByUri,
|
claimsByUri,
|
||||||
|
@ -5513,10 +5509,10 @@ exports.makeSelectSupportsForUri = makeSelectSupportsForUri;
|
||||||
exports.makeSelectTagsForUri = makeSelectTagsForUri;
|
exports.makeSelectTagsForUri = makeSelectTagsForUri;
|
||||||
exports.makeSelectThumbnailForUri = makeSelectThumbnailForUri;
|
exports.makeSelectThumbnailForUri = makeSelectThumbnailForUri;
|
||||||
exports.makeSelectTitleForUri = makeSelectTitleForUri;
|
exports.makeSelectTitleForUri = makeSelectTitleForUri;
|
||||||
|
exports.makeSelectTotalClaimsInChannelSearch = makeSelectTotalClaimsInChannelSearch;
|
||||||
exports.makeSelectTotalItemsForChannel = makeSelectTotalItemsForChannel;
|
exports.makeSelectTotalItemsForChannel = makeSelectTotalItemsForChannel;
|
||||||
exports.makeSelectTotalMatchingClaimsInChannel = makeSelectTotalMatchingClaimsInChannel;
|
|
||||||
exports.makeSelectTotalMatchingPaginatedPagesInChannel = makeSelectTotalMatchingPaginatedPagesInChannel;
|
|
||||||
exports.makeSelectTotalPagesForChannel = makeSelectTotalPagesForChannel;
|
exports.makeSelectTotalPagesForChannel = makeSelectTotalPagesForChannel;
|
||||||
|
exports.makeSelectTotalPagesInChannelSearch = makeSelectTotalPagesInChannelSearch;
|
||||||
exports.makeSelectUriIsStreamable = makeSelectUriIsStreamable;
|
exports.makeSelectUriIsStreamable = makeSelectUriIsStreamable;
|
||||||
exports.normalizeURI = normalizeURI;
|
exports.normalizeURI = normalizeURI;
|
||||||
exports.notificationsReducer = notificationsReducer;
|
exports.notificationsReducer = notificationsReducer;
|
||||||
|
|
|
@ -159,8 +159,8 @@ export {
|
||||||
makeSelectClaimIsMine,
|
makeSelectClaimIsMine,
|
||||||
makeSelectFetchingChannelClaims,
|
makeSelectFetchingChannelClaims,
|
||||||
makeSelectClaimsInChannelForPage,
|
makeSelectClaimsInChannelForPage,
|
||||||
makeSelectTotalMatchingPaginatedPagesInChannel,
|
makeSelectTotalPagesInChannelSearch,
|
||||||
makeSelectTotalMatchingClaimsInChannel,
|
makeSelectTotalClaimsInChannelSearch,
|
||||||
makeSelectMetadataForUri,
|
makeSelectMetadataForUri,
|
||||||
makeSelectMetadataItemForUri,
|
makeSelectMetadataItemForUri,
|
||||||
makeSelectThumbnailForUri,
|
makeSelectThumbnailForUri,
|
||||||
|
|
|
@ -28,7 +28,7 @@ type State = {
|
||||||
claimSearchByQuery: { [string]: Array<string> },
|
claimSearchByQuery: { [string]: Array<string> },
|
||||||
claimSearchByQueryLastPageReached: { [string]: Array<boolean> },
|
claimSearchByQueryLastPageReached: { [string]: Array<boolean> },
|
||||||
creatingChannel: boolean,
|
creatingChannel: boolean,
|
||||||
claimsByChannel: {
|
paginatedClaimsByChannel: {
|
||||||
[string]: {
|
[string]: {
|
||||||
all: Array<string>,
|
all: Array<string>,
|
||||||
pageCount: number,
|
pageCount: number,
|
||||||
|
@ -45,7 +45,7 @@ const reducers = {};
|
||||||
const defaultState = {
|
const defaultState = {
|
||||||
byId: {},
|
byId: {},
|
||||||
claimsByUri: {},
|
claimsByUri: {},
|
||||||
claimsByChannel: {},
|
paginatedClaimsByChannel: {},
|
||||||
channelClaimCounts: {},
|
channelClaimCounts: {},
|
||||||
fetchingChannelClaims: {},
|
fetchingChannelClaims: {},
|
||||||
resolvingUris: [],
|
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.
|
// byChannel keeps claim_search relevant results by page. If the total changes, erase it.
|
||||||
const channelClaimCounts = Object.assign({}, state.channelClaimCounts);
|
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
|
// check if count has changed - that means cached pagination will be wrong, so clear it
|
||||||
const previousCount = claimsByChannel[uri] && claimsByChannel[uri]['itemCount'];
|
const previousCount = paginatedClaimsByChannel[uri] && paginatedClaimsByChannel[uri]['itemCount'];
|
||||||
const byChannel = (claimsInChannel === previousCount) ? Object.assign({}, claimsByChannel[uri]) : {};
|
const byChannel = (claimsInChannel === previousCount) ? Object.assign({}, paginatedClaimsByChannel[uri]) : {};
|
||||||
const allClaimIds = new Set(byChannel.all);
|
const allClaimIds = new Set(byChannel.all);
|
||||||
const currentPageClaimIds = [];
|
const currentPageClaimIds = [];
|
||||||
const byId = Object.assign({}, state.byId);
|
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.all = allClaimIds;
|
||||||
byChannel.pageCount = totalPages;
|
byChannel.pageCount = totalPages;
|
||||||
byChannel.itemCount = claimsInChannel;
|
byChannel.itemCount = claimsInChannel;
|
||||||
byChannel[page] = currentPageClaimIds;
|
byChannel[page] = currentPageClaimIds;
|
||||||
claimsByChannel[uri] = byChannel;
|
paginatedClaimsByChannel[uri] = byChannel;
|
||||||
delete fetchingChannelClaims[uri];
|
delete fetchingChannelClaims[uri];
|
||||||
|
|
||||||
return Object.assign({}, state, {
|
return Object.assign({}, state, {
|
||||||
claimsByChannel,
|
paginatedClaimsByChannel,
|
||||||
byId,
|
byId,
|
||||||
fetchingChannelClaims,
|
fetchingChannelClaims,
|
||||||
claimsByUri,
|
claimsByUri,
|
||||||
|
|
|
@ -54,7 +54,7 @@ export const selectClaimsByUri = createSelector(
|
||||||
|
|
||||||
export const selectAllClaimsByChannel = createSelector(
|
export const selectAllClaimsByChannel = createSelector(
|
||||||
selectState,
|
selectState,
|
||||||
state => state.claimsByChannel || {}
|
state => state.paginatedClaimsByChannel || {}
|
||||||
);
|
);
|
||||||
|
|
||||||
export const selectPendingById = createSelector(
|
export const selectPendingById = createSelector(
|
||||||
|
@ -177,7 +177,7 @@ export const makeSelectFetchingChannelClaims = (uri: string) =>
|
||||||
selectAllFetchingChannelClaims,
|
selectAllFetchingChannelClaims,
|
||||||
fetching => fetching && fetching[uri]
|
fetching => fetching && fetching[uri]
|
||||||
);
|
);
|
||||||
// this is actually the result of claim search
|
|
||||||
export const makeSelectClaimsInChannelForPage = (uri: string, page?: number) =>
|
export const makeSelectClaimsInChannelForPage = (uri: string, page?: number) =>
|
||||||
createSelector(
|
createSelector(
|
||||||
selectClaimsById,
|
selectClaimsById,
|
||||||
|
@ -192,7 +192,7 @@ export const makeSelectClaimsInChannelForPage = (uri: string, page?: number) =>
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
export const makeSelectTotalMatchingClaimsInChannel = (uri: string) =>
|
export const makeSelectTotalClaimsInChannelSearch = (uri: string) =>
|
||||||
createSelector(
|
createSelector(
|
||||||
selectClaimsById,
|
selectClaimsById,
|
||||||
selectAllClaimsByChannel,
|
selectAllClaimsByChannel,
|
||||||
|
@ -202,7 +202,7 @@ export const makeSelectTotalMatchingClaimsInChannel = (uri: string) =>
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
export const makeSelectTotalMatchingPaginatedPagesInChannel = (uri: string) =>
|
export const makeSelectTotalPagesInChannelSearch = (uri: string) =>
|
||||||
createSelector(
|
createSelector(
|
||||||
selectClaimsById,
|
selectClaimsById,
|
||||||
selectAllClaimsByChannel,
|
selectAllClaimsByChannel,
|
||||||
|
|
Loading…
Reference in a new issue