If there is no session known locally, just re-fetch the whole routine

This commit is contained in:
Roland Geider
2025-03-19 10:15:43 +01:00
parent f65a0dfbc8
commit ea41b49051

View File

@@ -655,9 +655,16 @@ class RoutinesProvider with ChangeNotifier {
newLog.exerciseBase = (await _exerciseProvider.fetchAndSetExercise(log.exerciseId))!;
final plan = findById(newLog.routineId);
final session = plan.sessions.firstWhere((element) => element.session.id == newLog.sessionId);
session.logs.add(newLog);
notifyListeners();
// If there is no session known locally, just re-fetch everything
try {
final session = plan.sessions.firstWhere((element) => element.session.id == newLog.sessionId);
session.logs.add(newLog);
notifyListeners();
} on StateError {
await fetchAndSetRoutineFull(newLog.routineId);
}
return newLog;
}