fix pagination on channel pages
This commit is contained in:
parent
d7b8d6b82c
commit
b089a9a953
5 changed files with 10 additions and 80 deletions
|
@ -125,7 +125,7 @@
|
||||||
"imagesloaded": "^4.1.4",
|
"imagesloaded": "^4.1.4",
|
||||||
"json-loader": "^0.5.4",
|
"json-loader": "^0.5.4",
|
||||||
"lbry-format": "https://github.com/lbryio/lbry-format.git",
|
"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",
|
"lbryinc": "lbryio/lbryinc#2aedf5a188f028f61c45bc7ed0c747a2d4ae453a",
|
||||||
"lint-staged": "^7.0.2",
|
"lint-staged": "^7.0.2",
|
||||||
"localforage": "^1.7.1",
|
"localforage": "^1.7.1",
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
// @flow
|
// @flow
|
||||||
import React, { useEffect } from 'react';
|
import React, { useEffect } from 'react';
|
||||||
import { parseURI } from 'lbry-redux';
|
import { parseURI } from 'lbry-redux';
|
||||||
import { Redirect } from 'react-router';
|
|
||||||
import BusyIndicator from 'component/common/busy-indicator';
|
import BusyIndicator from 'component/common/busy-indicator';
|
||||||
import ChannelPage from 'page/channel';
|
import ChannelPage from 'page/channel';
|
||||||
import FilePage from 'page/file';
|
import FilePage from 'page/file';
|
||||||
|
@ -24,7 +23,7 @@ type Props = {
|
||||||
|
|
||||||
function ShowPage(props: Props) {
|
function ShowPage(props: Props) {
|
||||||
const { isResolvingUri, resolveUri, uri, claim, blackListedOutpoints, location, title } = 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 signingChannel = claim && claim.signing_channel;
|
||||||
const canonicalUrl = claim && claim.canonical_url;
|
const canonicalUrl = claim && claim.canonical_url;
|
||||||
const claimExists = claim !== null && claim !== undefined;
|
const claimExists = claim !== null && claim !== undefined;
|
||||||
|
@ -61,13 +60,6 @@ function ShowPage(props: Props) {
|
||||||
};
|
};
|
||||||
}, [title, channelName, streamName]);
|
}, [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 = '';
|
let innerContent = '';
|
||||||
|
|
||||||
if (!claim || (claim && !claim.name)) {
|
if (!claim || (claim && !claim.name)) {
|
||||||
|
|
|
@ -150,11 +150,11 @@ export function doFetchClaimsByChannel(uri: string, page: number = 1, pageSize:
|
||||||
valid_channel_signature: true,
|
valid_channel_signature: true,
|
||||||
order_by: ['release_time'],
|
order_by: ['release_time'],
|
||||||
}).then(result => {
|
}).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) {
|
if (page === 1) {
|
||||||
const latest = claimsInChannel[0];
|
const latest = claims[0];
|
||||||
dispatch(
|
dispatch(
|
||||||
setSubscriptionLatest(
|
setSubscriptionLatest(
|
||||||
{
|
{
|
||||||
|
@ -171,7 +171,8 @@ export function doFetchClaimsByChannel(uri: string, page: number = 1, pageSize:
|
||||||
type: ACTIONS.FETCH_CHANNEL_CLAIMS_COMPLETED,
|
type: ACTIONS.FETCH_CHANNEL_CLAIMS_COMPLETED,
|
||||||
data: {
|
data: {
|
||||||
uri,
|
uri,
|
||||||
claims: claimsInChannel || [],
|
claimsInChannel,
|
||||||
|
claims: claims || [],
|
||||||
page: returnedPage || undefined,
|
page: returnedPage || undefined,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
import * as ACTIONS from 'constants/action_types';
|
import * as ACTIONS from 'constants/action_types';
|
||||||
import { Lbryio, rewards, doClaimRewardType } from 'lbryinc';
|
import { Lbryio, rewards, doClaimRewardType } from 'lbryinc';
|
||||||
import { selectUnreadByChannel } from 'redux/selectors/subscriptions';
|
import { selectUnreadByChannel } from 'redux/selectors/subscriptions';
|
||||||
import { parseURI, doResolveUris } from 'lbry-redux';
|
import { parseURI } from 'lbry-redux';
|
||||||
|
|
||||||
export const doSetViewMode = (viewMode: ViewMode) => (dispatch: Dispatch) =>
|
export const doSetViewMode = (viewMode: ViewMode) => (dispatch: Dispatch) =>
|
||||||
dispatch({
|
dispatch({
|
||||||
|
@ -10,69 +10,6 @@ export const doSetViewMode = (viewMode: ViewMode) => (dispatch: Dispatch) =>
|
||||||
data: viewMode,
|
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) =>
|
export const setSubscriptionLatest = (subscription: Subscription, uri: string) => (dispatch: Dispatch) =>
|
||||||
dispatch({
|
dispatch({
|
||||||
type: ACTIONS.SET_SUBSCRIPTION_LATEST,
|
type: ACTIONS.SET_SUBSCRIPTION_LATEST,
|
||||||
|
|
|
@ -7048,9 +7048,9 @@ lazy-val@^1.0.4:
|
||||||
yargs "^13.2.2"
|
yargs "^13.2.2"
|
||||||
zstd-codec "^0.1.1"
|
zstd-codec "^0.1.1"
|
||||||
|
|
||||||
lbry-redux@lbryio/lbry-redux#f5a62363cf6d3ff33a42a4446e6df3024a7780d8:
|
lbry-redux@lbryio/lbry-redux#c30889d3392b89ffffdb5beea8534f2aa0f76b19:
|
||||||
version "0.0.1"
|
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:
|
dependencies:
|
||||||
proxy-polyfill "0.1.6"
|
proxy-polyfill "0.1.6"
|
||||||
reselect "^3.0.0"
|
reselect "^3.0.0"
|
||||||
|
|
Loading…
Add table
Reference in a new issue