@@ -156,35 +88,17 @@ const CatalogFooter = ({
interface CatalogLoadingProps {
subplebbitAddresses: string[];
hasMore: boolean;
- feedLength: number;
- weeklyFeedLength: number;
- monthlyFeedLength: number;
- yearlyFeedLength: number;
+ combinedFeedLength: number;
state: string | undefined;
subscriptionsLength: number;
- combinedFeedLength: number;
error: Error | undefined;
}
-const CatalogLoading = ({
- subplebbitAddresses,
- hasMore,
- feedLength,
- weeklyFeedLength,
- monthlyFeedLength,
- yearlyFeedLength,
- state,
- subscriptionsLength,
- combinedFeedLength,
- error,
-}: CatalogLoadingProps) => {
+const CatalogLoading = ({ subplebbitAddresses, hasMore, combinedFeedLength, state, subscriptionsLength, error }: CatalogLoadingProps) => {
const { t } = useTranslation();
const rawFeedStateString = useFeedStateString(subplebbitAddresses);
- const loadingStateString =
- rawFeedStateString || (feedLength === 0 && !(weeklyFeedLength > feedLength || monthlyFeedLength > feedLength || yearlyFeedLength > monthlyFeedLength))
- ? t('loading_feed')
- : t('looking_for_more_posts');
+ const loadingStateString = rawFeedStateString || (combinedFeedLength === 0 ? t('loading_feed') : t('looking_for_more_posts'));
return (
@@ -289,11 +203,10 @@ export interface CatalogProps {
feedCacheKey?: string;
viewType?: 'all' | 'subs' | 'mod' | 'board';
boardIdentifier?: string;
- timeFilterNameFromCache?: string;
isVisible?: boolean;
}
-const Catalog = ({ feedCacheKey, viewType, boardIdentifier: boardIdentifierProp, timeFilterNameFromCache, isVisible = true }: CatalogProps) => {
+const Catalog = ({ feedCacheKey, viewType, boardIdentifier: boardIdentifierProp, isVisible = true }: CatalogProps) => {
const { t } = useTranslation();
const location = useLocation();
const navigate = useNavigate();
@@ -316,7 +229,6 @@ const Catalog = ({ feedCacheKey, viewType, boardIdentifier: boardIdentifierProp,
return resolvedAddressFromUrl;
}, [boardIdentifierProp, directories, resolvedAddressFromUrl]);
- const boardPath = useBoardPath(subplebbitAddress);
const { filterItems, searchText, clearMatchedFilters } = useCatalogFiltersStore();
const account = useAccount();
@@ -352,10 +264,7 @@ const Catalog = ({ feedCacheKey, viewType, boardIdentifier: boardIdentifierProp,
}
}, [isInAllView, isInSubscriptionsView, isInModView, location.pathname, navigate]);
- const { timeFilterSeconds: timeFilterSecondsFromHook, timeFilterName: timeFilterNameFromHook } = useTimeFilter();
const { sortType } = useSortingStore();
- const timeFilterName = timeFilterNameFromCache || timeFilterNameFromHook;
- const timeFilterSeconds = timeFilterNameFromCache ? timeFilterNameToSeconds(timeFilterNameFromCache) : timeFilterSecondsFromHook;
// Create a stable callback for filter matching
const handleFilterMatch = useCallback((filterIndex: number, cid: string, subplebbitAddress: string) => {
@@ -380,18 +289,12 @@ const Catalog = ({ feedCacheKey, viewType, boardIdentifier: boardIdentifierProp,
? infiniteFeedPostsPerPage
: paginationFeedPostsPerPage;
- const options: any = {
+ return {
subplebbitAddresses,
sortType,
postsPerPage: catalogPostsPerPage,
filter: createCombinedFilter(filterItems, searchText, subplebbitAddress || 'all', handleFilterMatch),
};
-
- if (isInAllView || isInSubscriptionsView || isInModView) {
- options.newerThan = timeFilterSeconds;
- }
-
- return options;
}, [
subplebbitAddresses,
sortType,
@@ -401,7 +304,6 @@ const Catalog = ({ feedCacheKey, viewType, boardIdentifier: boardIdentifierProp,
effectiveInfiniteScroll,
infiniteFeedPostsPerPage,
paginationFeedPostsPerPage,
- timeFilterSeconds,
filterItems,
searchText,
subplebbitAddress,
@@ -474,36 +376,6 @@ const Catalog = ({ feedCacheKey, viewType, boardIdentifier: boardIdentifierProp,
};
// suggest the user to change time filter if there aren't enough posts
- const { feed: weeklyFeed } = useFeed({
- subplebbitAddresses,
- sortType,
- newerThan: 60 * 60 * 24 * 7,
- filter: createCombinedFilter(filterItems, searchText, subplebbitAddress || 'all', handleFilterMatch),
- });
-
- const { feed: monthlyFeed } = useFeed({
- subplebbitAddresses,
- sortType,
- newerThan: 60 * 60 * 24 * 30,
- filter: createCombinedFilter(filterItems, searchText, subplebbitAddress || 'all', handleFilterMatch),
- });
-
- const { feed: yearlyFeed } = useFeed({
- subplebbitAddresses,
- sortType,
- newerThan: 60 * 60 * 24 * 365,
- filter: createCombinedFilter(filterItems, searchText, subplebbitAddress || 'all', handleFilterMatch),
- });
-
- const [showMorePostsSuggestion, setShowMorePostsSuggestion] = useState(false);
- useEffect(() => {
- const timer = setTimeout(() => {
- setShowMorePostsSuggestion(true);
- }, 5000);
-
- return () => clearTimeout(timer);
- }, []);
-
const setResetFunction = useFeedResetStore((state) => state.setResetFunction);
useEffect(() => {
if (isVisible) {
@@ -513,12 +385,6 @@ const Catalog = ({ feedCacheKey, viewType, boardIdentifier: boardIdentifierProp,
const subplebbit = useSubplebbit({ subplebbitAddress });
const { error, shortAddress, state, title } = subplebbit || {};
- const feedLength = feed.length;
- const weeklyFeedLength = weeklyFeed.length;
- const monthlyFeedLength = monthlyFeed.length;
- const yearlyFeedLength = yearlyFeed.length;
-
- const currentTimeFilterName = timeFilterName || params?.timeFilterName;
// Memoize footer component to preserve identity across renders (Virtuoso optimization)
// Note: useFeedStateString is called inside CatalogFooter to isolate re-renders from backend state changes
@@ -528,19 +394,12 @@ const Catalog = ({ feedCacheKey, viewType, boardIdentifier: boardIdentifierProp,
),
@@ -548,19 +407,12 @@ const Catalog = ({ feedCacheKey, viewType, boardIdentifier: boardIdentifierProp,
[
subplebbitAddresses,
hasMore,
- feedLength,
cappedFeed.length,
subplebbitAddressesWithNewerPosts,
handleNewerPostsButtonClick,
isInAllView,
isInSubscriptionsView,
isInModView,
- showMorePostsSuggestion,
- weeklyFeedLength,
- monthlyFeedLength,
- yearlyFeedLength,
- boardPath,
- currentTimeFilterName,
effectiveInfiniteScroll,
],
);
@@ -603,7 +455,7 @@ const Catalog = ({ feedCacheKey, viewType, boardIdentifier: boardIdentifierProp,
const rows = useCatalogFeedRows(columnCount, processedFeed, isFeedLoaded, subplebbit);
const virtuosoRef = useRef(null);
- const virtuosoStateKey = feedCacheKey ? `${feedCacheKey}-${sortType}-${timeFilterSeconds}` : `${location.pathname}-${sortType}-${timeFilterSeconds}-catalog`;
+ const virtuosoStateKey = feedCacheKey ? `${feedCacheKey}-${sortType}` : `${location.pathname}-${sortType}-catalog`;
const navigationType = useNavigationType();
const hasBeenVisibleRef = useRef(false);
@@ -709,19 +561,12 @@ const Catalog = ({ feedCacheKey, viewType, boardIdentifier: boardIdentifierProp,
>
@@ -734,19 +579,12 @@ const Catalog = ({ feedCacheKey, viewType, boardIdentifier: boardIdentifierProp,
>
@@ -757,13 +595,9 @@ const Catalog = ({ feedCacheKey, viewType, boardIdentifier: boardIdentifierProp,