maintain channel page number on tab change

This commit is contained in:
Sean Yesmunt 2019-05-14 01:12:24 -04:00
parent a8cacd13ae
commit 7bb34fc7b5
3 changed files with 11 additions and 5 deletions

View file

@ -4,6 +4,7 @@ import {
makeSelectTitleForUri, makeSelectTitleForUri,
makeSelectThumbnailForUri, makeSelectThumbnailForUri,
makeSelectCoverForUri, makeSelectCoverForUri,
selectCurrentChannelPage,
} from 'lbry-redux'; } from 'lbry-redux';
import ChannelPage from './view'; import ChannelPage from './view';
@ -12,6 +13,7 @@ const select = (state, props) => ({
thumbnail: makeSelectThumbnailForUri(props.uri)(state), thumbnail: makeSelectThumbnailForUri(props.uri)(state),
cover: makeSelectCoverForUri(props.uri)(state), cover: makeSelectCoverForUri(props.uri)(state),
channelIsMine: makeSelectClaimIsMine(props.uri)(state), channelIsMine: makeSelectClaimIsMine(props.uri)(state),
page: selectCurrentChannelPage(state),
}); });
export default connect( export default connect(

View file

@ -19,13 +19,14 @@ type Props = {
title: ?string, title: ?string,
cover: ?string, cover: ?string,
thumbnail: ?string, thumbnail: ?string,
page: number,
location: { search: string }, location: { search: string },
history: { push: string => void }, history: { push: string => void },
match: { params: { attribute: ?string } }, match: { params: { attribute: ?string } },
}; };
function ChannelPage(props: Props) { 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 { channelName, claimName, claimId } = parseURI(uri);
const { search } = location; const { search } = location;
const urlParams = new URLSearchParams(search); const urlParams = new URLSearchParams(search);
@ -37,11 +38,14 @@ function ChannelPage(props: Props) {
const tabIndex = currentView === ABOUT_PAGE ? 1 : 0; const tabIndex = currentView === ABOUT_PAGE ? 1 : 0;
const onTabChange = newTabIndex => { const onTabChange = newTabIndex => {
let url = formatLbryUriForWeb(uri); let url = formatLbryUriForWeb(uri);
let search = '?';
if (newTabIndex !== 0) { 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 ( return (

View file

@ -6491,9 +6491,9 @@ lazy-val@^1.0.3, 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#c8126ab21792d7a85e1123a2363af285a0263654: lbry-redux@lbryio/lbry-redux#02f6918238110726c0b3b4248c61a84ac0b969e3:
version "0.0.1" 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: dependencies:
proxy-polyfill "0.1.6" proxy-polyfill "0.1.6"
reselect "^3.0.0" reselect "^3.0.0"