Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -319,29 +319,31 @@ class _DesktopConversationsPageState extends State<DesktopConversationsPage>
),
),

// Daily Score + Today Tasks + Goals section (only when not searching)
if (hasAnyConversationsInSystem && !isSearchActive)
// 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.

SliverToBoxAdapter(
child: FadeTransition(
opacity: _fadeAnimation,
child: Container(
padding: const EdgeInsets.fromLTRB(32, 0, 32, 24),
height: 260, // Height to fit 3 tasks/goals
child: Row(
child: const Row(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
// Daily Score Widget
const Expanded(
Expanded(
child: DesktopDailyScoreWidget(),
),
const SizedBox(width: 16),
SizedBox(width: 16),
// Today Tasks Widget
const Expanded(
Expanded(
child: DesktopTodayTasksWidget(),
),
const SizedBox(width: 16),
SizedBox(width: 16),
// Goals Widget
const Expanded(
Expanded(
child: DesktopGoalsWidget(),
),
],
Expand Down
31 changes: 15 additions & 16 deletions app/lib/pages/conversations/conversations_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import 'package:omi/pages/conversations/widgets/processing_capture.dart';
import 'package:omi/pages/conversations/widgets/search_result_header_widget.dart';
import 'package:omi/pages/conversations/widgets/search_widget.dart';
import 'package:omi/pages/conversations/widgets/today_tasks_widget.dart';
import 'package:omi/backend/preferences.dart';
import 'package:omi/providers/capture_provider.dart';
import 'package:omi/providers/conversation_provider.dart';
import 'package:omi/providers/folder_provider.dart';
Expand Down Expand Up @@ -207,24 +208,22 @@ class _ConversationsPageState extends State<ConversationsPage> with AutomaticKee
const SliverToBoxAdapter(child: SearchResultHeaderWidget()),
getProcessingConversationsWidget(convoProvider.processingConversations),

// Daily Score Widget
const SliverToBoxAdapter(
child: Padding(
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.

const SliverToBoxAdapter(
child: Padding(
padding: EdgeInsets.symmetric(horizontal: 16, vertical: 8),
child: DailyScoreWidget(),
),
),
),

// Today's Tasks (top 3)
const SliverToBoxAdapter(
child: Padding(
padding: EdgeInsets.only(top: 8, bottom: 8),
child: TodayTasksWidget(),
const SliverToBoxAdapter(
child: Padding(
padding: EdgeInsets.only(top: 8, bottom: 8),
child: TodayTasksWidget(),
),
),
),

// Goals Widget (up to 3 goals)
SliverToBoxAdapter(child: GoalsWidget(key: _goalsWidgetKey)),
SliverToBoxAdapter(child: GoalsWidget(key: _goalsWidgetKey)),
],

// Conversations section header
SliverToBoxAdapter(
Expand Down