Skip to content

Commit

Permalink
Updated visualization dropdown to default to last recorded exercise name
Browse files Browse the repository at this point in the history
  • Loading branch information
andreped committed Sep 16, 2024
1 parent 020090c commit 886c31f
Showing 1 changed file with 13 additions and 5 deletions.
18 changes: 13 additions & 5 deletions lib/tabs/visualization.dart
Original file line number Diff line number Diff line change
Expand Up @@ -71,12 +71,20 @@ class _VisualizationTabState extends State<VisualizationTab> {
print('Error fetching names: $e');
}

// render first exercise by default if any
// render last recorded exercise by default if any
if (_exerciseNames.isNotEmpty && _selectedExercise == null) {
setState(() {
_selectedExercise = _exerciseNames.first;
_fetchDataPoints(_selectedExercise);
});
try {
String? lastRecordedExercise =
await _dbHelper.getLastLoggedExerciseName();
if (lastRecordedExercise != null) {
setState(() {
_selectedExercise = lastRecordedExercise;
_fetchDataPoints(_selectedExercise);
});
}
} catch (e) {
print('Error fetching last recorded exercise: $e');
}
}
}

Expand Down

0 comments on commit 886c31f

Please sign in to comment.