From 7bb34fc7b5ee3235d9be8ec75d560d02ee2e6207 Mon Sep 17 00:00:00 2001 From: Sean Yesmunt Date: Tue, 14 May 2019 01:12:24 -0400 Subject: [PATCH] maintain channel page number on tab change --- src/ui/page/channel/index.js | 2 ++ src/ui/page/channel/view.jsx | 10 +++++++--- yarn.lock | 4 ++-- 3 files changed, 11 insertions(+), 5 deletions(-) diff --git a/src/ui/page/channel/index.js b/src/ui/page/channel/index.js index 0974411c7..a4715823e 100644 --- a/src/ui/page/channel/index.js +++ b/src/ui/page/channel/index.js @@ -4,6 +4,7 @@ import { makeSelectTitleForUri, makeSelectThumbnailForUri, makeSelectCoverForUri, + selectCurrentChannelPage, } from 'lbry-redux'; import ChannelPage from './view'; @@ -12,6 +13,7 @@ const select = (state, props) => ({ thumbnail: makeSelectThumbnailForUri(props.uri)(state), cover: makeSelectCoverForUri(props.uri)(state), channelIsMine: makeSelectClaimIsMine(props.uri)(state), + page: selectCurrentChannelPage(state), }); export default connect( diff --git a/src/ui/page/channel/view.jsx b/src/ui/page/channel/view.jsx index 43b2fa3d3..8cc4ca472 100644 --- a/src/ui/page/channel/view.jsx +++ b/src/ui/page/channel/view.jsx @@ -19,13 +19,14 @@ type Props = { title: ?string, cover: ?string, thumbnail: ?string, + page: number, location: { search: string }, history: { push: string => void }, match: { params: { attribute: ?string } }, }; function ChannelPage(props: Props) { - const { uri, title, cover, history, location } = props; + const { uri, title, cover, history, location, page } = props; const { channelName, claimName, claimId } = parseURI(uri); const { search } = location; const urlParams = new URLSearchParams(search); @@ -37,11 +38,14 @@ function ChannelPage(props: Props) { const tabIndex = currentView === ABOUT_PAGE ? 1 : 0; const onTabChange = newTabIndex => { let url = formatLbryUriForWeb(uri); + let search = '?'; if (newTabIndex !== 0) { - url += `?${PAGE_VIEW_QUERY}=${ABOUT_PAGE}`; + search += `${PAGE_VIEW_QUERY}=${ABOUT_PAGE}`; + } else { + search += `page=${page}`; } - history.push(url); + history.push(`${url}${search}`); }; return ( diff --git a/yarn.lock b/yarn.lock index 78a16a524..e5a0fd298 100644 --- a/yarn.lock +++ b/yarn.lock @@ -6491,9 +6491,9 @@ lazy-val@^1.0.3, lazy-val@^1.0.4: yargs "^13.2.2" zstd-codec "^0.1.1" -lbry-redux@lbryio/lbry-redux#c8126ab21792d7a85e1123a2363af285a0263654: +lbry-redux@lbryio/lbry-redux#02f6918238110726c0b3b4248c61a84ac0b969e3: version "0.0.1" - resolved "https://codeload.github.com/lbryio/lbry-redux/tar.gz/c8126ab21792d7a85e1123a2363af285a0263654" + resolved "https://codeload.github.com/lbryio/lbry-redux/tar.gz/02f6918238110726c0b3b4248c61a84ac0b969e3" dependencies: proxy-polyfill "0.1.6" reselect "^3.0.0"