Uses a constant for PAGE_SIZE #2089
4 changed files with 38 additions and 40 deletions
|
@ -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;
|
||||
|
|
|
@ -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),
|
||||
});
|
||||
|
||||
|
|
|
@ -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,
|
||||
},
|
||||
});
|
||||
});
|
||||
);
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
@ -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;
|
||||
});
|
||||
});
|
||||
|
||||
|
|
Loading…
Reference in a new issue