Skip to content

Conversation

@mdmohsin7
Copy link
Member

close #4316

@mdmohsin7 mdmohsin7 merged commit 1a76328 into main Jan 22, 2026
1 check passed
@mdmohsin7 mdmohsin7 deleted the goals-toggle-fix branch January 22, 2026 07:32
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

This pull request implements the 'hide goals' toggle by adding a condition to check SharedPreferencesUtil().showGoalTrackerEnabled before rendering the goals-related widgets on both mobile and desktop conversation pages.

While the logic correctly gates the feature, the implementation has a significant drawback: it's not reactive. Accessing SharedPreferences directly in the build method means the UI won't update automatically when the user changes the setting. I've left comments on both modified files with a recommendation to use a ChangeNotifierProvider for managing this setting to ensure the UI responds instantly to user actions. This is a high-severity issue as it impacts user experience directly.

// Daily Score + Today Tasks + Goals section
if (hasAnyConversationsInSystem &&
!isSearchActive &&
SharedPreferencesUtil().showGoalTrackerEnabled)
Copy link
Contributor

Choose a reason for hiding this comment

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

high

Calling SharedPreferencesUtil() directly within the build method to control UI visibility can lead to a poor user experience. SharedPreferences is not reactive, meaning that when the user changes the showGoalTrackerEnabled setting (e.g., on a settings page), this widget will not automatically rebuild to reflect the change. The goals section will only hide or show after a rebuild is triggered by another state change.

To fix this, you should manage this setting using a reactive state management solution like Provider.

Recommendation:

  1. Create a SettingsProvider that uses ChangeNotifier.
  2. This provider should load the setting from SharedPreferences in its constructor.
  3. Expose the setting value through a getter.
  4. Create a method in the provider to update the setting. This method should update the local value, save it to SharedPreferences, and then call notifyListeners().
  5. In this widget, use context.watch<SettingsProvider>().showGoalTrackerEnabled to reactively listen to changes.

This will ensure the UI updates instantly when the user toggles the setting.

padding: EdgeInsets.symmetric(horizontal: 16, vertical: 8),
child: DailyScoreWidget(),
// Daily Score, Today's Tasks, and Goals Widgets
if (SharedPreferencesUtil().showGoalTrackerEnabled) ...[
Copy link
Contributor

Choose a reason for hiding this comment

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

high

Similar to the desktop page, calling SharedPreferencesUtil() directly in the build method is not reactive. When the showGoalTrackerEnabled setting is changed by the user, the UI will not update to hide or show the goals-related widgets until something else causes a rebuild.

For a responsive user experience, this setting should be managed by a reactive state manager like a ChangeNotifierProvider.

Recommendation:
I've left a more detailed comment on desktop_conversations_page.dart with a recommendation to use a SettingsProvider. The same approach should be applied here to ensure the UI updates immediately when the setting is toggled. You would then use context.watch<SettingsProvider>().showGoalTrackerEnabled in this if condition.

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.

Users request disable/hide Goals and Score from home screen - toggle not working

2 participants