mirror of
https://github.com/bitsocialnet/5chan.git
synced 2026-08-03 07:41:04 +02:00
fix(directory): use resolved board for directory feeds
This commit is contained in:
@@ -10,7 +10,7 @@ import LoadingEllipsis from '../../components/loading-ellipsis';
|
||||
import { useResolvedCommunityAddress } from '../../hooks/use-resolved-community-address';
|
||||
import { useCommunityField } from '../../hooks/use-stable-community';
|
||||
import { useFeedStateString } from '../../hooks/use-state-string';
|
||||
import { getCommunityAddress, getBoardPath } from '../../lib/utils/route-utils';
|
||||
import { getBoardPath } from '../../lib/utils/route-utils';
|
||||
import { isCommentArchived } from '../../lib/utils/comment-moderation-utils';
|
||||
import { removeMarkdown } from '../../lib/utils/post-utils';
|
||||
import { useDirectories } from '../../hooks/use-directories';
|
||||
@@ -151,13 +151,7 @@ const Archive = () => {
|
||||
const boardIdentifier = params.boardIdentifier;
|
||||
const directories = useDirectories();
|
||||
|
||||
const resolvedAddressFromUrl = useResolvedCommunityAddress();
|
||||
const communityAddress = useMemo(() => {
|
||||
if (boardIdentifier) {
|
||||
return getCommunityAddress(boardIdentifier, directories);
|
||||
}
|
||||
return resolvedAddressFromUrl;
|
||||
}, [boardIdentifier, directories, resolvedAddressFromUrl]);
|
||||
const communityAddress = useResolvedCommunityAddress(boardIdentifier);
|
||||
|
||||
const boardPath = useMemo(() => {
|
||||
if (!communityAddress) {
|
||||
|
||||
@@ -25,7 +25,7 @@ const testState = vi.hoisted(() => ({
|
||||
accountComments: [] as TestComment[],
|
||||
accountCommentsCalls: [] as Array<{ commentIndices?: number[]; communityAddress?: string; newerThan?: number; sortType?: 'new' | 'old' } | undefined>,
|
||||
accountCommunityAddresses: [] as string[],
|
||||
directories: [{ address: 'music-posting.eth', title: '/mu/ - Music' }] as Array<{ address: string; title?: string }>,
|
||||
directories: [{ address: 'music-posting.eth', title: '/mu/ - Music' }] as Array<{ address: string; title?: string; directoryCode?: string }>,
|
||||
directoryByAddress: {
|
||||
'music-posting.eth': {
|
||||
address: 'music-posting.eth',
|
||||
@@ -33,7 +33,7 @@ const testState = vi.hoisted(() => ({
|
||||
},
|
||||
} as Record<string, { address: string; features?: Record<string, unknown> }>,
|
||||
feed: [] as TestComment[],
|
||||
feedOptionsCalls: [] as Array<{ communitiesLength?: number; newerThan?: number; postsPerPage?: number; sortType?: string }>,
|
||||
feedOptionsCalls: [] as Array<{ communities?: unknown[]; communitiesLength?: number; newerThan?: number; postsPerPage?: number; sortType?: string }>,
|
||||
feedState: undefined as string | undefined,
|
||||
feedStateString: 'syncing' as string | undefined,
|
||||
filteredDirectoryAddresses: ['music-posting.eth'] as string[],
|
||||
@@ -129,6 +129,7 @@ vi.mock('@bitsocial/bitsocial-react-hooks', () => ({
|
||||
sortType?: string;
|
||||
}) => {
|
||||
testState.feedOptionsCalls.push({
|
||||
communities: options?.communities,
|
||||
communitiesLength: options?.communities?.length,
|
||||
newerThan: options?.newerThan,
|
||||
postsPerPage: options?.postsPerPage,
|
||||
@@ -379,6 +380,25 @@ describe('Board', () => {
|
||||
localStorage.clear();
|
||||
});
|
||||
|
||||
it('uses the resolved directory winner for cached board feeds', async () => {
|
||||
testState.directories = [{ address: 'business-and-finance.bso', directoryCode: 'biz', title: '/biz/ - Business & Finance' }];
|
||||
testState.directoryByAddress = {
|
||||
'bizraelis.bso': {
|
||||
address: 'bizraelis.bso',
|
||||
features: { postsPerPage: 2 },
|
||||
},
|
||||
};
|
||||
testState.resolvedCommunityAddress = 'bizraelis.bso';
|
||||
|
||||
await renderBoard({
|
||||
boardProps: { boardIdentifier: 'biz', viewType: 'board' },
|
||||
initialEntry: '/biz',
|
||||
routePath: '/:boardIdentifier/*',
|
||||
});
|
||||
|
||||
expect(testState.feedOptionsCalls.map((call) => call.communities)).toContainEqual([{ name: 'bizraelis.bso' }]);
|
||||
});
|
||||
|
||||
it('renders the current page feed, inserts recent account comments, and wires footer actions', async () => {
|
||||
const currentTimestamp = Math.floor(Date.now() / 1000);
|
||||
testState.feed = [
|
||||
|
||||
@@ -22,7 +22,7 @@ import useIsMobile from '../../hooks/use-is-mobile';
|
||||
import { useSuggestionFeedLoader } from '../../hooks/use-suggestion-feed-loader';
|
||||
import useTimeFilter from '../../hooks/use-time-filter';
|
||||
import { getPageSlice } from '../../lib/utils/board-feed-pagination';
|
||||
import { getPageFromFeedPath, getCommunityAddress, isDirectoryBoard, normalizeMultiboardFeedPath, stripPageFromFeedPath } from '../../lib/utils/route-utils';
|
||||
import { getPageFromFeedPath, isDirectoryBoard, normalizeMultiboardFeedPath, stripPageFromFeedPath } from '../../lib/utils/route-utils';
|
||||
import { isCommentArchived } from '../../lib/utils/comment-moderation-utils';
|
||||
import { getCommentCommunityAddress } from '../../lib/utils/comment-utils';
|
||||
import { getSearchWithTimeFilter, getTimeFilterSuggestion, type TimeFilterSuggestion } from '../../lib/utils/time-filter-utils';
|
||||
@@ -166,13 +166,7 @@ const Board = ({ feedCacheKey, viewType, boardIdentifier: boardIdentifierProp, t
|
||||
const multiboardTimeFilterSeconds = isMultiboardView ? timeFilterSeconds : undefined;
|
||||
|
||||
const directories = useDirectories();
|
||||
const resolvedAddressFromUrl = useResolvedCommunityAddress();
|
||||
const communityAddress = useMemo(() => {
|
||||
if (boardIdentifierProp) {
|
||||
return getCommunityAddress(boardIdentifierProp, directories);
|
||||
}
|
||||
return resolvedAddressFromUrl;
|
||||
}, [boardIdentifierProp, directories, resolvedAddressFromUrl]);
|
||||
const communityAddress = useResolvedCommunityAddress(boardIdentifierProp);
|
||||
|
||||
const filteredDirectoryAddresses = useFilteredDirectoryAddresses();
|
||||
|
||||
|
||||
@@ -23,7 +23,7 @@ import useFeedResetStore from '../../stores/use-feed-reset-store';
|
||||
import useHiddenCatalogThreadsStore from '../../stores/use-hidden-catalog-threads-store';
|
||||
import useSortingStore from '../../stores/use-sorting-store';
|
||||
import useCatalogFiltersStore from '../../stores/use-catalog-filters-store';
|
||||
import { getCommunityAddress, isDirectoryBoard, normalizeMultiboardFeedPath } from '../../lib/utils/route-utils';
|
||||
import { isDirectoryBoard, normalizeMultiboardFeedPath } from '../../lib/utils/route-utils';
|
||||
import CatalogRow from '../../components/catalog-row';
|
||||
import { CatalogFooterFirstRow, CatalogFooterStyleRow, PageFooterDesktop, PageFooterMobile } from '../../components/footer';
|
||||
import { ReturnButton, ArchiveButton, TopButton, RefreshButton } from '../../components/board-buttons/board-buttons';
|
||||
@@ -285,13 +285,7 @@ const Catalog = ({ feedCacheKey, viewType, boardIdentifier: boardIdentifierProp,
|
||||
const effectiveInfiniteScroll = isMultiboard;
|
||||
|
||||
const directories = useDirectories();
|
||||
const resolvedAddressFromUrl = useResolvedCommunityAddress();
|
||||
const communityAddress = useMemo(() => {
|
||||
if (boardIdentifierProp) {
|
||||
return getCommunityAddress(boardIdentifierProp, directories);
|
||||
}
|
||||
return resolvedAddressFromUrl;
|
||||
}, [boardIdentifierProp, directories, resolvedAddressFromUrl]);
|
||||
const communityAddress = useResolvedCommunityAddress(boardIdentifierProp);
|
||||
|
||||
const filterItems = useCatalogFiltersStore((state) => state.filterItems);
|
||||
const searchText = useCatalogFiltersStore((state) => state.searchText);
|
||||
|
||||
Reference in New Issue
Block a user