-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix progress not changing when reviewing an environment
- Loading branch information
Showing
3 changed files
with
42 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import 'package:riverpod_annotation/riverpod_annotation.dart'; | ||
|
||
import '../models/environment_review.dart'; | ||
import 'artefact.dart'; | ||
import 'artefact_environment_reviews.dart'; | ||
|
||
part 'review_environment.g.dart'; | ||
|
||
@riverpod | ||
class ReviewEnvironment extends _$ReviewEnvironment { | ||
@override | ||
Future<void> build() async { | ||
return; | ||
} | ||
|
||
Future<void> review( | ||
EnvironmentReview review, | ||
int artefactId, | ||
) async { | ||
await ref | ||
.read(artefactEnvironmentReviewsProvider(artefactId).notifier) | ||
.updateReview(review); | ||
|
||
final environmentReviews = | ||
await ref.read(artefactEnvironmentReviewsProvider(artefactId).future); | ||
|
||
final newCompletedEnvironmentReviewsCount = environmentReviews.fold( | ||
0, | ||
(count, review) => count + (review.reviewDecision.isEmpty ? 0 : 1), | ||
); | ||
|
||
await ref | ||
.read(artefactProvider(artefactId).notifier) | ||
.updateCompletedEnvironmentReviewsCount( | ||
newCompletedEnvironmentReviewsCount, | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters