refactor(diary): migrate diary to tanstack query and fix bugs#692
refactor(diary): migrate diary to tanstack query and fix bugs#692CodeWithCJ merged 3 commits intoCodeWithCJ:mainfrom
Conversation
- migrated the whole /pages/diary directory to tanstack query - fixed unnecessary use of window listeners from CodeWithCJ#690 - fixes bug preventing to upload images - splitting components in seperate files - decouple logic from ui by moving the functions to utils
Summary of ChangesHello @Sim-sat, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request represents a significant refactoring effort focused on enhancing the diary functionality. By migrating to Tanstack Query, the application benefits from improved data fetching, caching, and synchronization, leading to a more robust and maintainable codebase. The changes also include crucial bug fixes, extensive code cleanup, and dependency updates, all contributing to a more stable and efficient user experience. Highlights
Changelog
Activity
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
3afe57c to
aa2dc94
Compare
There was a problem hiding this comment.
Code Review
This pull request primarily refactors the frontend's data fetching and state management by migrating several components and services to use TanStack Query hooks. Key changes include introducing new query keys for diary and exercise search data, creating dedicated hooks for daily progress, food entries, and meal types, and updating components like MealBuilder, DailyProgress, ExerciseCard, and various dialogs to consume these new hooks. This refactoring aims to centralize data management, reduce boilerplate, and improve caching. Additionally, eslint-plugin-unused-imports was added to the project configuration, and several dependencies in package-lock.json were updated. Minor cleanups include removing unused imports and console.log statements, and addressing a backend workaround for image URLs in exercise entry updates. Review comments highlight several issues: a circular dependency for MealTotals (now resolved by moving it to constants/nutrients.ts), incorrect unit conversions for calories in exercise entry forms, missing UI inputs for exercise details, a stale state issue in LogExerciseEntryDialog due to an insufficient key, and a redundant check in getMealData.
SparkyFitnessFrontend/src/pages/Diary/EditExerciseDatabaseDialog.tsx
Outdated
Show resolved
Hide resolved
SparkyFitnessFrontend/src/pages/Diary/LogExerciseEntryDialog.tsx
Outdated
Show resolved
Hide resolved
SparkyFitnessFrontend/src/pages/Diary/LogExerciseEntryDialog.tsx
Outdated
Show resolved
Hide resolved
SparkyFitnessFrontend/src/pages/Diary/EditExerciseDatabaseDialog.tsx
Outdated
Show resolved
Hide resolved
|
/gemini review |
There was a problem hiding this comment.
Code Review
This is an impressive refactoring effort. Migrating the entire diary feature to TanStack Query is a significant improvement for state management, data consistency, and performance. The code is now much cleaner, more organized, and follows modern React best practices by separating concerns into custom hooks, utility functions, and presentational components. The bug fixes, especially for image uploads, and the cleanup of unused code and dependencies are also valuable contributions. The suggestions to ensure components with internal state are correctly reset when their props change, which is a common pattern to ensure robustness in complex UIs, have been kept. Overall, this is a high-quality pull request that greatly improves the maintainability of the codebase.
Description
npm run format -- --fixto remove all unused imports directly