mirror of
https://github.com/wger-project/flutter.git
synced 2026-02-18 00:17:48 +01:00
The repetition and weight units can be null
and don't need to be loaded in this case
This commit is contained in:
@@ -289,12 +289,16 @@ class RoutinesProvider with ChangeNotifier {
|
||||
for (final slotEntry in slot.entries) {
|
||||
slotEntry.exerciseObj =
|
||||
(await _exerciseProvider.fetchAndSetExercise(slotEntry.exerciseId))!;
|
||||
slotEntry.repetitionUnitObj = _repetitionUnits.firstWhere(
|
||||
(e) => e.id == slotEntry.repetitionUnitId,
|
||||
);
|
||||
slotEntry.weightUnitObj = _weightUnits.firstWhere(
|
||||
(e) => e.id == slotEntry.weightUnitId,
|
||||
);
|
||||
if (slotEntry.repetitionUnitId != null) {
|
||||
slotEntry.repetitionUnitObj = _repetitionUnits.firstWhere(
|
||||
(e) => e.id == slotEntry.repetitionUnitId,
|
||||
);
|
||||
}
|
||||
if (slotEntry.weightUnitId != null) {
|
||||
slotEntry.weightUnitObj = _weightUnits.firstWhere(
|
||||
(e) => e.id == slotEntry.weightUnitId,
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -306,8 +310,12 @@ class RoutinesProvider with ChangeNotifier {
|
||||
routine.sessions = List<WorkoutSessionApi>.from(sessionDataEntries);
|
||||
for (final session in routine.sessions) {
|
||||
for (final log in session.logs) {
|
||||
log.weightUnit = _weightUnits.firstWhere((e) => e.id == log.weightUnitId);
|
||||
log.repetitionUnit = _repetitionUnits.firstWhere((e) => e.id == log.repetitionsUnitId);
|
||||
if (log.weightUnitId != null) {
|
||||
log.weightUnit = _weightUnits.firstWhere((e) => e.id == log.weightUnitId);
|
||||
}
|
||||
if (log.repetitionsUnitId != null) {
|
||||
log.repetitionUnit = _repetitionUnits.firstWhere((e) => e.id == log.repetitionsUnitId);
|
||||
}
|
||||
log.exerciseBase = (await _exerciseProvider.fetchAndSetExercise(log.exerciseId))!;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user