fix pagination of channels
This commit is contained in:
parent
7e6c55c605
commit
a31e064c3e
6 changed files with 56 additions and 13 deletions
|
@ -20,7 +20,7 @@
|
|||
"electron-rebuild": "^1.5.11"
|
||||
},
|
||||
"lbrySettings": {
|
||||
"lbrynetDaemonVersion": "0.15.0",
|
||||
"lbrynetDaemonVersion": "0.15.1",
|
||||
"lbrynetDaemonUrlTemplate": "https://github.com/lbryio/lbry/releases/download/vDAEMONVER/lbrynet-daemon-vDAEMONVER-OSNAME.zip"
|
||||
},
|
||||
"license": "MIT"
|
||||
|
|
|
@ -365,9 +365,6 @@ export function doFetchClaimsByChannel(uri, page) {
|
|||
lbry.claim_list_by_channel({ uri, page }).then(result => {
|
||||
const claimResult = result[uri],
|
||||
claims = claimResult ? claimResult.claims_in_channel : [],
|
||||
totalPages = claimResult
|
||||
? claimResult.claims_in_channel_pages
|
||||
: undefined,
|
||||
currentPage = claimResult ? claimResult.returned_page : undefined;
|
||||
|
||||
dispatch({
|
||||
|
@ -375,7 +372,6 @@ export function doFetchClaimsByChannel(uri, page) {
|
|||
data: {
|
||||
uri,
|
||||
claims,
|
||||
totalPages,
|
||||
page: currentPage,
|
||||
},
|
||||
});
|
||||
|
@ -383,6 +379,28 @@ export function doFetchClaimsByChannel(uri, page) {
|
|||
};
|
||||
}
|
||||
|
||||
export function doFetchClaimCountByChannel(uri) {
|
||||
return function(dispatch, getState) {
|
||||
dispatch({
|
||||
type: types.FETCH_CHANNEL_CLAIM_COUNT_STARTED,
|
||||
data: { uri },
|
||||
});
|
||||
|
||||
lbry.claim_list_by_channel({ uri }).then(result => {
|
||||
const claimResult = result[uri],
|
||||
totalClaims = claimResult ? claimResult.claims_in_channel : 0;
|
||||
|
||||
dispatch({
|
||||
type: types.FETCH_CHANNEL_CLAIM_COUNT_COMPLETED,
|
||||
data: {
|
||||
uri,
|
||||
totalClaims,
|
||||
},
|
||||
});
|
||||
});
|
||||
};
|
||||
}
|
||||
|
||||
export function doFetchClaimListMine() {
|
||||
return function(dispatch, getState) {
|
||||
dispatch({
|
||||
|
|
|
@ -45,6 +45,10 @@ export const RESOLVE_URI_COMPLETED = "RESOLVE_URI_COMPLETED";
|
|||
export const RESOLVE_URI_CANCELED = "RESOLVE_URI_CANCELED";
|
||||
export const FETCH_CHANNEL_CLAIMS_STARTED = "FETCH_CHANNEL_CLAIMS_STARTED";
|
||||
export const FETCH_CHANNEL_CLAIMS_COMPLETED = "FETCH_CHANNEL_CLAIMS_COMPLETED";
|
||||
export const FETCH_CHANNEL_CLAIM_COUNT_STARTED =
|
||||
"FETCH_CHANNEL_CLAIM_COUNT_STARTED";
|
||||
export const FETCH_CHANNEL_CLAIM_COUNT_COMPLETED =
|
||||
"FETCH_CHANNEL_CLAIM_COUNT_COMPLETED";
|
||||
export const FETCH_CLAIM_LIST_MINE_STARTED = "FETCH_CLAIM_LIST_MINE_STARTED";
|
||||
export const FETCH_CLAIM_LIST_MINE_COMPLETED =
|
||||
"FETCH_CLAIM_LIST_MINE_COMPLETED";
|
||||
|
|
|
@ -1,6 +1,9 @@
|
|||
import React from "react";
|
||||
import { connect } from "react-redux";
|
||||
import { doFetchClaimsByChannel } from "actions/content";
|
||||
import {
|
||||
doFetchClaimsByChannel,
|
||||
doFetchClaimCountByChannel,
|
||||
} from "actions/content";
|
||||
import {
|
||||
makeSelectClaimForUri,
|
||||
makeSelectClaimsInChannelForCurrentPage,
|
||||
|
@ -30,6 +33,7 @@ const makeSelect = () => {
|
|||
|
||||
const perform = dispatch => ({
|
||||
fetchClaims: (uri, page) => dispatch(doFetchClaimsByChannel(uri, page)),
|
||||
fetchClaimCount: uri => dispatch(doFetchClaimCountByChannel(uri)),
|
||||
navigate: (path, params) => dispatch(doNavigate(path, params)),
|
||||
});
|
||||
|
||||
|
|
|
@ -7,18 +7,23 @@ import ReactPaginate from "react-paginate";
|
|||
|
||||
class ChannelPage extends React.PureComponent {
|
||||
componentDidMount() {
|
||||
const { uri, params, fetchClaims } = this.props;
|
||||
const { uri, params, fetchClaims, fetchClaimCount } = this.props;
|
||||
|
||||
fetchClaims(uri, params.page || 1);
|
||||
fetchClaimCount(uri);
|
||||
}
|
||||
|
||||
componentWillReceiveProps(nextProps) {
|
||||
const { params, fetching, fetchClaims } = this.props;
|
||||
const { params, fetching, fetchClaims, fetchClaimCount } = this.props;
|
||||
const nextParams = nextProps.params;
|
||||
|
||||
if (fetching !== nextParams.page && params.page !== nextParams.page)
|
||||
if (fetching !== nextParams.page && params.page !== nextParams.page) {
|
||||
fetchClaims(nextProps.uri, nextParams.page);
|
||||
}
|
||||
if (nextProps.uri != this.props.uri) {
|
||||
fetchClaimCount(uri);
|
||||
}
|
||||
}
|
||||
|
||||
changePage(pageNumber) {
|
||||
const { params, currentPage } = this.props;
|
||||
|
|
|
@ -3,6 +3,7 @@ import * as types from "constants/action_types";
|
|||
const reducers = {};
|
||||
const defaultState = {
|
||||
rewardedContentClaimIds: [],
|
||||
channelPages: {},
|
||||
};
|
||||
|
||||
reducers[types.FETCH_FEATURED_CONTENT_STARTED] = function(state, action) {
|
||||
|
@ -57,11 +58,22 @@ reducers[types.RESOLVE_URI_CANCELED] = reducers[
|
|||
});
|
||||
};
|
||||
|
||||
reducers[types.FETCH_CHANNEL_CLAIMS_COMPLETED] = function(state, action) {
|
||||
const channelPages = Object.assign({}, state.channelPages);
|
||||
const { uri, totalPages } = action.data;
|
||||
// reducers[types.FETCH_CHANNEL_CLAIMS_COMPLETED] = function(state, action) {
|
||||
// const channelPages = Object.assign({}, state.channelPages);
|
||||
// const { uri, claims } = action.data;
|
||||
//
|
||||
// channelPages[uri] = totalPages;
|
||||
//
|
||||
// return Object.assign({}, state, {
|
||||
// channelPages,
|
||||
// });
|
||||
// };
|
||||
|
||||
channelPages[uri] = totalPages;
|
||||
reducers[types.FETCH_CHANNEL_CLAIM_COUNT_COMPLETED] = function(state, action) {
|
||||
const channelPages = Object.assign({}, state.channelPages);
|
||||
const { uri, totalClaims } = action.data;
|
||||
|
||||
channelPages[uri] = totalClaims / 10;
|
||||
|
||||
return Object.assign({}, state, {
|
||||
channelPages,
|
||||
|
|
Loading…
Reference in a new issue