Skip to content

Commit

Permalink
Fix GradeDetailsViewModel tests
Browse files Browse the repository at this point in the history
  • Loading branch information
XavierPaquet-Rapold committed Jan 21, 2024
1 parent bb2b900 commit cf48052
Showing 1 changed file with 12 additions and 20 deletions.
32 changes: 12 additions & 20 deletions lib/core/viewmodels/grades_details_viewmodel.dart
Original file line number Diff line number Diff line change
Expand Up @@ -32,21 +32,15 @@ class GradesDetailsViewModel extends FutureViewModel<Course> {

@override
Future<Course> futureToRun() async {
setBusyForObject(course, true);

// ignore: return_type_invalid_for_catch_error
await _courseRepository
.getCourseSummary(course)
// ignore: return_type_invalid_for_catch_error
.catchError(onError)
.then((value) {
course = value;
}).whenComplete(() {
try {
setBusyForObject(course, true);
course = await _courseRepository.getCourseSummary(course);
notifyListeners();
} catch(e) {
onError(e);
} finally {
setBusyForObject(course, false);
});

notifyListeners();

}
return course;
}

Expand All @@ -66,16 +60,14 @@ class GradesDetailsViewModel extends FutureViewModel<Course> {
Future<bool> refresh() async {
try {
setBusyForObject(course, true);
await _courseRepository.getCourseSummary(course).then((value) {
course = value;
});
course = await _courseRepository.getCourseSummary(course);
notifyListeners();
setBusyForObject(course, false);
return true;
} on Exception catch (error) {
} catch (error) {
onError(error);
setBusyForObject(course, false);
return false;
} finally {
setBusyForObject(course, false);
}
}

Expand Down

0 comments on commit cf48052

Please sign in to comment.