2026-04-03 15:51:57 +07:00
|
|
|
import { useDeferredValue, useEffect, useMemo, useRef, useCallback, useLayoutEffect } from 'react';
|
2026-02-22 15:57:42 +08:00
|
|
|
import { useLocation, useNavigate, useNavigationType, useParams } from 'react-router-dom';
|
2026-02-23 19:46:30 +08:00
|
|
|
import { useTranslation } from 'react-i18next';
|
2026-03-13 13:25:10 +08:00
|
|
|
import { Comment, useAccount, useCommunity, useFeed, useAccountComments } from '@bitsocialnet/bitsocial-react-hooks';
|
2024-04-12 14:28:06 +02:00
|
|
|
import { Virtuoso, VirtuosoHandle, StateSnapshot } from 'react-virtuoso';
|
2026-02-21 13:14:50 +08:00
|
|
|
import { useDirectories, useDirectoryByAddress } from '../../hooks/use-directories';
|
2026-04-15 12:51:21 +07:00
|
|
|
import { useCommunityIdentifier, useCommunityIdentifiers } from '../../hooks/use-community-identifiers';
|
2026-02-21 13:14:50 +08:00
|
|
|
import { useBoardFeedPageSize } from '../../hooks/use-board-feed-page-size';
|
2026-01-28 16:51:27 +08:00
|
|
|
import { useFilteredDirectoryAddresses } from '../../hooks/use-filtered-directory-addresses';
|
2026-03-13 13:25:10 +08:00
|
|
|
import { useResolvedCommunityAddress } from '../../hooks/use-resolved-community-address';
|
2025-02-28 23:36:33 +01:00
|
|
|
import { useFeedStateString } from '../../hooks/use-state-string';
|
2026-04-02 19:45:55 +07:00
|
|
|
import useIsMobile from '../../hooks/use-is-mobile';
|
2024-04-12 14:28:06 +02:00
|
|
|
import useWindowWidth from '../../hooks/use-window-width';
|
2024-08-03 13:21:09 +02:00
|
|
|
import useCatalogStyleStore from '../../stores/use-catalog-style-store';
|
2024-05-31 10:41:44 +02:00
|
|
|
import useFeedResetStore from '../../stores/use-feed-reset-store';
|
2024-06-15 16:03:59 +02:00
|
|
|
import useSortingStore from '../../stores/use-sorting-store';
|
2025-03-06 00:07:08 +01:00
|
|
|
import useCatalogFiltersStore from '../../stores/use-catalog-filters-store';
|
2026-04-17 10:48:27 +07:00
|
|
|
import { getCommunityAddress, isDirectoryBoard, normalizeMultiboardFeedPath } from '../../lib/utils/route-utils';
|
2024-04-12 14:28:06 +02:00
|
|
|
import CatalogRow from '../../components/catalog-row';
|
2026-03-09 15:17:39 +08:00
|
|
|
import { CatalogFooterFirstRow, PageFooterDesktop, PageFooterMobile } from '../../components/footer';
|
|
|
|
|
import { ReturnButton, ArchiveButton, TopButton, RefreshButton } from '../../components/board-buttons/board-buttons';
|
|
|
|
|
import mobileFooterStyles from '../../components/footer/footer.module.css';
|
2024-04-12 14:28:06 +02:00
|
|
|
import LoadingEllipsis from '../../components/loading-ellipsis';
|
2025-12-31 16:00:58 +01:00
|
|
|
import ErrorDisplay from '../../components/error-display/error-display';
|
2024-04-12 14:28:06 +02:00
|
|
|
import styles from './catalog.module.css';
|
2025-03-06 23:48:17 +01:00
|
|
|
import { commentMatchesPattern } from '../../lib/utils/pattern-utils';
|
2026-03-13 16:06:36 +08:00
|
|
|
import { isCommentArchived } from '../../lib/utils/comment-moderation-utils';
|
2026-02-23 17:09:26 +08:00
|
|
|
import { sortCatalogFeedForDisplay } from '../../lib/utils/catalog-sort';
|
2026-04-17 10:48:27 +07:00
|
|
|
import { getCommentCommunityAddress } from '../../lib/utils/comment-utils';
|
2026-04-02 19:45:55 +07:00
|
|
|
import {
|
|
|
|
|
getCatalogRowHeightEstimates,
|
|
|
|
|
getPretextItemSizeFromElement,
|
|
|
|
|
getTypicalCatalogRowHeight,
|
|
|
|
|
readReplyTypographyMetrics,
|
|
|
|
|
resolveCatalogVirtualizationMode,
|
|
|
|
|
} from '../../lib/utils/pretext-height-estimates';
|
2024-04-12 14:28:06 +02:00
|
|
|
|
|
|
|
|
const lastVirtuosoStates: { [key: string]: StateSnapshot } = {};
|
2026-03-20 21:25:57 +08:00
|
|
|
const RECENT_ACCOUNT_COMMENT_WINDOW_SECONDS = 60 * 60;
|
|
|
|
|
// Keep the hook on its indexed fast path when this view should not inject local posts.
|
|
|
|
|
const EMPTY_ACCOUNT_COMMENT_LOOKUP = { commentIndices: [-1] };
|
2026-04-03 15:51:57 +07:00
|
|
|
export const getCatalogRenderFeed = <T,>(processedFeed: readonly T[], deferredProcessedFeed: readonly T[]): readonly T[] =>
|
|
|
|
|
deferredProcessedFeed.length === 0 && processedFeed.length > 0 ? processedFeed : deferredProcessedFeed;
|
2024-04-12 14:28:06 +02:00
|
|
|
|
2026-01-13 17:21:30 +01:00
|
|
|
interface CatalogFooterProps {
|
2026-03-13 13:25:10 +08:00
|
|
|
communityAddresses: string[];
|
2026-01-13 17:21:30 +01:00
|
|
|
hasMore: boolean;
|
|
|
|
|
combinedFeedLength: number;
|
2026-02-21 13:14:50 +08:00
|
|
|
/** When false, suppress the loading ellipsis (e.g. non-infinite mode) */
|
|
|
|
|
showLoadingEllipsis?: boolean;
|
2026-01-13 17:21:30 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Defined outside Catalog to preserve component identity across renders (Virtuoso optimization)
|
|
|
|
|
// The useFeedStateString hook is called here instead of in Catalog to isolate re-renders
|
|
|
|
|
// caused by backend IPFS state changes to just this footer component
|
2026-04-02 19:45:55 +07:00
|
|
|
const CatalogFooter = ({ communityAddresses, hasMore, combinedFeedLength, showLoadingEllipsis = true }: CatalogFooterProps) => {
|
2026-01-13 17:21:30 +01:00
|
|
|
const { t } = useTranslation();
|
|
|
|
|
|
2026-03-13 13:25:10 +08:00
|
|
|
const loadingStateString = useFeedStateString(communityAddresses) || (combinedFeedLength === 0 ? t('loading_feed') : t('looking_for_more_posts'));
|
2026-01-13 17:21:30 +01:00
|
|
|
|
|
|
|
|
let footerContent;
|
2026-02-22 15:57:42 +08:00
|
|
|
if (combinedFeedLength === 0) {
|
|
|
|
|
footerContent = t('no_threads');
|
2026-01-13 17:21:30 +01:00
|
|
|
}
|
2026-03-13 13:25:10 +08:00
|
|
|
if (hasMore || (communityAddresses && communityAddresses.length === 0)) {
|
2026-01-13 17:21:30 +01:00
|
|
|
footerContent = (
|
|
|
|
|
<>
|
2026-02-21 13:14:50 +08:00
|
|
|
{showLoadingEllipsis && (
|
|
|
|
|
<div className={styles.stateString}>
|
|
|
|
|
<LoadingEllipsis string={loadingStateString} />
|
|
|
|
|
</div>
|
|
|
|
|
)}
|
2026-01-13 17:21:30 +01:00
|
|
|
</>
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
return <div className={styles.footer}>{footerContent}</div>;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
// Separate component for the loading state when there's no feed
|
|
|
|
|
// This also calls useFeedStateString internally to isolate re-renders
|
|
|
|
|
interface CatalogLoadingProps {
|
2026-03-13 13:25:10 +08:00
|
|
|
communityAddresses: string[];
|
2026-01-13 17:21:30 +01:00
|
|
|
hasMore: boolean;
|
2026-02-22 15:57:42 +08:00
|
|
|
combinedFeedLength: number;
|
2026-01-13 17:21:30 +01:00
|
|
|
state: string | undefined;
|
|
|
|
|
subscriptionsLength: number;
|
|
|
|
|
error: Error | undefined;
|
|
|
|
|
}
|
|
|
|
|
|
2026-03-13 13:25:10 +08:00
|
|
|
const CatalogLoading = ({ communityAddresses, hasMore, combinedFeedLength, state, subscriptionsLength, error }: CatalogLoadingProps) => {
|
2026-01-13 17:21:30 +01:00
|
|
|
const { t } = useTranslation();
|
|
|
|
|
|
2026-03-13 13:25:10 +08:00
|
|
|
const rawFeedStateString = useFeedStateString(communityAddresses);
|
2026-02-22 15:57:42 +08:00
|
|
|
const loadingStateString = rawFeedStateString || (combinedFeedLength === 0 ? t('loading_feed') : t('looking_for_more_posts'));
|
2026-01-13 17:21:30 +01:00
|
|
|
|
|
|
|
|
return (
|
|
|
|
|
<div className={styles.stateString}>
|
|
|
|
|
{state === 'failed' ? (
|
|
|
|
|
<span className='red'>{state}</span>
|
|
|
|
|
) : subscriptionsLength === 0 ? (
|
|
|
|
|
<span className='red'>{t('not_subscribed_to_any_board')}</span>
|
|
|
|
|
) : !hasMore && combinedFeedLength === 0 ? (
|
|
|
|
|
t('no_threads')
|
|
|
|
|
) : (
|
|
|
|
|
hasMore && <LoadingEllipsis string={loadingStateString} />
|
|
|
|
|
)}
|
|
|
|
|
<ErrorDisplay error={error} />
|
|
|
|
|
</div>
|
|
|
|
|
);
|
|
|
|
|
};
|
|
|
|
|
|
2025-03-06 00:07:08 +01:00
|
|
|
const createContentFilter = (
|
2025-03-07 17:43:09 +01:00
|
|
|
filterItems: { text: string; enabled: boolean; count: number; filteredCids: Set<string>; hide: boolean; top: boolean; color?: string }[],
|
2026-03-13 13:25:10 +08:00
|
|
|
communityAddress: string,
|
|
|
|
|
onFilterMatch?: (filterIndex: number, cid: string, communityAddress: string) => void,
|
2025-03-06 00:07:08 +01:00
|
|
|
) => {
|
|
|
|
|
// Create a unique key based on the enabled filter items
|
|
|
|
|
const enabledFilters = filterItems.filter((item) => item.enabled && item.text.trim() !== '');
|
|
|
|
|
const filterKey =
|
|
|
|
|
enabledFilters.length > 0
|
|
|
|
|
? `content-filter-${enabledFilters.map((item) => `${item.text}-${item.hide ? 'hide' : ''}-${item.top ? 'top' : ''}`).join('-')}`
|
|
|
|
|
: 'no-content-filter';
|
|
|
|
|
|
|
|
|
|
return {
|
|
|
|
|
filter: (comment: Comment) => {
|
|
|
|
|
if (!comment?.cid) return true;
|
|
|
|
|
|
|
|
|
|
if (enabledFilters.length === 0) return true;
|
|
|
|
|
|
|
|
|
|
// Check if any enabled filter matches the content
|
|
|
|
|
for (let i = 0; i < enabledFilters.length; i++) {
|
|
|
|
|
const item = enabledFilters[i];
|
2025-03-06 23:48:17 +01:00
|
|
|
const pattern = item.text;
|
2025-03-06 00:07:08 +01:00
|
|
|
|
2025-03-06 23:48:17 +01:00
|
|
|
if (commentMatchesPattern(comment, pattern)) {
|
2025-03-06 00:07:08 +01:00
|
|
|
// Find the original filter index to increment count
|
|
|
|
|
const filterIndex = filterItems.findIndex((f) => f.text === item.text && f.enabled);
|
|
|
|
|
if (filterIndex !== -1) {
|
|
|
|
|
if (onFilterMatch) {
|
2026-03-13 13:25:10 +08:00
|
|
|
onFilterMatch(filterIndex, comment.cid, communityAddress);
|
2025-03-06 00:07:08 +01:00
|
|
|
} else {
|
|
|
|
|
// Fallback to the store method if no callback provided
|
2026-03-13 13:25:10 +08:00
|
|
|
useCatalogFiltersStore.getState().incrementFilterCount(filterIndex, comment.cid, communityAddress);
|
2025-03-06 00:07:08 +01:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// If this filter is set to hide, filter out the comment
|
|
|
|
|
if (item.hide) {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// If this filter is set to top, we'll handle it separately in the component
|
|
|
|
|
// (we don't filter it out here)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
},
|
|
|
|
|
key: filterKey,
|
|
|
|
|
};
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
const createCombinedFilter = (
|
2025-03-07 17:43:09 +01:00
|
|
|
filterItems: { text: string; enabled: boolean; count: number; filteredCids: Set<string>; hide: boolean; top: boolean; color?: string }[],
|
2025-03-06 16:27:09 +01:00
|
|
|
searchText: string,
|
2026-03-13 13:25:10 +08:00
|
|
|
communityAddress: string,
|
|
|
|
|
onFilterMatch?: (filterIndex: number, cid: string, communityAddress: string) => void,
|
2025-03-06 00:07:08 +01:00
|
|
|
) => {
|
2026-03-13 13:25:10 +08:00
|
|
|
const contentFilter = createContentFilter(filterItems, communityAddress, onFilterMatch);
|
2025-03-06 00:07:08 +01:00
|
|
|
|
2025-03-06 16:27:09 +01:00
|
|
|
const searchFilter = {
|
|
|
|
|
filter: (comment: Comment) => {
|
|
|
|
|
if (!searchText.trim()) return true;
|
2025-03-06 23:48:17 +01:00
|
|
|
return commentMatchesPattern(comment, searchText);
|
2025-03-06 16:27:09 +01:00
|
|
|
},
|
|
|
|
|
key: searchText ? `search-filter-${searchText}` : 'no-search-filter',
|
|
|
|
|
};
|
|
|
|
|
|
2025-03-06 00:07:08 +01:00
|
|
|
return {
|
|
|
|
|
filter: (comment: Comment) => {
|
2026-03-13 16:06:36 +08:00
|
|
|
if (isCommentArchived(comment)) return false;
|
2025-03-06 16:27:09 +01:00
|
|
|
if (!contentFilter.filter(comment)) return false;
|
|
|
|
|
if (!searchFilter.filter(comment)) return false;
|
2025-03-06 00:07:08 +01:00
|
|
|
|
2025-03-06 16:27:09 +01:00
|
|
|
return true;
|
2025-03-06 00:07:08 +01:00
|
|
|
},
|
2026-03-13 16:06:36 +08:00
|
|
|
key: `${contentFilter.key}-${searchFilter.key}-exclude-archived`,
|
2025-03-06 00:07:08 +01:00
|
|
|
};
|
|
|
|
|
};
|
2024-10-12 15:35:27 +02:00
|
|
|
|
2025-12-08 22:40:16 +01:00
|
|
|
export interface CatalogProps {
|
|
|
|
|
feedCacheKey?: string;
|
|
|
|
|
viewType?: 'all' | 'subs' | 'mod' | 'board';
|
|
|
|
|
boardIdentifier?: string;
|
|
|
|
|
isVisible?: boolean;
|
|
|
|
|
}
|
|
|
|
|
|
2026-02-22 15:57:42 +08:00
|
|
|
const Catalog = ({ feedCacheKey, viewType, boardIdentifier: boardIdentifierProp, isVisible = true }: CatalogProps) => {
|
2024-04-12 14:28:06 +02:00
|
|
|
const { t } = useTranslation();
|
2024-05-09 16:04:24 +02:00
|
|
|
const location = useLocation();
|
2026-02-22 14:24:45 +08:00
|
|
|
const navigate = useNavigate();
|
2025-12-08 22:40:16 +01:00
|
|
|
const params = useParams();
|
2024-05-17 16:39:02 +02:00
|
|
|
|
2025-12-08 22:40:16 +01:00
|
|
|
const isInAllView = viewType ? viewType === 'all' : false;
|
|
|
|
|
const isInSubscriptionsView = viewType ? viewType === 'subs' : false;
|
2026-02-22 14:24:45 +08:00
|
|
|
const isInModView = viewType ? viewType === 'mod' : false;
|
|
|
|
|
|
2026-02-25 17:39:07 +08:00
|
|
|
const isMultiboard = isInAllView || isInSubscriptionsView || isInModView;
|
|
|
|
|
// Single-board catalogs always cap at maxGuiPages (no infinite scroll beyond the board's page limit)
|
|
|
|
|
const effectiveInfiniteScroll = isMultiboard;
|
2025-12-08 22:40:16 +01:00
|
|
|
|
2026-01-28 16:51:27 +08:00
|
|
|
const directories = useDirectories();
|
2026-03-13 13:25:10 +08:00
|
|
|
const resolvedAddressFromUrl = useResolvedCommunityAddress();
|
|
|
|
|
const communityAddress = useMemo(() => {
|
2025-12-08 22:40:16 +01:00
|
|
|
if (boardIdentifierProp) {
|
2026-04-17 10:48:27 +07:00
|
|
|
return getCommunityAddress(boardIdentifierProp, directories);
|
2025-12-08 22:40:16 +01:00
|
|
|
}
|
|
|
|
|
return resolvedAddressFromUrl;
|
2026-01-28 16:51:27 +08:00
|
|
|
}, [boardIdentifierProp, directories, resolvedAddressFromUrl]);
|
2025-12-08 22:40:16 +01:00
|
|
|
|
2026-04-02 19:45:55 +07:00
|
|
|
const { filterItems, searchText } = useCatalogFiltersStore();
|
2024-05-17 16:39:02 +02:00
|
|
|
|
|
|
|
|
const account = useAccount();
|
|
|
|
|
const subscriptions = account?.subscriptions;
|
2026-01-28 16:51:27 +08:00
|
|
|
const filteredDirectoryAddresses = useFilteredDirectoryAddresses();
|
2024-05-17 16:39:02 +02:00
|
|
|
|
2026-03-13 13:25:10 +08:00
|
|
|
const communityAddresses = useMemo(() => {
|
2024-05-17 16:39:02 +02:00
|
|
|
if (isInAllView) {
|
2026-01-28 16:51:27 +08:00
|
|
|
return filteredDirectoryAddresses;
|
2024-05-17 16:39:02 +02:00
|
|
|
}
|
|
|
|
|
if (isInSubscriptionsView) {
|
2025-06-04 16:37:17 +02:00
|
|
|
return (subscriptions || []).filter(Boolean); // Filter out any undefined/null values
|
2024-05-17 16:39:02 +02:00
|
|
|
}
|
2026-03-13 13:25:10 +08:00
|
|
|
// Only include communityAddress if it's defined
|
|
|
|
|
return communityAddress ? [communityAddress] : [];
|
|
|
|
|
}, [isInAllView, isInSubscriptionsView, communityAddress, filteredDirectoryAddresses, subscriptions]);
|
2026-04-15 12:51:21 +07:00
|
|
|
const communities = useCommunityIdentifiers(communityAddresses);
|
|
|
|
|
const communityIdentifier = useCommunityIdentifier(communityAddress);
|
2024-06-15 16:42:30 +02:00
|
|
|
|
2026-04-02 19:45:55 +07:00
|
|
|
const { imageSize, showOPComment } = useCatalogStyleStore();
|
2024-06-17 21:16:31 +02:00
|
|
|
const columnWidth = imageSize === 'Large' ? 270 : 180;
|
2026-04-02 19:45:55 +07:00
|
|
|
const windowWidth = useWindowWidth();
|
|
|
|
|
const isMobile = useIsMobile();
|
|
|
|
|
const columnCount = Math.floor(windowWidth / columnWidth);
|
2026-04-03 15:08:22 +07:00
|
|
|
const multiboardCatalogPostsPerPage = Math.max(18, Math.min(24, Math.max(columnCount, 1) * 5));
|
2024-04-12 14:28:06 +02:00
|
|
|
|
2026-03-13 13:25:10 +08:00
|
|
|
const communityDirectory = useDirectoryByAddress(isInAllView || isInSubscriptionsView || isInModView ? undefined : communityAddress);
|
|
|
|
|
const { guiPostsPerPage: boardPostsPerPage, maxGuiPages, paginationFeedPostsPerPage } = useBoardFeedPageSize(communityDirectory);
|
2026-02-21 13:14:50 +08:00
|
|
|
|
2026-02-22 14:24:45 +08:00
|
|
|
// Canonical redirect for multiboard catalog paths with numeric page segment (e.g. /all/catalog/1w/5 -> /all/catalog/1w)
|
|
|
|
|
useEffect(() => {
|
|
|
|
|
if (!(isInAllView || isInSubscriptionsView || isInModView)) return;
|
|
|
|
|
const canonical = normalizeMultiboardFeedPath(location.pathname);
|
|
|
|
|
if (location.pathname !== canonical) {
|
|
|
|
|
navigate(canonical, { replace: true });
|
|
|
|
|
}
|
|
|
|
|
}, [isInAllView, isInSubscriptionsView, isInModView, location.pathname, navigate]);
|
|
|
|
|
|
2024-06-15 16:03:59 +02:00
|
|
|
const { sortType } = useSortingStore();
|
2026-02-23 17:09:26 +08:00
|
|
|
const feedSortType = sortType === 'new' ? 'new' : 'active';
|
2026-04-02 19:45:55 +07:00
|
|
|
const catalogVirtualizationMode = useMemo(() => resolveCatalogVirtualizationMode(location.search, 'item-size'), [location.search]);
|
|
|
|
|
const themeKey = typeof document !== 'undefined' ? document.body.className : '';
|
2024-06-09 18:16:01 +02:00
|
|
|
|
2025-03-06 15:44:26 +01:00
|
|
|
// Create a stable callback for filter matching
|
2026-03-13 13:25:10 +08:00
|
|
|
const handleFilterMatch = useCallback((filterIndex: number, cid: string, communityAddress: string) => {
|
|
|
|
|
useCatalogFiltersStore.getState().incrementFilterCount(filterIndex, cid, communityAddress);
|
2025-03-06 00:07:08 +01:00
|
|
|
}, []);
|
|
|
|
|
|
2026-03-13 13:25:10 +08:00
|
|
|
// Set the current community address
|
2025-03-06 15:44:26 +01:00
|
|
|
useEffect(() => {
|
2026-04-17 10:48:27 +07:00
|
|
|
useCatalogFiltersStore.getState().setCurrentCommunityAddress(communityAddress || null);
|
2025-03-06 15:44:26 +01:00
|
|
|
return () => {
|
2026-04-17 10:48:27 +07:00
|
|
|
useCatalogFiltersStore.getState().setCurrentCommunityAddress(null);
|
2025-03-06 15:44:26 +01:00
|
|
|
};
|
2026-03-13 13:25:10 +08:00
|
|
|
}, [communityAddress]);
|
2025-03-06 15:44:26 +01:00
|
|
|
|
2024-09-10 18:20:24 +02:00
|
|
|
const feedOptions = useMemo(() => {
|
2026-02-22 15:57:42 +08:00
|
|
|
return {
|
2026-04-15 12:51:21 +07:00
|
|
|
communities,
|
2026-02-23 17:09:26 +08:00
|
|
|
sortType: feedSortType,
|
2026-04-03 15:08:22 +07:00
|
|
|
postsPerPage: isMultiboard ? multiboardCatalogPostsPerPage : paginationFeedPostsPerPage,
|
2026-03-13 13:25:10 +08:00
|
|
|
filter: createCombinedFilter(filterItems, searchText, communityAddress || 'all', handleFilterMatch),
|
2024-09-10 18:20:24 +02:00
|
|
|
};
|
2026-04-15 12:51:21 +07:00
|
|
|
}, [communities, feedSortType, isMultiboard, paginationFeedPostsPerPage, multiboardCatalogPostsPerPage, filterItems, searchText, communityAddress, handleFilterMatch]);
|
2024-06-09 18:16:01 +02:00
|
|
|
|
2026-02-23 19:46:30 +08:00
|
|
|
const { feed, hasMore, loadMore, reset } = useFeed(feedOptions);
|
2026-03-20 21:25:57 +08:00
|
|
|
const accountCommentLookupOptions = useMemo(
|
|
|
|
|
() =>
|
|
|
|
|
communityAddress
|
|
|
|
|
? {
|
|
|
|
|
communityAddress,
|
|
|
|
|
newerThan: RECENT_ACCOUNT_COMMENT_WINDOW_SECONDS,
|
|
|
|
|
sortType: 'old' as const,
|
|
|
|
|
}
|
|
|
|
|
: EMPTY_ACCOUNT_COMMENT_LOOKUP,
|
|
|
|
|
[communityAddress],
|
|
|
|
|
);
|
|
|
|
|
const { accountComments: recentAccountComments } = useAccountComments(accountCommentLookupOptions);
|
2025-02-23 16:28:30 +01:00
|
|
|
|
|
|
|
|
const resetTriggeredRef = useRef(false);
|
|
|
|
|
|
|
|
|
|
// show account comments instantly in the feed once published (cid defined), instead of waiting for the feed to update
|
2026-02-23 18:51:42 +08:00
|
|
|
const feedCids = useMemo(() => new Set(feed.map((f) => f.cid)), [feed]);
|
2025-02-23 16:28:30 +01:00
|
|
|
const filteredComments = useMemo(
|
|
|
|
|
() =>
|
2026-03-20 21:25:57 +08:00
|
|
|
recentAccountComments.filter((comment) => {
|
2026-02-19 15:34:13 +08:00
|
|
|
const { cid, deleted, postCid, removed, state, timestamp } = comment || {};
|
2026-04-17 10:48:27 +07:00
|
|
|
const commentCommunityAddress = getCommentCommunityAddress(comment);
|
2025-03-06 16:27:09 +01:00
|
|
|
|
|
|
|
|
// Basic filtering conditions
|
|
|
|
|
const basicConditions =
|
2025-02-23 16:28:30 +01:00
|
|
|
!deleted &&
|
|
|
|
|
!removed &&
|
2026-03-20 21:25:57 +08:00
|
|
|
timestamp > Date.now() / 1000 - RECENT_ACCOUNT_COMMENT_WINDOW_SECONDS &&
|
2025-02-23 16:28:30 +01:00
|
|
|
state === 'succeeded' &&
|
|
|
|
|
cid &&
|
|
|
|
|
cid === postCid &&
|
2026-03-13 13:25:10 +08:00
|
|
|
commentCommunityAddress === communityAddress &&
|
2026-02-23 18:51:42 +08:00
|
|
|
!feedCids.has(cid);
|
2025-03-06 16:27:09 +01:00
|
|
|
|
|
|
|
|
// If search is active, also check search conditions
|
|
|
|
|
if (basicConditions && searchText.trim()) {
|
|
|
|
|
const titleLower = comment?.title?.toLowerCase() || '';
|
|
|
|
|
const contentLower = comment?.content?.toLowerCase() || '';
|
|
|
|
|
const searchPattern = searchText.toLowerCase();
|
|
|
|
|
|
|
|
|
|
return titleLower.includes(searchPattern) || contentLower.includes(searchPattern);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return basicConditions;
|
2025-02-23 16:28:30 +01:00
|
|
|
}),
|
2026-03-20 21:25:57 +08:00
|
|
|
[recentAccountComments, communityAddress, feedCids, searchText],
|
2025-02-23 16:28:30 +01:00
|
|
|
);
|
|
|
|
|
|
|
|
|
|
// show newest account comment at the top of the feed but after pinned posts
|
|
|
|
|
const combinedFeed = useMemo(() => {
|
|
|
|
|
const newFeed = [...feed];
|
|
|
|
|
const lastPinnedIndex = newFeed.map((post) => post.pinned).lastIndexOf(true);
|
|
|
|
|
if (filteredComments.length > 0) {
|
|
|
|
|
newFeed.splice(lastPinnedIndex + 1, 0, ...filteredComments);
|
|
|
|
|
}
|
|
|
|
|
return newFeed;
|
|
|
|
|
}, [feed, filteredComments]);
|
|
|
|
|
|
2026-02-21 13:14:50 +08:00
|
|
|
const cappedFeed = useMemo(
|
2026-02-22 14:24:45 +08:00
|
|
|
() => (effectiveInfiniteScroll ? combinedFeed : combinedFeed.slice(0, boardPostsPerPage * maxGuiPages)),
|
|
|
|
|
[effectiveInfiniteScroll, combinedFeed, boardPostsPerPage, maxGuiPages],
|
2026-02-21 13:14:50 +08:00
|
|
|
);
|
|
|
|
|
|
2026-02-23 17:09:26 +08:00
|
|
|
const sortedFeed = useMemo(() => sortCatalogFeedForDisplay(cappedFeed, sortType), [cappedFeed, sortType]);
|
|
|
|
|
|
2025-02-23 16:28:30 +01:00
|
|
|
useEffect(() => {
|
|
|
|
|
if (filteredComments.length > 0 && !resetTriggeredRef.current) {
|
|
|
|
|
reset();
|
|
|
|
|
resetTriggeredRef.current = true;
|
|
|
|
|
}
|
|
|
|
|
}, [filteredComments, reset]);
|
2024-10-12 15:35:27 +02:00
|
|
|
|
|
|
|
|
// suggest the user to change time filter if there aren't enough posts
|
2024-05-31 10:41:44 +02:00
|
|
|
const setResetFunction = useFeedResetStore((state) => state.setResetFunction);
|
|
|
|
|
useEffect(() => {
|
2025-12-08 22:40:16 +01:00
|
|
|
if (isVisible) {
|
|
|
|
|
setResetFunction(reset);
|
|
|
|
|
}
|
|
|
|
|
}, [reset, setResetFunction, isVisible]);
|
2024-04-12 14:28:06 +02:00
|
|
|
|
2026-04-15 12:51:21 +07:00
|
|
|
const community = useCommunity(communityIdentifier ? { community: communityIdentifier } : undefined);
|
2026-03-13 13:25:10 +08:00
|
|
|
const { error, shortAddress, state, title } = community || {};
|
2024-06-27 14:18:10 +02:00
|
|
|
|
2026-01-13 17:21:30 +01:00
|
|
|
// Memoize footer component to preserve identity across renders (Virtuoso optimization)
|
|
|
|
|
// Note: useFeedStateString is called inside CatalogFooter to isolate re-renders from backend state changes
|
|
|
|
|
const footerComponents = useMemo(
|
|
|
|
|
() => ({
|
|
|
|
|
Footer: () => (
|
2026-02-23 16:47:51 +08:00
|
|
|
<>
|
2026-04-02 19:45:55 +07:00
|
|
|
<CatalogFooter communityAddresses={communityAddresses} hasMore={hasMore} combinedFeedLength={cappedFeed.length} showLoadingEllipsis={effectiveInfiniteScroll} />
|
2026-02-24 16:36:13 +08:00
|
|
|
<PageFooterDesktop
|
|
|
|
|
firstRow={
|
|
|
|
|
<CatalogFooterFirstRow
|
2026-03-13 13:25:10 +08:00
|
|
|
communityAddress={communityAddress}
|
2026-02-24 16:36:13 +08:00
|
|
|
isInAllView={isInAllView}
|
|
|
|
|
isInSubscriptionsView={isInSubscriptionsView}
|
|
|
|
|
isInModView={isInModView}
|
|
|
|
|
/>
|
|
|
|
|
}
|
|
|
|
|
/>
|
2026-03-09 15:17:39 +08:00
|
|
|
<PageFooterMobile>
|
|
|
|
|
<div className={mobileFooterStyles.mobileFooterButtons}>
|
2026-03-13 13:25:10 +08:00
|
|
|
<ReturnButton address={communityAddress} isInAllView={isInAllView} isInSubscriptionsView={isInSubscriptionsView} isInModView={isInModView} />
|
|
|
|
|
<ArchiveButton address={communityAddress} isInAllView={isInAllView} isInSubscriptionsView={isInSubscriptionsView} isInModView={isInModView} />
|
2026-03-09 15:17:39 +08:00
|
|
|
<TopButton />
|
|
|
|
|
<RefreshButton />
|
|
|
|
|
</div>
|
|
|
|
|
</PageFooterMobile>
|
2026-02-23 16:47:51 +08:00
|
|
|
</>
|
2026-01-13 17:21:30 +01:00
|
|
|
),
|
|
|
|
|
}),
|
2026-03-13 13:25:10 +08:00
|
|
|
[communityAddresses, hasMore, cappedFeed.length, communityAddress, isInAllView, isInSubscriptionsView, isInModView, effectiveInfiniteScroll],
|
2026-01-13 17:21:30 +01:00
|
|
|
);
|
2026-04-03 15:08:22 +07:00
|
|
|
const catalogFooter = useMemo(
|
|
|
|
|
() => (
|
|
|
|
|
<>
|
|
|
|
|
<CatalogFooter communityAddresses={communityAddresses} hasMore={hasMore} combinedFeedLength={cappedFeed.length} showLoadingEllipsis={effectiveInfiniteScroll} />
|
|
|
|
|
<PageFooterDesktop
|
|
|
|
|
firstRow={
|
|
|
|
|
<CatalogFooterFirstRow
|
|
|
|
|
communityAddress={communityAddress}
|
|
|
|
|
isInAllView={isInAllView}
|
|
|
|
|
isInSubscriptionsView={isInSubscriptionsView}
|
|
|
|
|
isInModView={isInModView}
|
|
|
|
|
/>
|
|
|
|
|
}
|
|
|
|
|
/>
|
|
|
|
|
<PageFooterMobile>
|
|
|
|
|
<div className={mobileFooterStyles.mobileFooterButtons}>
|
|
|
|
|
<ReturnButton address={communityAddress} isInAllView={isInAllView} isInSubscriptionsView={isInSubscriptionsView} isInModView={isInModView} />
|
|
|
|
|
<ArchiveButton address={communityAddress} isInAllView={isInAllView} isInSubscriptionsView={isInSubscriptionsView} isInModView={isInModView} />
|
|
|
|
|
<TopButton />
|
|
|
|
|
<RefreshButton />
|
|
|
|
|
</div>
|
|
|
|
|
</PageFooterMobile>
|
|
|
|
|
</>
|
|
|
|
|
),
|
|
|
|
|
[communityAddresses, hasMore, cappedFeed.length, communityAddress, isInAllView, isInSubscriptionsView, isInModView, effectiveInfiniteScroll],
|
|
|
|
|
);
|
2024-04-12 14:28:06 +02:00
|
|
|
|
2024-05-31 09:38:59 +02:00
|
|
|
const isFeedLoaded = feed.length > 0 || state === 'failed';
|
2024-04-14 16:45:59 +02:00
|
|
|
|
2026-02-23 17:09:26 +08:00
|
|
|
// Process the feed to move "top" posts to the top (applied after display sort)
|
2025-03-06 00:07:08 +01:00
|
|
|
const processedFeed = useMemo(() => {
|
2026-02-23 17:09:26 +08:00
|
|
|
if (!sortedFeed || sortedFeed.length === 0) return sortedFeed;
|
2025-03-06 00:07:08 +01:00
|
|
|
|
|
|
|
|
const enabledTopFilters = filterItems.filter((item) => item.enabled && item.text.trim() !== '' && item.top);
|
2026-02-23 17:09:26 +08:00
|
|
|
if (enabledTopFilters.length === 0) return sortedFeed;
|
2025-03-06 00:07:08 +01:00
|
|
|
|
|
|
|
|
// Separate posts that match "top" filters
|
|
|
|
|
const topPosts: Comment[] = [];
|
|
|
|
|
const regularPosts: Comment[] = [];
|
|
|
|
|
|
2026-02-23 17:09:26 +08:00
|
|
|
sortedFeed.forEach((comment) => {
|
2025-03-06 00:07:08 +01:00
|
|
|
if (!comment) return;
|
|
|
|
|
|
|
|
|
|
let isTop = false;
|
|
|
|
|
for (const filter of enabledTopFilters) {
|
2025-03-06 23:48:17 +01:00
|
|
|
if (commentMatchesPattern(comment, filter.text)) {
|
2025-03-06 00:07:08 +01:00
|
|
|
isTop = true;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (isTop) {
|
|
|
|
|
topPosts.push(comment);
|
|
|
|
|
} else {
|
|
|
|
|
regularPosts.push(comment);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
// Return top posts followed by regular posts
|
|
|
|
|
return [...topPosts, ...regularPosts];
|
2026-02-23 17:09:26 +08:00
|
|
|
}, [sortedFeed, filterItems]);
|
2025-03-06 00:07:08 +01:00
|
|
|
|
2026-04-03 15:08:22 +07:00
|
|
|
const deferredProcessedFeed = useDeferredValue(processedFeed);
|
2026-04-03 15:51:57 +07:00
|
|
|
const catalogRenderFeed = getCatalogRenderFeed(processedFeed, deferredProcessedFeed);
|
2026-04-03 15:08:22 +07:00
|
|
|
|
2026-04-02 19:45:55 +07:00
|
|
|
const matchedFilterColors = useMemo(() => {
|
|
|
|
|
const nextMatchedFilterColors = new Map<string, string>();
|
|
|
|
|
const activeColoredFilters = filterItems.filter((item) => item.enabled && item.text.trim() !== '' && item.color);
|
|
|
|
|
|
|
|
|
|
if (activeColoredFilters.length === 0) {
|
|
|
|
|
return nextMatchedFilterColors;
|
|
|
|
|
}
|
|
|
|
|
|
2026-04-03 15:51:57 +07:00
|
|
|
for (const comment of catalogRenderFeed) {
|
2026-04-02 19:45:55 +07:00
|
|
|
const cid = comment?.cid;
|
|
|
|
|
if (!cid) {
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const firstMatch = activeColoredFilters.find((item) => commentMatchesPattern(comment, item.text));
|
|
|
|
|
if (firstMatch?.color) {
|
|
|
|
|
nextMatchedFilterColors.set(cid, firstMatch.color);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return nextMatchedFilterColors;
|
2026-04-03 15:51:57 +07:00
|
|
|
}, [catalogRenderFeed, filterItems]);
|
2026-04-02 19:45:55 +07:00
|
|
|
|
2026-04-03 15:08:22 +07:00
|
|
|
const rowCacheRef = useRef(new Map<string, Comment[]>());
|
2026-03-20 21:25:57 +08:00
|
|
|
const rows = useMemo(() => {
|
|
|
|
|
if (!isFeedLoaded) {
|
2026-04-03 15:08:22 +07:00
|
|
|
rowCacheRef.current.clear();
|
2026-03-20 21:25:57 +08:00
|
|
|
return [];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const effectiveColumnCount = Math.max(columnCount, 1);
|
2026-04-03 15:08:22 +07:00
|
|
|
const nextRows: Comment[][] = [];
|
|
|
|
|
const nextRowCache = new Map<string, Comment[]>();
|
2026-04-03 15:51:57 +07:00
|
|
|
for (let i = 0; i < catalogRenderFeed.length; i += effectiveColumnCount) {
|
|
|
|
|
const nextRow = catalogRenderFeed.slice(i, i + effectiveColumnCount);
|
2026-04-03 15:08:22 +07:00
|
|
|
const rowKey = nextRow.map((post) => post?.cid || '').join('\u0000');
|
|
|
|
|
const cachedRow = rowCacheRef.current.get(rowKey);
|
|
|
|
|
const stableRow = cachedRow && cachedRow.length === nextRow.length && cachedRow.every((post, index) => post === nextRow[index]) ? cachedRow : nextRow;
|
|
|
|
|
nextRowCache.set(rowKey, stableRow);
|
|
|
|
|
nextRows.push(stableRow);
|
2026-03-20 21:25:57 +08:00
|
|
|
}
|
2026-04-03 15:08:22 +07:00
|
|
|
rowCacheRef.current = nextRowCache;
|
2026-03-20 21:25:57 +08:00
|
|
|
return nextRows;
|
2026-04-03 15:51:57 +07:00
|
|
|
}, [catalogRenderFeed, columnCount, isFeedLoaded]);
|
2024-04-12 14:28:06 +02:00
|
|
|
|
2026-04-02 19:45:55 +07:00
|
|
|
const catalogMetrics = useMemo(() => readReplyTypographyMetrics(), [themeKey, windowWidth]);
|
|
|
|
|
const rowHeightEstimates = useMemo(
|
|
|
|
|
() =>
|
|
|
|
|
catalogVirtualizationMode === 'off'
|
|
|
|
|
? []
|
|
|
|
|
: getCatalogRowHeightEstimates({
|
|
|
|
|
imageSize,
|
|
|
|
|
metrics: catalogMetrics,
|
|
|
|
|
rows,
|
|
|
|
|
showOPComment,
|
|
|
|
|
}),
|
|
|
|
|
[catalogMetrics, catalogVirtualizationMode, imageSize, rows, showOPComment],
|
|
|
|
|
);
|
|
|
|
|
const defaultCatalogRowHeight = useMemo(() => getTypicalCatalogRowHeight(rowHeightEstimates, imageSize), [imageSize, rowHeightEstimates]);
|
|
|
|
|
// Omit the prop entirely in fallback mode. Passing `itemSize={undefined}` overrides
|
|
|
|
|
// Virtuoso's default DOM measurement path and leaves rows on the fallback height.
|
|
|
|
|
const catalogSizingProps = useMemo(() => (catalogVirtualizationMode === 'item-size' ? { itemSize: getPretextItemSizeFromElement } : {}), [catalogVirtualizationMode]);
|
|
|
|
|
const isMultiboardView = isInAllView || isInSubscriptionsView || isInModView;
|
2026-04-03 15:08:22 +07:00
|
|
|
const shouldVirtualizeCatalog = isMultiboardView;
|
|
|
|
|
const catalogViewportBuffer = isMultiboardView ? (isMobile ? { bottom: 2400, top: 1200 } : { bottom: 900, top: 600 }) : { bottom: 1200, top: 1200 };
|
2026-04-02 19:45:55 +07:00
|
|
|
|
2024-04-12 14:28:06 +02:00
|
|
|
const virtuosoRef = useRef<VirtuosoHandle | null>(null);
|
2026-02-22 15:57:42 +08:00
|
|
|
const virtuosoStateKey = feedCacheKey ? `${feedCacheKey}-${sortType}` : `${location.pathname}-${sortType}-catalog`;
|
2025-12-08 13:03:25 +01:00
|
|
|
const navigationType = useNavigationType();
|
|
|
|
|
|
2025-12-08 22:40:16 +01:00
|
|
|
const hasBeenVisibleRef = useRef(false);
|
2024-04-12 14:28:06 +02:00
|
|
|
useEffect(() => {
|
2025-12-08 22:40:16 +01:00
|
|
|
if (isVisible && !hasBeenVisibleRef.current) {
|
|
|
|
|
hasBeenVisibleRef.current = true;
|
|
|
|
|
if (navigationType !== 'POP') {
|
|
|
|
|
window.scrollTo({ top: 0, left: 0, behavior: 'auto' });
|
|
|
|
|
}
|
2025-12-08 13:03:25 +01:00
|
|
|
}
|
2025-12-08 22:40:16 +01:00
|
|
|
}, [isVisible, navigationType]);
|
2025-12-08 13:03:25 +01:00
|
|
|
|
2026-04-03 15:51:57 +07:00
|
|
|
useLayoutEffect(() => {
|
2026-04-03 15:08:22 +07:00
|
|
|
if (!isVisible || !shouldVirtualizeCatalog) return;
|
2025-12-08 22:40:16 +01:00
|
|
|
|
2025-12-08 13:03:25 +01:00
|
|
|
const currentKey = virtuosoStateKey;
|
2026-04-03 15:08:22 +07:00
|
|
|
// Avoid pulling Virtuoso state on every scroll tick in the catalog hot path.
|
|
|
|
|
const saveVirtuosoState = () =>
|
2024-04-12 14:28:06 +02:00
|
|
|
virtuosoRef.current?.getState((snapshot: StateSnapshot) => {
|
|
|
|
|
if (snapshot?.ranges?.length) {
|
2025-12-08 13:03:25 +01:00
|
|
|
lastVirtuosoStates[currentKey] = snapshot;
|
2024-04-12 14:28:06 +02:00
|
|
|
}
|
|
|
|
|
});
|
2026-04-03 15:08:22 +07:00
|
|
|
window.addEventListener('pagehide', saveVirtuosoState);
|
|
|
|
|
return () => {
|
|
|
|
|
saveVirtuosoState();
|
|
|
|
|
window.removeEventListener('pagehide', saveVirtuosoState);
|
|
|
|
|
};
|
|
|
|
|
}, [virtuosoStateKey, isVisible, shouldVirtualizeCatalog]);
|
2024-04-12 14:28:06 +02:00
|
|
|
|
2026-04-03 15:08:22 +07:00
|
|
|
const lastVirtuosoState = shouldVirtualizeCatalog && navigationType === 'POP' ? lastVirtuosoStates?.[virtuosoStateKey] : undefined;
|
|
|
|
|
|
|
|
|
|
const renderCatalogRow = useCallback(
|
|
|
|
|
(index: number, row: Comment[]) => <CatalogRow estimatedHeight={rowHeightEstimates[index]} index={index} matchedFilterColors={matchedFilterColors} row={row} />,
|
|
|
|
|
[matchedFilterColors, rowHeightEstimates],
|
|
|
|
|
);
|
2024-04-12 14:28:06 +02:00
|
|
|
|
|
|
|
|
useEffect(() => {
|
2025-12-08 22:40:16 +01:00
|
|
|
if (!isVisible) return;
|
2025-12-28 23:13:25 +01:00
|
|
|
const boardIdentifier = params.boardIdentifier || boardIdentifierProp;
|
2026-01-28 16:51:27 +08:00
|
|
|
const isDirectory = boardIdentifier ? isDirectoryBoard(boardIdentifier, directories) : false;
|
2025-12-28 23:13:25 +01:00
|
|
|
|
|
|
|
|
let documentTitle: string;
|
|
|
|
|
if (isInAllView) {
|
|
|
|
|
documentTitle = t('all');
|
|
|
|
|
} else if (isInSubscriptionsView) {
|
|
|
|
|
documentTitle = t('subscriptions');
|
|
|
|
|
} else if (isDirectory) {
|
|
|
|
|
documentTitle = `/${boardIdentifier}/`;
|
|
|
|
|
} else {
|
2026-03-13 13:25:10 +08:00
|
|
|
documentTitle = title ? title : shortAddress || communityAddress || '';
|
2025-12-28 23:13:25 +01:00
|
|
|
}
|
2025-10-17 23:30:35 +02:00
|
|
|
document.title = documentTitle + ` - ${t('catalog')} - 5chan`;
|
2026-03-13 13:25:10 +08:00
|
|
|
}, [title, shortAddress, communityAddress, isInAllView, isInSubscriptionsView, t, isVisible, params.boardIdentifier, boardIdentifierProp, directories]);
|
2024-04-12 14:28:06 +02:00
|
|
|
|
|
|
|
|
return (
|
2024-04-12 17:47:30 +02:00
|
|
|
<div className={styles.content}>
|
|
|
|
|
<hr />
|
|
|
|
|
<div className={styles.catalog}>
|
2026-04-03 15:51:57 +07:00
|
|
|
{catalogRenderFeed.length !== 0 ? (
|
2024-10-12 15:35:27 +02:00
|
|
|
<>
|
2026-04-03 15:08:22 +07:00
|
|
|
{shouldVirtualizeCatalog ? (
|
|
|
|
|
<Virtuoso
|
|
|
|
|
defaultItemHeight={defaultCatalogRowHeight}
|
|
|
|
|
heightEstimates={catalogVirtualizationMode === 'off' ? undefined : rowHeightEstimates}
|
|
|
|
|
increaseViewportBy={catalogViewportBuffer}
|
|
|
|
|
{...catalogSizingProps}
|
|
|
|
|
totalCount={rows?.length || 0}
|
|
|
|
|
data={rows}
|
|
|
|
|
itemContent={renderCatalogRow}
|
|
|
|
|
useWindowScroll={true}
|
|
|
|
|
components={footerComponents}
|
|
|
|
|
endReached={effectiveInfiniteScroll && hasMore ? loadMore : undefined}
|
|
|
|
|
ref={virtuosoRef}
|
|
|
|
|
restoreStateFrom={lastVirtuosoState}
|
|
|
|
|
initialScrollTop={lastVirtuosoState?.scrollTop}
|
|
|
|
|
/>
|
|
|
|
|
) : (
|
|
|
|
|
<>
|
|
|
|
|
{rows.map((row, index) => (
|
|
|
|
|
<CatalogRow
|
|
|
|
|
key={row.map((post) => post?.cid || '').join('\u0000') || `row-${index}`}
|
|
|
|
|
estimatedHeight={rowHeightEstimates[index]}
|
|
|
|
|
index={index}
|
|
|
|
|
matchedFilterColors={matchedFilterColors}
|
|
|
|
|
row={row}
|
|
|
|
|
/>
|
|
|
|
|
))}
|
|
|
|
|
{catalogFooter}
|
|
|
|
|
</>
|
|
|
|
|
)}
|
2024-10-12 15:35:27 +02:00
|
|
|
</>
|
|
|
|
|
) : (
|
2026-02-23 16:47:51 +08:00
|
|
|
<>
|
|
|
|
|
<div className={styles.footer}>
|
|
|
|
|
<CatalogLoading
|
2026-03-13 13:25:10 +08:00
|
|
|
communityAddresses={communityAddresses}
|
2026-02-23 16:47:51 +08:00
|
|
|
hasMore={hasMore}
|
|
|
|
|
combinedFeedLength={cappedFeed.length}
|
|
|
|
|
state={state}
|
|
|
|
|
subscriptionsLength={isInSubscriptionsView ? subscriptions?.length || 0 : 1}
|
|
|
|
|
error={error}
|
|
|
|
|
/>
|
|
|
|
|
</div>
|
2026-02-24 16:36:13 +08:00
|
|
|
<PageFooterDesktop
|
|
|
|
|
firstRow={
|
|
|
|
|
<CatalogFooterFirstRow
|
2026-03-13 13:25:10 +08:00
|
|
|
communityAddress={communityAddress}
|
2026-02-24 16:36:13 +08:00
|
|
|
isInAllView={isInAllView}
|
|
|
|
|
isInSubscriptionsView={isInSubscriptionsView}
|
|
|
|
|
isInModView={isInModView}
|
|
|
|
|
/>
|
|
|
|
|
}
|
|
|
|
|
/>
|
2026-03-09 15:17:39 +08:00
|
|
|
<PageFooterMobile>
|
|
|
|
|
<div className={mobileFooterStyles.mobileFooterButtons}>
|
2026-03-13 13:25:10 +08:00
|
|
|
<ReturnButton address={communityAddress} isInAllView={isInAllView} isInSubscriptionsView={isInSubscriptionsView} isInModView={isInModView} />
|
|
|
|
|
<ArchiveButton address={communityAddress} isInAllView={isInAllView} isInSubscriptionsView={isInSubscriptionsView} isInModView={isInModView} />
|
2026-03-09 15:17:39 +08:00
|
|
|
<TopButton />
|
|
|
|
|
<RefreshButton />
|
|
|
|
|
</div>
|
|
|
|
|
</PageFooterMobile>
|
2026-02-23 16:47:51 +08:00
|
|
|
</>
|
2024-10-12 15:35:27 +02:00
|
|
|
)}
|
2024-04-12 17:47:30 +02:00
|
|
|
</div>
|
2024-04-12 14:28:06 +02:00
|
|
|
</div>
|
|
|
|
|
);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
export default Catalog;
|