From be38ed784c75a02cce13df7a2c9bbef60aa55eb4 Mon Sep 17 00:00:00 2001 From: mgabdev <> Date: Wed, 13 Jan 2021 22:49:00 -0500 Subject: [PATCH] Added MIN_UNAUTHENTICATED_PAGES for pagination of group, explore timelines MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit • Added: - MIN_UNAUTHENTICATED_PAGES for pagination of group, explore timelines --- app/javascript/gabsocial/constants.js | 2 ++ app/javascript/gabsocial/features/explore_timeline.js | 7 ++++--- .../gabsocial/features/group_collection_timeline.js | 7 ++++--- app/javascript/gabsocial/features/group_timeline.js | 7 ++++--- 4 files changed, 14 insertions(+), 9 deletions(-) diff --git a/app/javascript/gabsocial/constants.js b/app/javascript/gabsocial/constants.js index 72b9f046..0ecaf4f6 100644 --- a/app/javascript/gabsocial/constants.js +++ b/app/javascript/gabsocial/constants.js @@ -13,6 +13,8 @@ export const BREAKPOINT_EXTRA_SMALL = 992 export const MOUSE_IDLE_DELAY = 300 +export const MIN_UNAUTHENTICATED_PAGES = 1 + export const LAZY_LOAD_SCROLL_OFFSET = 50 export const ALLOWED_AROUND_SHORT_CODE = '><\u0085\u0020\u00a0\u1680\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200a\u202f\u205f\u3000\u2028\u2029\u0009\u000a\u000b\u000c\u000d' diff --git a/app/javascript/gabsocial/features/explore_timeline.js b/app/javascript/gabsocial/features/explore_timeline.js index 1d5de9ba..ac7c5832 100644 --- a/app/javascript/gabsocial/features/explore_timeline.js +++ b/app/javascript/gabsocial/features/explore_timeline.js @@ -12,6 +12,7 @@ import { setGroupTimelineSort, } from '../actions/groups' import { + MIN_UNAUTHENTICATED_PAGES, GROUP_TIMELINE_SORTING_TYPE_HOT, GROUP_TIMELINE_SORTING_TYPE_NEWEST, } from '../constants' @@ -24,7 +25,7 @@ class ExploreTimeline extends React.PureComponent { state = { //keep track of page loads for if no user, - //only allow 2 page loads before showing sign up msg + //only allow MIN_UNAUTHENTICATED_PAGES page loads before showing sign up msg page: 1, } @@ -58,7 +59,7 @@ class ExploreTimeline extends React.PureComponent { const { page } = this.state const newPage = !!maxId ? this.state.page + 1 : 1 - if (!!maxId && !me && page >= 2) return false + if (!!maxId && !me && page >= MIN_UNAUTHENTICATED_PAGES) return false this.setState({ page: newPage }) const sortBy = getSortBy(sortByValue, sortByTopValue) @@ -71,7 +72,7 @@ class ExploreTimeline extends React.PureComponent { const { intl } = this.props const { page } = this.state - const canLoadMore = page < 2 && !me || !!me + const canLoadMore = page < MIN_UNAUTHENTICATED_PAGES && !me || !!me return ( diff --git a/app/javascript/gabsocial/features/group_collection_timeline.js b/app/javascript/gabsocial/features/group_collection_timeline.js index 28c0cca2..e574a758 100644 --- a/app/javascript/gabsocial/features/group_collection_timeline.js +++ b/app/javascript/gabsocial/features/group_collection_timeline.js @@ -12,6 +12,7 @@ import { setGroupTimelineSort, } from '../actions/groups' import { + MIN_UNAUTHENTICATED_PAGES, GROUP_TIMELINE_SORTING_TYPE_HOT, GROUP_TIMELINE_SORTING_TYPE_NEWEST, } from '../constants' @@ -25,7 +26,7 @@ class GroupCollectionTimeline extends React.PureComponent { state = { //keep track of page loads for if no user, - //only allow 2 page loads before showing sign up msg + //only allow MIN_UNAUTHENTICATED_PAGES page loads before showing sign up msg page: 1, } @@ -64,7 +65,7 @@ class GroupCollectionTimeline extends React.PureComponent { const { page } = this.state const newPage = !!maxId ? this.state.page + 1 : 1 - if (!!maxId && !me && page >= 2) return false + if (!!maxId && !me && page >= MIN_UNAUTHENTICATED_PAGES) return false this.setState({ page: newPage }) const sortBy = getSortBy(sortByValue, sortByTopValue) @@ -90,7 +91,7 @@ class GroupCollectionTimeline extends React.PureComponent { ) : intl.formatMessage(messages.empty) - const canLoadMore = page < 2 && !me || !!me + const canLoadMore = page < MIN_UNAUTHENTICATED_PAGES && !me || !!me return ( diff --git a/app/javascript/gabsocial/features/group_timeline.js b/app/javascript/gabsocial/features/group_timeline.js index 31b3299b..efa48931 100644 --- a/app/javascript/gabsocial/features/group_timeline.js +++ b/app/javascript/gabsocial/features/group_timeline.js @@ -16,6 +16,7 @@ import { setGroupTimelineSort, } from '../actions/groups' import { + MIN_UNAUTHENTICATED_PAGES, GROUP_TIMELINE_SORTING_TYPE_NEWEST, } from '../constants' import StatusList from '../components/status_list' @@ -26,7 +27,7 @@ class GroupTimeline extends ImmutablePureComponent { state = { //keep track of page loads for if no user, - //only allow 2 page loads before showing sign up msg + //only allow MIN_UNAUTHENTICATED_PAGES page loads before showing sign up msg page: 1, } @@ -75,7 +76,7 @@ class GroupTimeline extends ImmutablePureComponent { const { page } = this.state const newPage = !!maxId ? this.state.page + 1 : 1 - if (!!maxId && !me && page >= 2) return false + if (!!maxId && !me && page >= MIN_UNAUTHENTICATED_PAGES) return false this.setState({ page: newPage }) const sortBy = getSortBy(sortByValue, sortByTopValue) @@ -102,7 +103,7 @@ class GroupTimeline extends ImmutablePureComponent { return } - const canLoadMore = page < 2 && !me || !!me + const canLoadMore = page < MIN_UNAUTHENTICATED_PAGES && !me || !!me return (