diff --git a/src/renderer/constants/claim.js b/src/renderer/constants/claim.js index 3f5db67bf..4cf33ce09 100644 --- a/src/renderer/constants/claim.js +++ b/src/renderer/constants/claim.js @@ -2,3 +2,4 @@ export const MINIMUM_PUBLISH_BID = 0.00000001; export const CHANNEL_ANONYMOUS = 'anonymous'; export const CHANNEL_NEW = 'new'; +export const PAGE_SIZE = 20; diff --git a/src/renderer/page/channel/index.js b/src/renderer/page/channel/index.js index f0415523e..f7cbf28b0 100644 --- a/src/renderer/page/channel/index.js +++ b/src/renderer/page/channel/index.js @@ -1,15 +1,16 @@ import { connect } from 'react-redux'; import { doFetchClaimsByChannel, doFetchClaimCountByChannel } from 'redux/actions/content'; +import { PAGE_SIZE } from 'constants/claim'; import { makeSelectClaimForUri, makeSelectClaimsInChannelForCurrentPage, makeSelectFetchingChannelClaims, makeSelectCurrentParam, makeSelectClaimIsMine, + makeSelectTotalPagesForChannel, selectCurrentParams, } from 'lbry-redux'; import { doNavigate } from 'redux/actions/navigation'; -import { makeSelectTotalPagesForChannel } from 'redux/selectors/content'; import ChannelPage from './view'; const select = (state, props) => ({ @@ -18,7 +19,7 @@ const select = (state, props) => ({ fetching: makeSelectFetchingChannelClaims(props.uri)(state), page: makeSelectCurrentParam('page')(state), params: selectCurrentParams(state), - totalPages: makeSelectTotalPagesForChannel(props.uri)(state), + totalPages: makeSelectTotalPagesForChannel(props.uri, PAGE_SIZE)(state), channelIsMine: makeSelectClaimIsMine(props.uri)(state), }); diff --git a/src/renderer/redux/actions/content.js b/src/renderer/redux/actions/content.js index 94d7c680d..36e6002fe 100644 --- a/src/renderer/redux/actions/content.js +++ b/src/renderer/redux/actions/content.js @@ -1,5 +1,6 @@ // @flow import * as NOTIFICATION_TYPES from 'constants/subscriptions'; +import { PAGE_SIZE } from 'constants/claim'; import { ipcRenderer } from 'electron'; import { doAlertError } from 'redux/actions/app'; import { doNavigate } from 'redux/actions/navigation'; @@ -293,38 +294,40 @@ export function doFetchClaimsByChannel(uri, page, pageSize) { data: { uri, page }, }); - Lbry.claim_list_by_channel({ uri, page: page || 1, page_size: pageSize || 20 }).then(result => { - const claimResult = result[uri] || {}; - const { claims_in_channel: claimsInChannel, returned_page: returnedPage } = claimResult; + Lbry.claim_list_by_channel({ uri, page: page || 1, page_size: pageSize || PAGE_SIZE }).then( + result => { + const claimResult = result[uri] || {}; + const { claims_in_channel: claimsInChannel, returned_page: returnedPage } = claimResult; - if (claimsInChannel && claimsInChannel.length) { - const latest = claimsInChannel[0]; - dispatch( - setSubscriptionLatest( - { - channelName: latest.channel_name, - uri: buildURI( - { - contentName: latest.channel_name, - claimId: latest.value.publisherSignature.certificateId, - }, - false - ), - }, - buildURI({ contentName: latest.name, claimId: latest.claim_id }, false) - ) - ); + if (claimsInChannel && claimsInChannel.length) { + const latest = claimsInChannel[0]; + dispatch( + setSubscriptionLatest( + { + channelName: latest.channel_name, + uri: buildURI( + { + contentName: latest.channel_name, + claimId: latest.value.publisherSignature.certificateId, + }, + false + ), + }, + buildURI({ contentName: latest.name, claimId: latest.claim_id }, false) + ) + ); + } + + dispatch({ + type: ACTIONS.FETCH_CHANNEL_CLAIMS_COMPLETED, + data: { + uri, + claims: claimsInChannel || [], + page: returnedPage || undefined, + }, + }); } - - dispatch({ - type: ACTIONS.FETCH_CHANNEL_CLAIMS_COMPLETED, - data: { - uri, - claims: claimsInChannel || [], - page: returnedPage || undefined, - }, - }); - }); + ); }; } diff --git a/src/renderer/redux/selectors/content.js b/src/renderer/redux/selectors/content.js index bfeec666c..e55732847 100644 --- a/src/renderer/redux/selectors/content.js +++ b/src/renderer/redux/selectors/content.js @@ -14,12 +14,6 @@ export const selectChannelClaimCounts = createSelector( export const makeSelectTotalItemsForChannel = uri => createSelector(selectChannelClaimCounts, byUri => byUri && byUri[uri]); -export const makeSelectTotalPagesForChannel = uri => - createSelector( - selectChannelClaimCounts, - byUri => byUri && byUri[uri] && Math.ceil(byUri[uri] / 10) - ); - export const selectRewardContentClaimIds = createSelector( selectState, state => state.rewardedContentClaimIds @@ -52,9 +46,8 @@ export const makeSelectHistoryForPage = page => if (claimAtUri) { return { lastViewed, uri, ...claimAtUri }; - } else { - return historyItem; } + return historyItem; }); });