From 322005223e9552b094e71f81d28594a0c3bdc27d Mon Sep 17 00:00:00 2001 From: Sean Yesmunt Date: Wed, 11 Sep 2019 14:29:20 -0400 Subject: [PATCH] fix: reset back to top of infinite list on refresh (but keep scroll state on back navigation --- src/ui/component/claimListDiscover/view.jsx | 11 ++++------- static/locales/en.json | 21 +++++++++++++++++++-- 2 files changed, 23 insertions(+), 9 deletions(-) diff --git a/src/ui/component/claimListDiscover/view.jsx b/src/ui/component/claimListDiscover/view.jsx index 713d9feaf..869313385 100644 --- a/src/ui/component/claimListDiscover/view.jsx +++ b/src/ui/component/claimListDiscover/view.jsx @@ -1,6 +1,6 @@ // @flow import type { Node } from 'react'; -import React, { Fragment, useEffect } from 'react'; +import React, { Fragment, useEffect, useState } from 'react'; import { withRouter } from 'react-router'; import { createNormalizedClaimSearchKey, MATURE_TAGS } from 'lbry-redux'; import { FormField } from 'component/common/form'; @@ -9,7 +9,6 @@ import moment from 'moment'; import ClaimList from 'component/claimList'; import Tag from 'component/tag'; import ClaimPreview from 'component/claimPreview'; -import { updateQueryParam } from 'util/query-params'; import { toCapitalCase } from 'util/string'; const PAGE_SIZE = 20; @@ -64,14 +63,13 @@ function ClaimListDiscover(props: Props) { hiddenUris, } = props; const didNavigateForward = history.action === 'PUSH'; - const { search, pathname } = location; + const { search } = location; const urlParams = new URLSearchParams(search); const personalSort = urlParams.get('sort') || SEARCH_SORT_YOU; const typeSort = urlParams.get('type') || TYPE_TRENDING; const timeSort = urlParams.get('time') || TIME_WEEK; - const page = Number(urlParams.get('page')) || 1; + const [page, setPage] = useState(1); const tagsInUrl = urlParams.get('t') || ''; - const url = `${pathname}${search}`; const options: { page_size: number, page: number, @@ -163,8 +161,7 @@ function ClaimListDiscover(props: Props) { function handleScrollBottom() { if (!loading) { - const uri = updateQueryParam(url, 'page', page + 1); - history.replace(uri); + setPage(page + 1); } } diff --git a/static/locales/en.json b/static/locales/en.json index 30dd04347..02d66dbb4 100644 --- a/static/locales/en.json +++ b/static/locales/en.json @@ -684,5 +684,22 @@ "The viewer doesn't support this file type. See more info below.": "The viewer doesn't support this file type. See more info below.", "Catching up...": "Catching up...", "%s blocks behind": "%s blocks behind", - "Support this creator": "Support this creator" -} + "Support this creator": "Support this creator", + "Network and Data Settings": "Network and Data Settings", + "Save all viewed content to your downloads directory": "Save all viewed content to your downloads directory", + "Paid content and some file types are saved by default. Changing this setting will not affect previously downloaded content.": "Paid content and some file types are saved by default. Changing this setting will not affect previously downloaded content.", + "Save hosting data to help the LBRY network": "Save hosting data to help the LBRY network", + "If disabled, LBRY will be very sad and you won't be helping improve the network.": "If disabled, LBRY will be very sad and you won't be helping improve the network.", + "Floating video player": "Floating video player", + "Keep content playing in the corner when navigating to a different page.": "Keep content playing in the corner when navigating to a different page.", + "Blocked Channels": "Blocked Channels", + "blocked": "blocked", + "channels": "channels", + "Manage": "Manage", + "Automatic dark mode": "Automatic dark mode", + "Hide wallet balance in header": "Hide wallet balance in header", + "Max Connections": "Max Connections", + "For users with good bandwidth, try a higher value to improve streaming and download speeds. Low bandwidth users may benefit from a lower setting. Default is 4.": "For users with good bandwidth, try a higher value to improve streaming and download speeds. Low bandwidth users may benefit from a lower setting. Default is 4.", + "This will clear the application cache. Your wallet will not be affected. Currently, followed tags and blocked channels will be cleared.": "This will clear the application cache. Your wallet will not be affected. Currently, followed tags and blocked channels will be cleared.", + "Show All": "Show All" +} \ No newline at end of file