From b089a9a953f9a9950d00a14e0ea6378d30816861 Mon Sep 17 00:00:00 2001 From: Sean Yesmunt Date: Tue, 19 Nov 2019 15:34:25 -0500 Subject: [PATCH] fix pagination on channel pages --- package.json | 2 +- ui/page/show/view.jsx | 10 +---- ui/redux/actions/content.js | 9 +++-- ui/redux/actions/subscriptions.js | 65 +------------------------------ yarn.lock | 4 +- 5 files changed, 10 insertions(+), 80 deletions(-) diff --git a/package.json b/package.json index 80b9e548b..0c765a632 100644 --- a/package.json +++ b/package.json @@ -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", diff --git a/ui/page/show/view.jsx b/ui/page/show/view.jsx index 3beaab329..f7f71d049 100644 --- a/ui/page/show/view.jsx +++ b/ui/page/show/view.jsx @@ -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 ; - } - let innerContent = ''; if (!claim || (claim && !claim.name)) { diff --git a/ui/redux/actions/content.js b/ui/redux/actions/content.js index e1e6eb3da..668ae08b9 100644 --- a/ui/redux/actions/content.js +++ b/ui/redux/actions/content.js @@ -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, }, }); diff --git a/ui/redux/actions/subscriptions.js b/ui/redux/actions/subscriptions.js index 71e0e9885..470db1f39 100644 --- a/ui/redux/actions/subscriptions.js +++ b/ui/redux/actions/subscriptions.js @@ -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) => { - 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, diff --git a/yarn.lock b/yarn.lock index 5eaa8c408..fdc20f2cb 100644 --- a/yarn.lock +++ b/yarn.lock @@ -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"