fix pagination on channel pages

This commit is contained in:
Sean Yesmunt 2019-11-19 15:34:25 -05:00
parent d7b8d6b82c
commit b089a9a953
5 changed files with 10 additions and 80 deletions

View file

@ -125,7 +125,7 @@
"imagesloaded": "^4.1.4",
"json-loader": "^0.5.4",
"lbry-format": "https://github.com/lbryio/lbry-format.git",
"lbry-redux": "lbryio/lbry-redux#f5a62363cf6d3ff33a42a4446e6df3024a7780d8",
"lbry-redux": "lbryio/lbry-redux#c30889d3392b89ffffdb5beea8534f2aa0f76b19",
"lbryinc": "lbryio/lbryinc#2aedf5a188f028f61c45bc7ed0c747a2d4ae453a",
"lint-staged": "^7.0.2",
"localforage": "^1.7.1",

View file

@ -1,7 +1,6 @@
// @flow
import React, { useEffect } from 'react';
import { parseURI } from 'lbry-redux';
import { Redirect } from 'react-router';
import BusyIndicator from 'component/common/busy-indicator';
import ChannelPage from 'page/channel';
import FilePage from 'page/file';
@ -24,7 +23,7 @@ type Props = {
function ShowPage(props: Props) {
const { isResolvingUri, resolveUri, uri, claim, blackListedOutpoints, location, title } = props;
const { channelName, channelClaimId, streamName, streamClaimId } = parseURI(uri);
const { channelName, streamName } = parseURI(uri);
const signingChannel = claim && claim.signing_channel;
const canonicalUrl = claim && claim.canonical_url;
const claimExists = claim !== null && claim !== undefined;
@ -61,13 +60,6 @@ function ShowPage(props: Props) {
};
}, [title, channelName, streamName]);
// @routinghax
if (channelName && !channelClaimId && streamName && !streamClaimId && !isResolvingUri && !claim) {
// Kinda hacky, but this is probably an old url
// Just redirect to the vanity channel
return <Redirect to={`/@${channelName}`} />;
}
let innerContent = '';
if (!claim || (claim && !claim.name)) {

View file

@ -150,11 +150,11 @@ export function doFetchClaimsByChannel(uri: string, page: number = 1, pageSize:
valid_channel_signature: true,
order_by: ['release_time'],
}).then(result => {
const { items: claimsInChannel, page: returnedPage } = result;
const { items: claims, total_items: claimsInChannel, page: returnedPage } = result;
if (claimsInChannel && claimsInChannel.length) {
if (claims && claims.length) {
if (page === 1) {
const latest = claimsInChannel[0];
const latest = claims[0];
dispatch(
setSubscriptionLatest(
{
@ -171,7 +171,8 @@ export function doFetchClaimsByChannel(uri: string, page: number = 1, pageSize:
type: ACTIONS.FETCH_CHANNEL_CLAIMS_COMPLETED,
data: {
uri,
claims: claimsInChannel || [],
claimsInChannel,
claims: claims || [],
page: returnedPage || undefined,
},
});

View file

@ -2,7 +2,7 @@
import * as ACTIONS from 'constants/action_types';
import { Lbryio, rewards, doClaimRewardType } from 'lbryinc';
import { selectUnreadByChannel } from 'redux/selectors/subscriptions';
import { parseURI, doResolveUris } from 'lbry-redux';
import { parseURI } from 'lbry-redux';
export const doSetViewMode = (viewMode: ViewMode) => (dispatch: Dispatch) =>
dispatch({
@ -10,69 +10,6 @@ export const doSetViewMode = (viewMode: ViewMode) => (dispatch: Dispatch) =>
data: viewMode,
});
export const doFetchMySubscriptions = () => (dispatch: Dispatch, getState: GetState) => {
const state: { subscriptions: SubscriptionState, settings: any } = getState();
const { subscriptions: reduxSubscriptions } = state.subscriptions;
const { share_usage_data: shareSetting } = state.settings.daemonSettings;
const isSharingData = shareSetting || IS_WEB;
if (!isSharingData && isSharingData !== undefined) {
// They aren't sharing their data, subscriptions will be handled by persisted redux state
return;
}
// most of this logic comes from scenarios where the db isn't synced with redux
// this will happen if the user stops sharing data
dispatch({ type: ACTIONS.FETCH_SUBSCRIPTIONS_START });
Lbryio.call('subscription', 'list')
.then(dbSubscriptions => {
const storedSubscriptions = dbSubscriptions || [];
// // User has no subscriptions in db or redux
if (!storedSubscriptions.length && (!reduxSubscriptions || !reduxSubscriptions.length)) {
return [];
}
// There is some mismatch between redux state and db state
// If something is in the db, but not in redux, add it to redux
// If something is in redux, but not in the db, add it to the db
if (storedSubscriptions.length !== reduxSubscriptions.length) {
const reduxSubMap = {};
const subscriptionsToReturn = reduxSubscriptions.slice();
reduxSubscriptions.forEach(sub => {
const { channelClaimId } = parseURI(sub.uri);
reduxSubMap[channelClaimId] = 1;
});
storedSubscriptions.forEach(sub => {
if (!reduxSubMap[sub.claim_id]) {
const uri = `lbry://${sub.channel_name}#${sub.claim_id}`;
subscriptionsToReturn.push({ uri, channelName: sub.channel_name });
}
});
return subscriptionsToReturn;
}
// DB is already synced, just return the subscriptions in redux
return reduxSubscriptions;
})
.then((subscriptions: Array<Subscription>) => {
dispatch({
type: ACTIONS.FETCH_SUBSCRIPTIONS_SUCCESS,
data: subscriptions,
});
dispatch(doResolveUris(subscriptions.map(({ uri }) => uri)));
})
.catch(() => {
dispatch({
type: ACTIONS.FETCH_SUBSCRIPTIONS_FAIL,
});
});
};
export const setSubscriptionLatest = (subscription: Subscription, uri: string) => (dispatch: Dispatch) =>
dispatch({
type: ACTIONS.SET_SUBSCRIPTION_LATEST,

View file

@ -7048,9 +7048,9 @@ lazy-val@^1.0.4:
yargs "^13.2.2"
zstd-codec "^0.1.1"
lbry-redux@lbryio/lbry-redux#f5a62363cf6d3ff33a42a4446e6df3024a7780d8:
lbry-redux@lbryio/lbry-redux#c30889d3392b89ffffdb5beea8534f2aa0f76b19:
version "0.0.1"
resolved "https://codeload.github.com/lbryio/lbry-redux/tar.gz/f5a62363cf6d3ff33a42a4446e6df3024a7780d8"
resolved "https://codeload.github.com/lbryio/lbry-redux/tar.gz/c30889d3392b89ffffdb5beea8534f2aa0f76b19"
dependencies:
proxy-polyfill "0.1.6"
reselect "^3.0.0"