Skip to content

fix(723): water unit update fails#726

Merged
CodeWithCJ merged 1 commit intoCodeWithCJ:mainfrom
Sim-sat:main
Feb 23, 2026
Merged

fix(723): water unit update fails#726
CodeWithCJ merged 1 commit intoCodeWithCJ:mainfrom
Sim-sat:main

Conversation

@Sim-sat
Copy link
Contributor

@Sim-sat Sim-sat commented Feb 23, 2026

Description

Fixes #723 issue preventing change of the water unit. This was caused by not saving the selected state locally and not calling the update function. The setWaterDisplayUnit is only changing the state locally without saving it to the server. I also removed the window.reload() since it's not needed.

@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @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 resolves an issue where users were unable to successfully update their water unit preferences. The problem stemmed from a lack of local state management for the selected unit and the omission of a server-side update call. The changes introduce a local state variable to track the water unit selection and ensure that the saveAllPreferences function is invoked when the unit is changed, thereby persisting the user's choice. Additionally, an unnecessary page reload after saving preferences has been removed, streamlining the user experience.

Highlights

  • Bug Fix: Resolved an issue (Fixes [Bug]: Water Units setting not changeable #723) where the water unit preference was not updating or saving correctly due to missing local state management and an omitted server update call.
  • State Management Improvement: Introduced local state for water display units in both the Goals and Settings pages to ensure proper display and handling of user selections before persisting to the server.
  • Preference Persistence: Ensured that changes to the water display unit are correctly saved to the server by explicitly calling the saveAllPreferences function.
  • User Experience Enhancement: Removed an unnecessary window.location.reload() call, preventing full page refreshes and providing a smoother user experience after saving preferences.
  • UI Correction: Corrected a UI option in the Settings page, changing the 'cup' unit selection to 'liter' for water display units.
Changelog
  • SparkyFitnessFrontend/src/pages/Goals/WaterAndExerciseFields.tsx
    • Imported the useState hook.
    • Introduced a localWaterUnit state variable, initialized with the global water_display_unit.
    • Updated the water goal display and calculation logic to use localWaterUnit.
    • Modified the Select component's onValueChange handler to call saveAllPreferences and update both the global setWaterDisplayUnit and localWaterUnit.
    • Destructured saveAllPreferences from usePreferences.
  • SparkyFitnessFrontend/src/pages/Settings/SettingsPage.tsx
    • Introduced a localWaterUnit state variable, initialized with the global water_display_unit.
    • Updated the saveAllPreferences call within the handleSavePreferences function to include water_display_unit from localWaterUnit.
    • Called setWaterDisplayUnit with localWaterUnit after saving preferences.
    • Removed the window.location.reload() call.
    • Modified the water unit Select component to use localWaterUnit for its value and onValueChange handler.
    • Corrected a SelectItem value from "cup" to "liter" for water unit options.
Activity
  • No specific activity (comments, reviews, or progress updates) has been recorded for this pull request yet.
Using Gemini Code Assist

The 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 /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

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 .gemini/ folder in the base of the repository. Detailed instructions can be found here.

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

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

The pull request successfully addresses the issue where water unit changes were not being persisted to the server. By adding calls to saveAllPreferences and managing local state for the selected unit, the UI now correctly reflects and saves the user's preference. I have provided some feedback regarding redundant state in one component and a missing synchronization effect in another to ensure the UI remains consistent with the underlying context data.

@CodeWithCJ CodeWithCJ merged commit a8d12b2 into CodeWithCJ:main Feb 23, 2026
6 checks passed
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.

[Bug]: Water Units setting not changeable

2 participants