mirror of
https://github.com/duckietm/Nitro-V3.git
synced 2026-06-19 15:06:20 +00:00
catalog: migrate remaining 36 useCatalog() consumers to the three filters
Replaces every direct call to the deprecated useCatalog() shim with the targeted filter(s) (useCatalogData / useCatalogUiState / useCatalogActions). Each consumer now subscribes only to the slice it actually reads, which restores React Compiler memoization and stops catalog-wide re-renders whenever an unrelated key changes. Removes the now-unused useCatalog shim from useCatalog.ts and the shim-specific case in tests/useCatalog.filters.test.tsx. The "all four hooks observe the same singleton" test becomes "all three filters", since there is no shim left to compare against. useCatalogFavorites swaps its internal useCatalog() call for useCatalogUiState() (currentType lives in the UI slice). Updates CLAUDE.md and docs/ARCHITECTURE.md to reflect that all 48 historical consumers are migrated and the shim is gone. Vitest: 162/162 (was 163 — minus the deprecated-shim contract case).
This commit is contained in:
+6
-10
@@ -502,15 +502,11 @@ filters built on top of the same `useBetween` singleton:
|
||||
`getBuilderFurniPlaceableStatus`).
|
||||
|
||||
The internal store is named `useCatalogStore` and is **not exported**;
|
||||
the four public entry points (`useCatalogData` / `useCatalogUiState`
|
||||
/ `useCatalogActions` / `useCatalog`) all funnel into the same
|
||||
`useBetween` instance, so listeners + state register once. The
|
||||
deprecated `useCatalog` shim continues to expose the full historical
|
||||
return shape so the 48 existing consumers compile unchanged; they
|
||||
should be incrementally migrated to the specific filters as PRs
|
||||
touch them. Three pilot migrations already landed in
|
||||
`CatalogBuildersClubStatusView`, `CatalogBreadcrumbView`, and
|
||||
`CatalogNavigationItemView`.
|
||||
the three public entry points (`useCatalogData` / `useCatalogUiState`
|
||||
/ `useCatalogActions`) all funnel into the same `useBetween`
|
||||
instance, so listeners + state register once. All 48 historical
|
||||
consumers have been migrated to the targeted filters; the deprecated
|
||||
`useCatalog` shim has been removed.
|
||||
|
||||
Pure helpers in `useCatalog.helpers.ts`:
|
||||
|
||||
@@ -569,7 +565,7 @@ empty-map / partial-bucket branches of the offer lookup).
|
||||
the partial-visible fallback), `buildCatalogNodeTree` (tree
|
||||
depth + offerId index), and the full decision tree of
|
||||
`resolveBuilderFurniPlaceableStatus`.
|
||||
- `useCatalog.filters.test.tsx` (5) — contract tests for the
|
||||
- `useCatalog.filters.test.tsx` (4) — contract tests for the
|
||||
three-way singleton-filter split. Stubs `use-between` so the
|
||||
filters share one fake store, asserts each filter exposes
|
||||
exactly the keys it owns (no leak across slices), and pins
|
||||
|
||||
Reference in New Issue
Block a user