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_ANONYMOUS = 'anonymous';
|
||||||
export const CHANNEL_NEW = 'new';
|
export const CHANNEL_NEW = 'new';
|
||||||
|
export const PAGE_SIZE = 20;
|
||||||
|
|
|
@ -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),
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -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,38 +294,40 @@ 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(
|
||||||
const claimResult = result[uri] || {};
|
result => {
|
||||||
const { claims_in_channel: claimsInChannel, returned_page: returnedPage } = claimResult;
|
const claimResult = result[uri] || {};
|
||||||
|
const { claims_in_channel: claimsInChannel, returned_page: returnedPage } = claimResult;
|
||||||
|
|
||||||
if (claimsInChannel && claimsInChannel.length) {
|
if (claimsInChannel && claimsInChannel.length) {
|
||||||
const latest = claimsInChannel[0];
|
const latest = claimsInChannel[0];
|
||||||
dispatch(
|
dispatch(
|
||||||
setSubscriptionLatest(
|
setSubscriptionLatest(
|
||||||
{
|
{
|
||||||
channelName: latest.channel_name,
|
channelName: latest.channel_name,
|
||||||
uri: buildURI(
|
uri: buildURI(
|
||||||
{
|
{
|
||||||
contentName: latest.channel_name,
|
contentName: latest.channel_name,
|
||||||
claimId: latest.value.publisherSignature.certificateId,
|
claimId: latest.value.publisherSignature.certificateId,
|
||||||
},
|
},
|
||||||
false
|
false
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
buildURI({ contentName: latest.name, claimId: latest.claim_id }, 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 =>
|
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;
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue