Skip to content

Commit

Permalink
Fix setting grade type weights for subject and term (#1476)
Browse files Browse the repository at this point in the history
## Description

This was because I used `_getSubject()` and after calling
`changeGradeTypeWeightForSubject()` Firestore wasn't quick enough to
pull the update. Therefore, `_getSubject` returned the old subject. Same
for the term.

## Demo


https://github.com/SharezoneApp/sharezone-app/assets/24459435/9687b3c0-51ad-4d4c-bb53-ee1e51716abc
  • Loading branch information
nilsreichardt authored Apr 21, 2024
1 parent 9c2e02b commit 707d0c5
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ class SubjectSettingsPageController extends ChangeNotifier {
weight: weight,
);
_selectableGradeTypes = gradesService.getPossibleGradeTypes();
_weights = _getSubject()!.gradeTypeWeights;
_weights = _weights.add(gradeTypeId, weight);
state = SubjectSettingsLoaded(view);
notifyListeners();
}
Expand All @@ -118,7 +118,7 @@ class SubjectSettingsPageController extends ChangeNotifier {
gradeType: gradeTypeId,
);
_selectableGradeTypes = gradesService.getPossibleGradeTypes();
_weights = _getSubject()!.gradeTypeWeights;
_weights = _weights.remove(gradeTypeId);
state = SubjectSettingsLoaded(view);
notifyListeners();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ class TermSettingsPageController extends ChangeNotifier {
gradeType: gradeTypeId,
weight: weight,
);
_weights = _getTerm()!.gradeTypeWeightings;
_weights = _weights.add(gradeTypeId, weight);
state = TermSettingsLoaded(view);
notifyListeners();
}
Expand All @@ -149,7 +149,7 @@ class TermSettingsPageController extends ChangeNotifier {
termId: termId,
gradeType: gradeTypeId,
);
_weights = _getTerm()!.gradeTypeWeightings;
_weights = _weights.remove(gradeTypeId);
state = TermSettingsLoaded(view);
notifyListeners();
}
Expand Down

0 comments on commit 707d0c5

Please sign in to comment.