Skip to content

Conversation

@marcuscastelo
Copy link
Owner

@marcuscastelo marcuscastelo commented Dec 2, 2025

Restructure the search module for better organization, consolidate template search functionality, and simplify the initialization of cached search logic. Encapsulate cached search operations to enhance maintainability and clarity.

export const [templates, { refetch: refetchTemplates }] = createResource(
  () => ({
    tab: debouncedTab(),
    search: debouncedSearch(),
    userId: currentUserId(),
  }),
  (signals) => {
    return fetchTemplatesByTabLogic(
      signals.tab,
      signals.search,
      signals.userId,
      {
        fetchUserRecipes,
        fetchUserRecipeByName,
        fetchUserRecentFoods,
        fetchFoods,
        fetchFoodsByName,
        getFavoriteFoods,
      },
    )
  },
)

BLOCKED BY:

Copilot AI review requested due to automatic review settings December 2, 2025 14:30
@marcuscastelo marcuscastelo self-assigned this Dec 2, 2025
@vercel
Copy link

vercel bot commented Dec 2, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Preview Comments Updated (UTC)
macroflows Ready Ready Preview Comment Dec 2, 2025 2:32pm

@marcuscastelo marcuscastelo changed the title Refactor search module and improve cached search logic [BLOCKED] Refactor search module and improve cached search logic Dec 2, 2025
@marcuscastelo marcuscastelo marked this pull request as draft December 2, 2025 14:32
Copilot finished reviewing on behalf of marcuscastelo December 2, 2025 14:36
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR refactors the search module by consolidating functionality from sections/search and the old modules/template-search into a unified modules/search structure. The refactoring improves architectural organization by moving UI components, state management, and business logic into a cohesive module following the codebase's established patterns. The cached search initialization logic is simplified by introducing a searchUseCases facade that uses createRoot for singleton initialization, consistent with other modules like authUseCases and dayUseCases.

Key Changes

  • Consolidated template search functionality into modules/search with proper separation of concerns (ui/, application/, infrastructure/, domain/)
  • Simplified cached search initialization by replacing separate cachedSearchEffects and cachedSearchCacheStore files with a unified searchUseCases facade
  • Updated all import paths across the codebase to reference the new module structure

Reviewed changes

Copilot reviewed 24 out of 28 changed files in this pull request and generated no comments.

Show a summary per file
File Description
src/sections/recipe/components/RecipeEditModal.tsx Updated import path from sections/search to modules/search
src/sections/item/components/ItemView/ItemEdit/ItemEditModal.tsx Updated import path from sections/search to modules/search
src/sections/day-diet/components/DayMeals.tsx Updated import path from sections/search to modules/search
src/sections/common/components/buttons/RemoveFromRecentButton.tsx Updated import path from modules/template-search to modules/search
src/sections/common/components/buttons/RemoveFromRecentButton.test.tsx Deleted test file (section UI components are not typically tested in this codebase)
src/routes/test-app.tsx Updated to use openTemplateSearchModal helper instead of manual modal setup
src/modules/search/ui/openTemplateSearchModal.tsx Updated import to reference TemplateSearchModal from modules/search/ui
src/modules/search/ui/TemplateSearchTabs.tsx New file - moved and consolidated from sections/search
src/modules/search/ui/TemplateSearchResults.tsx Updated imports to use modules/search paths
src/modules/search/ui/TemplateSearchResultItem.tsx New file - moved from sections/search with proper module imports
src/modules/search/ui/TemplateSearchModal.tsx Updated imports to use modules/search and modules/search/application paths
src/modules/search/ui/TemplateSearchBar.tsx Updated import from modules/template-search to modules/search
src/modules/search/ui/SearchLoadingIndicator.tsx New file - moved from sections/search with inline loading indicator
src/modules/search/infrastructure/tests/templateSearchTabPreference.test.ts Updated all imports to reference modules/search
src/modules/search/infrastructure/templateSearchTabPreference.ts Updated import to use modules/search/ui path
src/modules/search/infrastructure/supabase/realtime.ts Refactored to accept callbacks as parameters, removing direct cache store dependency
src/modules/search/infrastructure/signals/cachedSearchEffects.ts Deleted - logic moved to searchUseCases
src/modules/search/infrastructure/signals/cachedSearchCacheStore.ts Deleted - replaced by application/store/cachedSearchCacheStore.ts factory
src/modules/search/infrastructure/cachedSearchRepository.ts Simplified by removing cache management logic (now in searchUseCases)
src/modules/search/application/usecases/tests/templateSearchLogic.test.ts Updated imports to use modules/search paths
src/modules/search/application/usecases/templateSearchLogic.ts Updated import to reference modules/search/ui
src/modules/search/application/usecases/searchUseCases.ts New facade that encapsulates cached search initialization with createRoot pattern
src/modules/search/application/usecases/cachedSearchCrud.ts Refactored to export factory function instead of direct repository usage
src/modules/search/application/store/templateSearchState.ts Updated imports from modules/template-search to modules/search
src/modules/search/application/store/cachedSearchCacheStore.ts New factory function replacing the old signal-based store
src/modules/diet/food/infrastructure/api/application/apiFood.ts Updated to use searchUseCases instead of direct cachedSearchCrud import
src/modules/diet/food/application/usecases/foodCrud.ts Updated to use searchUseCases instead of direct cachedSearchCrud import

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants