refactor(feed): remove "Newer threads available" banner

Removed the newer threads banner and refresh button from catalog and board
footers. Deleted newer_threads_available translation key from all languages.
This commit is contained in:
plebeius
2026-02-23 19:46:30 +08:00
parent 609436a0fb
commit 0ea7356523
39 changed files with 10 additions and 111 deletions
+2 -7
View File
@@ -12,18 +12,13 @@
padding: 15px 0 20px 5px;
}
.morePostsSuggestion {
color: var(--body-font-color);
padding-bottom: 5px;
}
.footer a, .newerPostsButton {
.footer a {
cursor: pointer;
text-decoration: var(--button-text-decoration);
color: var(--button-desktop-text-color);
}
.footer a:hover, .newerPostsButton:hover {
.footer a:hover {
color: var(--button-desktop-text-color-hover);
}
+3 -31
View File
@@ -3,7 +3,7 @@ import { useLocation, useNavigate, useNavigationType, useParams } from 'react-ro
import { Comment, useAccount, useAccountComments, useAccountSubplebbits, useFeed, useSubplebbit } from '@plebbit/plebbit-react-hooks';
import { useSubplebbitField } from '../../hooks/use-stable-subplebbit';
import { Virtuoso, VirtuosoHandle, StateSnapshot } from 'react-virtuoso';
import { Trans, useTranslation } from 'react-i18next';
import { useTranslation } from 'react-i18next';
import styles from './board.module.css';
import { shouldShowSnow } from '../../lib/snow';
import { useDirectoryAddresses, useDirectories, useDirectoryByAddress } from '../../hooks/use-directories';
@@ -30,8 +30,6 @@ interface BoardFooterProps {
subplebbitAddresses: string[];
hasMore: boolean;
combinedFeedLength: number;
subplebbitAddressesWithNewerPosts: string[];
onNewerPostsClick: () => void;
isInAllView: boolean;
isInSubscriptionsView: boolean;
isInModView: boolean;
@@ -49,8 +47,6 @@ const BoardFooter = ({
subplebbitAddresses,
hasMore,
combinedFeedLength,
subplebbitAddressesWithNewerPosts,
onNewerPostsClick,
isInAllView,
isInSubscriptionsView,
isInModView,
@@ -68,20 +64,7 @@ const BoardFooter = ({
footerContent = t('no_threads');
}
if (hasMore || (subplebbitAddresses && subplebbitAddresses.length === 0)) {
footerContent = (
<>
{subplebbitAddressesWithNewerPosts.length > 0 && (
<div className={styles.morePostsSuggestion}>
<Trans
i18nKey='newer_threads_available'
components={{
1: <span className={styles.newerPostsButton} onClick={onNewerPostsClick} />,
}}
/>
</div>
)}
</>
);
footerContent = null;
}
return (
<div className={styles.footer}>
@@ -162,7 +145,7 @@ const Board = ({ feedCacheKey, viewType, boardIdentifier: boardIdentifierProp, i
[subplebbitAddresses, effectiveInfiniteScroll, infiniteFeedPostsPerPage, paginationFeedPostsPerPage],
);
const { feed, hasMore, loadMore, reset, subplebbitAddressesWithNewerPosts } = useFeed(feedOptions);
const { feed, hasMore, loadMore, reset } = useFeed(feedOptions);
const { accountComments } = useAccountComments();
const feedContextKey = `${isInAllView ? 'all' : isInSubscriptionsView ? 'subs' : isInModView ? 'mod' : (subplebbitAddress ?? 'board')}-${BOARD_SORT_TYPE}-${viewType ?? 'board'}-${effectiveInfiniteScroll}`;
@@ -260,13 +243,6 @@ const Board = ({ feedCacheKey, viewType, boardIdentifier: boardIdentifierProp, i
const { error: subplebbitError, state: subplebbitState } = subplebbit || {};
const title = isInAllView ? t('all') : isInSubscriptionsView ? t('subscriptions') : isInModView ? t('mod') : subplebbitTitle;
const handleNewerPostsButtonClick = () => {
window.scrollTo({ top: 0, left: 0 });
setTimeout(() => {
reset();
}, 300);
};
// Memoize footer component to preserve identity across renders (Virtuoso optimization)
// Note: useFeedStateString is called inside BoardFooter to isolate re-renders from backend state changes
const footerComponents = useMemo(
@@ -277,8 +253,6 @@ const Board = ({ feedCacheKey, viewType, boardIdentifier: boardIdentifierProp, i
subplebbitAddresses={subplebbitAddresses}
hasMore={hasMore}
combinedFeedLength={combinedFeed.length}
subplebbitAddressesWithNewerPosts={subplebbitAddressesWithNewerPosts}
onNewerPostsClick={handleNewerPostsButtonClick}
isInAllView={isInAllView}
isInSubscriptionsView={isInSubscriptionsView}
isInModView={isInModView}
@@ -295,8 +269,6 @@ const Board = ({ feedCacheKey, viewType, boardIdentifier: boardIdentifierProp, i
subplebbitAddresses,
hasMore,
combinedFeed.length,
subplebbitAddressesWithNewerPosts,
handleNewerPostsButtonClick,
isInAllView,
isInSubscriptionsView,
isInModView,
+2 -2
View File
@@ -3,12 +3,12 @@
color: var(--post-mobile-abbr-text-color);
}
.footer a, .newerPostsButton {
.footer a {
text-decoration: var(--button-text-decoration);
color: var(--button-desktop-text-color);
}
.footer a:hover, .newerPostsButton:hover {
.footer a:hover {
color: var(--button-desktop-text-color-hover);
}
+3 -36
View File
@@ -1,6 +1,6 @@
import { useEffect, useMemo, useRef, useState, useCallback } from 'react';
import { useLocation, useNavigate, useNavigationType, useParams } from 'react-router-dom';
import { Trans, useTranslation } from 'react-i18next';
import { useTranslation } from 'react-i18next';
import { Comment, useAccount, useFeed, useSubplebbit, useAccountComments } from '@plebbit/plebbit-react-hooks';
import { Virtuoso, VirtuosoHandle, StateSnapshot } from 'react-virtuoso';
import useCatalogFeedRows from '../../hooks/use-catalog-feed-rows';
@@ -31,8 +31,6 @@ interface CatalogFooterProps {
subplebbitAddresses: string[];
hasMore: boolean;
combinedFeedLength: number;
subplebbitAddressesWithNewerPosts: string[];
onNewerPostsClick: () => void;
isInAllView: boolean;
isInSubscriptionsView: boolean;
isInModView: boolean;
@@ -47,8 +45,6 @@ const CatalogFooter = ({
subplebbitAddresses,
hasMore,
combinedFeedLength,
subplebbitAddressesWithNewerPosts,
onNewerPostsClick,
isInAllView,
isInSubscriptionsView,
isInModView,
@@ -65,16 +61,6 @@ const CatalogFooter = ({
if (hasMore || (subplebbitAddresses && subplebbitAddresses.length === 0)) {
footerContent = (
<>
{subplebbitAddressesWithNewerPosts.length > 0 && (
<div className={styles.stateString}>
<Trans
i18nKey='newer_threads_available'
components={{
1: <span className={styles.newerPostsButton} onClick={onNewerPostsClick} />,
}}
/>
</div>
)}
{showLoadingEllipsis && (
<div className={styles.stateString}>
<LoadingEllipsis string={loadingStateString} />
@@ -314,7 +300,7 @@ const Catalog = ({ feedCacheKey, viewType, boardIdentifier: boardIdentifierProp,
handleFilterMatch,
]);
const { feed, hasMore, loadMore, reset, subplebbitAddressesWithNewerPosts } = useFeed(feedOptions);
const { feed, hasMore, loadMore, reset } = useFeed(feedOptions);
const { accountComments } = useAccountComments();
const resetTriggeredRef = useRef(false);
@@ -375,13 +361,6 @@ const Catalog = ({ feedCacheKey, viewType, boardIdentifier: boardIdentifierProp,
}
}, [filteredComments, reset]);
const handleNewerPostsButtonClick = useCallback(() => {
window.scrollTo({ top: 0, left: 0 });
setTimeout(() => {
reset();
}, 300);
}, [reset]);
// suggest the user to change time filter if there aren't enough posts
const setResetFunction = useFeedResetStore((state) => state.setResetFunction);
useEffect(() => {
@@ -403,8 +382,6 @@ const Catalog = ({ feedCacheKey, viewType, boardIdentifier: boardIdentifierProp,
subplebbitAddresses={subplebbitAddresses}
hasMore={hasMore}
combinedFeedLength={cappedFeed.length}
subplebbitAddressesWithNewerPosts={subplebbitAddressesWithNewerPosts}
onNewerPostsClick={handleNewerPostsButtonClick}
isInAllView={isInAllView}
isInSubscriptionsView={isInSubscriptionsView}
isInModView={isInModView}
@@ -414,17 +391,7 @@ const Catalog = ({ feedCacheKey, viewType, boardIdentifier: boardIdentifierProp,
</>
),
}),
[
subplebbitAddresses,
hasMore,
cappedFeed.length,
subplebbitAddressesWithNewerPosts,
handleNewerPostsButtonClick,
isInAllView,
isInSubscriptionsView,
isInModView,
effectiveInfiniteScroll,
],
[subplebbitAddresses, hasMore, cappedFeed.length, isInAllView, isInSubscriptionsView, isInModView, effectiveInfiniteScroll],
);
const isFeedLoaded = feed.length > 0 || state === 'failed';