mirror of
https://github.com/wger-project/flutter.git
synced 2026-02-18 00:17:48 +01:00
Slightly refactor the fetch session data part in the calendar.
In general, it doesn't make much sense that the sessions are the only data points that are loaded live every time, all the others are simply read from the respective providers. Hopefully all this can be removed when (if) we move to using a local sqlite db with powersync.
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of wger Workout Manager <https://github.com/wger-project>.
|
||||
* Copyright (C) 2020, 2021 wger Team
|
||||
* Copyright (c) 2026 wger Team
|
||||
*
|
||||
* wger Workout Manager is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
|
||||
@@ -134,35 +134,29 @@ class _DashboardCalendarWidgetState extends State<DashboardCalendarWidget>
|
||||
|
||||
// Process workout sessions
|
||||
final routinesProvider = context.read<RoutinesProvider>();
|
||||
await routinesProvider.fetchSessionData().then((sessions) {
|
||||
for (final session in sessions) {
|
||||
final date = DateFormatLists.format(session.date);
|
||||
if (!_events.containsKey(date)) {
|
||||
_events[date] = [];
|
||||
}
|
||||
var time = '';
|
||||
if (session.timeStart != null && session.timeEnd != null) {
|
||||
time = '(${timeToString(session.timeStart)} - ${timeToString(session.timeEnd)})';
|
||||
}
|
||||
|
||||
// Add events to lists
|
||||
_events[date]?.add(
|
||||
Event(
|
||||
EventType.session,
|
||||
'${i18n.impression}: ${session.impressionAsString(context)} $time',
|
||||
),
|
||||
);
|
||||
}
|
||||
});
|
||||
final sessions = await routinesProvider.fetchSessionData();
|
||||
if (!mounted) {
|
||||
return;
|
||||
}
|
||||
|
||||
for (final session in sessions) {
|
||||
final date = DateFormatLists.format(session.date);
|
||||
_events.putIfAbsent(date, () => []);
|
||||
|
||||
final time = (session.timeStart != null && session.timeEnd != null)
|
||||
? '(${timeToString(session.timeStart)} - ${timeToString(session.timeEnd)})'
|
||||
: '';
|
||||
|
||||
_events[date]?.add(
|
||||
Event(
|
||||
EventType.session,
|
||||
'${i18n.impression}: ${session.impressionAsString(context)}${time.isNotEmpty ? ' $time' : ''}',
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
// Process nutritional plans
|
||||
final NutritionPlansProvider nutritionProvider = Provider.of<NutritionPlansProvider>(
|
||||
context,
|
||||
listen: false,
|
||||
);
|
||||
final nutritionProvider = context.read<NutritionPlansProvider>();
|
||||
for (final plan in nutritionProvider.items) {
|
||||
for (final entry in plan.logEntriesValues.entries) {
|
||||
final date = DateFormatLists.format(entry.key);
|
||||
|
||||
Reference in New Issue
Block a user