fix(codebase audit): preserve cleanup without regressions

Fix codebase audit regressions while preserving UI/UX behavior and adding review-driven hardening.
This commit is contained in:
Tommaso Casaburi
2026-04-24 15:48:07 +07:00
committed by GitHub
parent 5df994b2c7
commit 5dc5408a15
70 changed files with 1478 additions and 518 deletions
+5 -3
View File
@@ -233,6 +233,7 @@ vi.mock('../../../hooks/use-state-string', () => ({
vi.mock('../../../hooks/use-window-width', () => ({
default: () => testState.windowWidth,
useIsMobileBreakpoint: () => testState.windowWidth < 640,
}));
vi.mock('../../../stores/use-catalog-style-store', () => ({
@@ -250,9 +251,10 @@ vi.mock('../../../stores/use-feed-reset-store', () => ({
}));
vi.mock('../../../stores/use-sorting-store', () => ({
default: () => ({
sortType: testState.sortType,
}),
default: (selector?: (state: { sortType: typeof testState.sortType }) => unknown) => {
const state = { sortType: testState.sortType };
return selector ? selector(state) : state;
},
}));
vi.mock('../../../stores/use-catalog-filters-store', () => ({
+5 -4
View File
@@ -272,7 +272,8 @@ const Catalog = ({ feedCacheKey, viewType, boardIdentifier: boardIdentifierProp,
return resolvedAddressFromUrl;
}, [boardIdentifierProp, directories, resolvedAddressFromUrl]);
const { filterItems, searchText } = useCatalogFiltersStore();
const filterItems = useCatalogFiltersStore((state) => state.filterItems);
const searchText = useCatalogFiltersStore((state) => state.searchText);
const account = useAccount();
const subscriptions = account?.subscriptions;
@@ -306,7 +307,8 @@ const Catalog = ({ feedCacheKey, viewType, boardIdentifier: boardIdentifierProp,
const communities = useCommunityIdentifiers(communityAddresses);
const communityIdentifier = useCommunityIdentifier(communityAddress);
const { imageSize, showOPComment } = useCatalogStyleStore();
const imageSize = useCatalogStyleStore((state) => state.imageSize);
const showOPComment = useCatalogStyleStore((state) => state.showOPComment);
const columnWidth = imageSize === 'Large' ? 270 : 180;
const windowWidth = useWindowWidth();
const isMobile = useIsMobile();
@@ -325,7 +327,7 @@ const Catalog = ({ feedCacheKey, viewType, boardIdentifier: boardIdentifierProp,
}
}, [isInAllView, isInSubscriptionsView, isInModView, location.pathname, location.search, navigate]);
const { sortType } = useSortingStore();
const sortType = useSortingStore((state) => state.sortType);
const feedSortType = sortType === 'new' ? 'new' : 'active';
const catalogVirtualizationMode = useMemo(() => resolveCatalogVirtualizationMode(location.search, 'item-size'), [location.search]);
const themeKey = typeof document !== 'undefined' ? document.body.className : '';
@@ -632,7 +634,6 @@ const Catalog = ({ feedCacheKey, viewType, boardIdentifier: boardIdentifierProp,
effectiveInfiniteScroll,
],
);
const isFeedLoaded = feed.length > 0 || state === 'failed';
// Process the feed to move "top" posts to the top (applied after display sort)