From de84c24e72a3b971be8891dae707bcd3b92de1f3 Mon Sep 17 00:00:00 2001 From: Roland Geider Date: Sat, 24 Jul 2021 21:55:55 +0200 Subject: [PATCH] Don't use the canonical form endpoint This was removed on the server --- lib/providers/workout_plans.dart | 19 ++++++++----------- pubspec.lock | 12 ++++++------ 2 files changed, 14 insertions(+), 17 deletions(-) diff --git a/lib/providers/workout_plans.dart b/lib/providers/workout_plans.dart index a58084ce3..796ab8a88 100644 --- a/lib/providers/workout_plans.dart +++ b/lib/providers/workout_plans.dart @@ -167,9 +167,9 @@ class WorkoutPlansProvider extends WgerBaseProvider with ChangeNotifier { /// Fetches a workout plan fully, i.e. with all corresponding child attributes Future fetchAndSetWorkoutPlanFull(int workoutId) async { - // Load a list of all settings so that we can search through it late + // Load a list of all settings so that we can search through it // - // This is a bit ugly, but makes saves sending lots of requests later on + // This is a bit ugly, but saves us sending lots of requests later on final allSettingsData = await fetch( makeUrl(_settingsUrlPath, query: {'limit': '1000'}), ); @@ -181,20 +181,17 @@ class WorkoutPlansProvider extends WgerBaseProvider with ChangeNotifier { plan = await fetchAndSetPlanSparse(workoutId); } - // Plan - final fullPlanData = await fetch( - makeUrl(_workoutPlansUrlPath, id: workoutId, objectMethod: 'canonical_representation'), - ); - // Days List days = []; - for (var dayData in fullPlanData['day_list']) { - final day = Day.fromJson(dayData['obj']); + final daysData = await fetch(makeUrl(_daysUrlPath, query: {'training': plan.id.toString()})); + for (final dayEntry in daysData['results']) { + final day = Day.fromJson(dayEntry); // Sets List sets = []; - for (var setData in dayData['set_list']) { - final workoutSet = Set.fromJson(setData['obj']); + final setData = await fetch(makeUrl(_setsUrlPath, query: {'exerciseday': day.id.toString()})); + for (final setEntry in setData['results']) { + final workoutSet = Set.fromJson(setEntry); fetchComputedSettings(workoutSet); // request! diff --git a/pubspec.lock b/pubspec.lock index 3fdc8aa56..358fc7ac3 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -112,7 +112,7 @@ packages: name: camera url: "https://pub.dartlang.org" source: hosted - version: "0.8.1+4" + version: "0.8.1+5" camera_platform_interface: dependency: transitive description: @@ -189,7 +189,7 @@ packages: name: code_builder url: "https://pub.dartlang.org" source: hosted - version: "4.0.0" + version: "4.1.0" collection: dependency: "direct main" description: @@ -292,7 +292,7 @@ packages: name: flutter_keyboard_visibility url: "https://pub.dartlang.org" source: hosted - version: "5.0.2" + version: "5.0.3" flutter_keyboard_visibility_platform_interface: dependency: transitive description: @@ -433,14 +433,14 @@ packages: name: image_picker url: "https://pub.dartlang.org" source: hosted - version: "0.8.1+4" + version: "0.8.2" image_picker_for_web: dependency: transitive description: name: image_picker_for_web url: "https://pub.dartlang.org" source: hosted - version: "2.1.0" + version: "2.1.1" image_picker_platform_interface: dependency: transitive description: @@ -517,7 +517,7 @@ packages: name: mockito url: "https://pub.dartlang.org" source: hosted - version: "5.0.10" + version: "5.0.12" nested: dependency: transitive description: