Refactor recent food module for improved structure and functionality#1438
Merged
marcuscastelo merged 31 commits intorc/v0.16.0from Mar 24, 2026
Merged
Refactor recent food module for improved structure and functionality#1438marcuscastelo merged 31 commits intorc/v0.16.0from
marcuscastelo merged 31 commits intorc/v0.16.0from
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Contributor
There was a problem hiding this comment.
Pull request overview
This PR restructures the recent food module by introducing a clean architecture pattern with distinct layers, moving components to more appropriate locations, and preparing the groundwork for real-time synchronization capabilities.
Key Changes
- Introduced a service layer (
recentFoodCrudService) to separate business logic from use case orchestration - Consolidated recent food operations into a centralized
recentFoodUseCasesmodule with consistent error handling and user feedback - Refactored the realtime update system to use dependency-injected callbacks instead of directly coupling to a cache store
- Moved
RemoveFromRecentButtonfrom common components to the recent-food module for better cohesion - Cleaned up database schema by removing deprecated
user_id_oldfields
Reviewed changes
Copilot reviewed 18 out of 18 changed files in this pull request and generated 9 comments.
Show a summary per file
| File | Description |
|---|---|
src/shared/supabase/supabase.ts |
Added TODO comment about implementing user-specific realtime subscriptions |
src/shared/supabase/database.types.ts |
Removed deprecated user_id_old fields from recent_foods table and added users_duplicate table |
src/sections/search/ui/openTemplateSearchModal.tsx |
Added template refetch on modal close to update recent foods list |
src/sections/search/components/TemplateSearchResultItem.tsx |
Updated import path for RemoveFromRecentButton after component relocation |
src/sections/search/components/TemplateSearchModal.tsx |
Simplified item tracking logic by delegating to recentFoodUseCases.touchRecentFoodForItem |
src/modules/template-search/application/usecases/templateSearchState.ts |
Updated to use recentFoodUseCases.fetchUserRecentFoodsAsTemplates and added TODO for reactive signals |
src/modules/template-search/application/tests/templateSearchLogic.test.ts |
Updated test mocks to use renamed fetchUserRecentFoodsAsTemplates method |
src/modules/template-search/application/templateSearchLogic.ts |
Renamed dependency from fetchUserRecentFoods to fetchUserRecentFoodsAsTemplates for clarity |
src/modules/recent-food/ui/tests/RemoveFromRecentButton.test.tsx |
Removed redundant API integration and toast promise tests, focusing on business logic tests |
src/modules/recent-food/ui/RemoveFromRecentButton.tsx |
Simplified to use recentFoodUseCases and removed empty catch block |
src/modules/recent-food/infrastructure/supabase/supabaseRecentFoodGateway.ts |
Added type export for RecentFoodGateway to support dependency injection |
src/modules/recent-food/infrastructure/supabase/realtime.ts |
Refactored to accept callback functions as parameters instead of directly coupling to cache store |
src/modules/recent-food/infrastructure/signals/recentFoodCacheStore.ts |
Deleted entire file as part of cache refactoring |
src/modules/recent-food/infrastructure/recentFoodRepository.ts |
Converted to factory function accepting gateway as parameter; improved error log messages with [NON-FATAL] prefix |
src/modules/recent-food/domain/recentFood.ts |
Removed comment-only line (cleanup) |
src/modules/recent-food/application/usecases/recentFoodUseCases.ts |
New consolidated use cases module with consistent error handling, toast notifications, and touchRecentFoodForItem orchestration |
src/modules/recent-food/application/usecases/recentFoodCrud.ts |
Deleted entire file, functionality moved to recentFoodUseCases.ts |
src/modules/recent-food/application/services/recentFoodCrudService.ts |
New service layer that wraps repository methods without side effects (no toasts/errors) |
Removed the display of guest terms acceptance status in the warning message.
Base automatically changed from
marcuscastelo/issue1447-remove-shims
to
marcuscastelo/issue1447
March 23, 2026 18:34
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Restructure the recent food module by moving components, simplifying data management, and enhancing real-time updates. This refactor improves code organization and reduces unnecessary exports.
Fix #1404