Uses a constant for PAGE_SIZE #2089

Merged
jessopb merged 2 commits from pageSize into master 2018-11-05 16:22:47 +01:00
4 changed files with 38 additions and 40 deletions
Showing only changes of commit bf86974ec2 - Show all commits

View file

@ -2,3 +2,4 @@ export const MINIMUM_PUBLISH_BID = 0.00000001;
export const CHANNEL_ANONYMOUS = 'anonymous'; export const CHANNEL_ANONYMOUS = 'anonymous';
export const CHANNEL_NEW = 'new'; export const CHANNEL_NEW = 'new';
export const PAGE_SIZE = 20;

View file

@ -1,15 +1,16 @@
import { connect } from 'react-redux'; import { connect } from 'react-redux';
import { doFetchClaimsByChannel, doFetchClaimCountByChannel } from 'redux/actions/content'; import { doFetchClaimsByChannel, doFetchClaimCountByChannel } from 'redux/actions/content';
import { PAGE_SIZE } from 'constants/claim';
import { import {
makeSelectClaimForUri, makeSelectClaimForUri,
makeSelectClaimsInChannelForCurrentPage, makeSelectClaimsInChannelForCurrentPage,
makeSelectFetchingChannelClaims, makeSelectFetchingChannelClaims,
makeSelectCurrentParam, makeSelectCurrentParam,
makeSelectClaimIsMine, makeSelectClaimIsMine,
makeSelectTotalPagesForChannel,
selectCurrentParams, selectCurrentParams,
} from 'lbry-redux'; } from 'lbry-redux';
import { doNavigate } from 'redux/actions/navigation'; import { doNavigate } from 'redux/actions/navigation';
import { makeSelectTotalPagesForChannel } from 'redux/selectors/content';
import ChannelPage from './view'; import ChannelPage from './view';
const select = (state, props) => ({ const select = (state, props) => ({
@ -18,7 +19,7 @@ const select = (state, props) => ({
fetching: makeSelectFetchingChannelClaims(props.uri)(state), fetching: makeSelectFetchingChannelClaims(props.uri)(state),
page: makeSelectCurrentParam('page')(state), page: makeSelectCurrentParam('page')(state),
params: selectCurrentParams(state), params: selectCurrentParams(state),
totalPages: makeSelectTotalPagesForChannel(props.uri)(state), totalPages: makeSelectTotalPagesForChannel(props.uri, PAGE_SIZE)(state),
channelIsMine: makeSelectClaimIsMine(props.uri)(state), channelIsMine: makeSelectClaimIsMine(props.uri)(state),
}); });

View file

@ -1,5 +1,6 @@
// @flow // @flow
import * as NOTIFICATION_TYPES from 'constants/subscriptions'; import * as NOTIFICATION_TYPES from 'constants/subscriptions';
import { PAGE_SIZE } from 'constants/claim';
import { ipcRenderer } from 'electron'; import { ipcRenderer } from 'electron';
import { doAlertError } from 'redux/actions/app'; import { doAlertError } from 'redux/actions/app';
import { doNavigate } from 'redux/actions/navigation'; import { doNavigate } from 'redux/actions/navigation';
@ -293,7 +294,8 @@ export function doFetchClaimsByChannel(uri, page, pageSize) {
data: { uri, page }, data: { uri, page },
}); });
Lbry.claim_list_by_channel({ uri, page: page || 1, page_size: pageSize || 20 }).then(result => { Lbry.claim_list_by_channel({ uri, page: page || 1, page_size: pageSize || PAGE_SIZE }).then(
result => {
const claimResult = result[uri] || {}; const claimResult = result[uri] || {};
const { claims_in_channel: claimsInChannel, returned_page: returnedPage } = claimResult; const { claims_in_channel: claimsInChannel, returned_page: returnedPage } = claimResult;
@ -324,7 +326,8 @@ export function doFetchClaimsByChannel(uri, page, pageSize) {
page: returnedPage || undefined, page: returnedPage || undefined,
}, },
}); });
}); }
);
}; };
} }

View file

@ -14,12 +14,6 @@ export const selectChannelClaimCounts = createSelector(
export const makeSelectTotalItemsForChannel = uri => export const makeSelectTotalItemsForChannel = uri =>
createSelector(selectChannelClaimCounts, byUri => byUri && byUri[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( export const selectRewardContentClaimIds = createSelector(
selectState, selectState,
state => state.rewardedContentClaimIds state => state.rewardedContentClaimIds
@ -52,9 +46,8 @@ export const makeSelectHistoryForPage = page =>
if (claimAtUri) { if (claimAtUri) {
return { lastViewed, uri, ...claimAtUri }; return { lastViewed, uri, ...claimAtUri };
} else {
return historyItem;
} }
return historyItem;
}); });
}); });