From c5dbcc27efbe81ac81d71d050d573bc6df37e163 Mon Sep 17 00:00:00 2001 From: Roland Geider Date: Wed, 29 Apr 2026 10:56:17 +0200 Subject: [PATCH] Extract routines repository to its own file --- lib/providers/nutrition_notifier.g.dart | 2 +- lib/providers/routines.dart | 272 +-------------- lib/providers/routines.g.dart | 44 +-- lib/providers/routines_repository.dart | 309 ++++++++++++++++++ lib/providers/routines_repository.g.dart | 52 +++ test/routine/day_form_test.dart | 6 +- test/routine/day_form_test.mocks.dart | 10 +- test/routine/forms/slot_form_test.dart | 1 + test/routine/forms/slot_form_test.mocks.dart | 10 +- test/routine/routine_edit_test.dart | 2 +- test/routine/routine_edit_test.mocks.dart | 10 +- test/routine/routine_form_test.dart | 2 +- test/routine/routine_form_test.mocks.dart | 10 +- .../routines_provider_repository_test.dart | 2 +- test/routine/routines_provider_test.dart | 1 + .../routine/routines_provider_test.mocks.dart | 10 +- test/routine/routines_screen_test.dart | 2 +- test/routine/routines_screen_test.mocks.dart | 10 +- test/routine/slot_entry_form_test.dart | 1 + test/routine/slot_entry_form_test.mocks.dart | 10 +- 20 files changed, 381 insertions(+), 385 deletions(-) create mode 100644 lib/providers/routines_repository.dart create mode 100644 lib/providers/routines_repository.g.dart diff --git a/lib/providers/nutrition_notifier.g.dart b/lib/providers/nutrition_notifier.g.dart index 0be06c4ef..83ace7b20 100644 --- a/lib/providers/nutrition_notifier.g.dart +++ b/lib/providers/nutrition_notifier.g.dart @@ -33,7 +33,7 @@ final class NutritionNotifierProvider NutritionNotifier create() => NutritionNotifier(); } -String _$nutritionNotifierHash() => r'cddf4167586ddc55c031d097be7af02e7e1dec33'; +String _$nutritionNotifierHash() => r'8b4b7cfe44572e929265e43dc3241c67833fec12'; abstract class _$NutritionNotifier extends $StreamNotifier { Stream build(); diff --git a/lib/providers/routines.dart b/lib/providers/routines.dart index 8ab64d659..5bbf56857 100644 --- a/lib/providers/routines.dart +++ b/lib/providers/routines.dart @@ -17,7 +17,6 @@ */ import 'package:collection/collection.dart'; -import 'package:drift/drift.dart' show OrderingTerm; import 'package:logging/logging.dart'; import 'package:riverpod_annotation/riverpod_annotation.dart'; import 'package:wger/database/powersync/database.dart'; @@ -30,10 +29,9 @@ import 'package:wger/models/workouts/session.dart'; import 'package:wger/models/workouts/slot.dart'; import 'package:wger/models/workouts/slot_entry.dart'; import 'package:wger/models/workouts/weight_unit.dart'; -import 'package:wger/providers/base_provider.dart'; import 'package:wger/providers/exercises.dart'; import 'package:wger/providers/helpers.dart'; -import 'package:wger/providers/wger_base.dart'; +import 'package:wger/providers/routines_repository.dart'; import 'package:wger/providers/workout_session.dart'; part 'routines.g.dart'; @@ -325,271 +323,3 @@ class RoutinesRiverpod extends _$RoutinesRiverpod { await repo.handleConfigServer(entry, value, type); } } - -@Riverpod(keepAlive: true) -RoutinesRepository routinesRepository(Ref ref) { - final baseProvider = ref.watch(wgerBaseProvider); - final db = ref.read(driftPowerSyncDatabase); - return RoutinesRepository(baseProvider, db); -} - -class RoutinesRepository { - RoutinesRepository(this._baseProvider, this._db); - - final _logger = Logger('RoutinesRepository'); - final WgerBaseProvider _baseProvider; - final DriftPowersyncDatabase _db; - static const _routinesUrlPath = 'routine'; - static const _routinesStructureSubpath = 'structure'; - static const _routinesDateSequenceDisplaySubpath = 'date-sequence-display'; - static const _routinesDateSequenceGymSubpath = 'date-sequence-gym'; - static const _daysUrlPath = 'day'; - static const _slotsUrlPath = 'slot'; - static const _slotEntriesUrlPath = 'slot-entry'; - static const _routineConfigSets = 'sets-config'; - static const _routineConfigMaxSets = 'max-sets-config'; - static const _routineConfigWeights = 'weight-config'; - static const _routineConfigMaxWeights = 'max-weight-config'; - static const _routineConfigRepetitions = 'repetitions-config'; - static const _routineConfigMaxRepetitions = 'max-repetitions-config'; - static const _routineConfigRir = 'rir-config'; - static const _routineConfigMaxRir = 'max-rir-config'; - static const _routineConfigRestTime = 'rest-config'; - static const _routineConfigMaxRestTime = 'max-rest-config'; - - /* - * Routines - */ - Future fetchAndSetRoutineFullServer(int routineId) async { - // Fetch structure and computed data - final results = await Future.wait([ - _baseProvider.fetch( - _baseProvider.makeUrl( - _routinesUrlPath, - objectMethod: _routinesStructureSubpath, - id: routineId, - ), - ), - _baseProvider.fetch( - _baseProvider.makeUrl( - _routinesUrlPath, - id: routineId, - objectMethod: _routinesDateSequenceDisplaySubpath, - ), - ), - _baseProvider.fetch( - _baseProvider.makeUrl( - _routinesUrlPath, - id: routineId, - objectMethod: _routinesDateSequenceGymSubpath, - ), - ), - ]); - - final routine = Routine.fromJson(results[0] as Map); - final dayData = results[1] as List; - final dayDataGym = results[2] as List; - - routine.dayData = dayData.map((entry) => DayData.fromJson(entry)).toList(); - routine.dayDataGym = dayDataGym.map((entry) => DayData.fromJson(entry)).toList(); - - return routine; - } - - Future addRoutineServer(Routine routine) async { - final data = await _baseProvider.post( - routine.toJson(), - _baseProvider.makeUrl(_routinesUrlPath), - ); - return Routine.fromJson(data); - } - - Future editRoutineServer(Routine routine) async { - await _baseProvider.patch( - routine.toJson(), - _baseProvider.makeUrl(_routinesUrlPath, id: routine.id), - ); - return fetchAndSetRoutineFullServer(routine.id!); - } - - Future deleteRoutineServer(int id) async { - await _baseProvider.deleteRequest(_routinesUrlPath, id); - } - - /// Streams all routines from the local PowerSync-backed Drift table. - /// - /// Sort matches Django's `Routine.Meta.ordering = ['-start', '-created']` so - /// that REST responses and PowerSync emissions agree on the row order. The - /// UI takes the first row as the active routine ([RoutinesState.currentRoutine]) - /// and [addRoutine]'s optimistic insertion assumes newest-first. - Stream> watchAllDrift() { - _logger.finer('Watching all local routines'); - return (_db.select(_db.routineTable)..orderBy([ - (t) => OrderingTerm.desc(t.start), - (t) => OrderingTerm.desc(t.created), - ])) - .watch(); - } - - /// Updates a routine via the local Drift table - Future editLocalDrift(Routine routine) async { - final id = routine.id; - if (id == null) { - throw StateError('Cannot edit a routine without id'); - } - _logger.finer('Updating local routine $id'); - await (_db.update( - _db.routineTable, - )..where((t) => t.id.equals(id))).write(routine.toCompanion()); - } - - /// Deletes a routine via the local Drift table - Future deleteLocalDrift(int id) async { - _logger.finer('Deleting local routine $id'); - await (_db.delete(_db.routineTable)..where((t) => t.id.equals(id))).go(); - } - - /* - * Days - */ - Future addDayServer(Day day) async { - final data = await _baseProvider.post( - day.toJson(), - _baseProvider.makeUrl(_daysUrlPath), - ); - day = Day.fromJson(data); - - fetchAndSetRoutineFullServer(day.routineId); - - return day; - } - - Future editDayServer(Day day) async { - await _baseProvider.patch( - day.toJson(), - _baseProvider.makeUrl(_daysUrlPath, id: day.id), - ); - } - - Future deleteDayServer(int dayId) async { - await _baseProvider.deleteRequest(_daysUrlPath, dayId); - } - - /* - * Slots - */ - Future addSlotServer(Slot slot) async { - final data = await _baseProvider.post( - slot.toJson(), - _baseProvider.makeUrl(_slotsUrlPath), - ); - final newSlot = Slot.fromJson(data); - return newSlot; - } - - Future deleteSlotServer(int slotId) async { - await _baseProvider.deleteRequest(_slotsUrlPath, slotId); - } - - Future editSlotServer(Slot slot) async { - await _baseProvider.patch( - slot.toJson(), - _baseProvider.makeUrl(_slotsUrlPath, id: slot.id), - ); - } - - /* - * Slot entries - */ - Future addSlotEntryServer(SlotEntry entry) async { - final data = await _baseProvider.post( - entry.toJson(), - _baseProvider.makeUrl(_slotEntriesUrlPath), - ); - return SlotEntry.fromJson(data); - } - - Future deleteSlotEntryServer(int id) async { - await _baseProvider.deleteRequest(_slotEntriesUrlPath, id); - } - - Future editSlotEntryServer(SlotEntry entry) async { - await _baseProvider.patch( - entry.toJson(), - _baseProvider.makeUrl(_slotEntriesUrlPath, id: entry.id), - ); - } - - /* - * Configs - */ - String _getConfigUrl(ConfigType type) { - switch (type) { - case ConfigType.sets: - return _routineConfigSets; - case ConfigType.maxSets: - return _routineConfigMaxSets; - case ConfigType.weight: - return _routineConfigWeights; - case ConfigType.maxWeight: - return _routineConfigMaxWeights; - case ConfigType.repetitions: - return _routineConfigRepetitions; - case ConfigType.maxRepetitions: - return _routineConfigMaxRepetitions; - case ConfigType.rir: - return _routineConfigRir; - case ConfigType.maxRir: - return _routineConfigMaxRir; - case ConfigType.rest: - return _routineConfigRestTime; - case ConfigType.maxRest: - return _routineConfigMaxRestTime; - } - } - - Future editConfigServer(BaseConfig config, ConfigType type) async { - final data = await _baseProvider.patch( - config.toJson(), - _baseProvider.makeUrl(_getConfigUrl(type), id: config.id), - ); - - return BaseConfig.fromJson(data); - } - - Future addConfigServer(BaseConfig config, ConfigType type) async { - final data = await _baseProvider.post( - config.toJson(), - _baseProvider.makeUrl(_getConfigUrl(type)), - ); - return BaseConfig.fromJson(data); - } - - Future deleteConfigServer(int id, ConfigType type) async { - await _baseProvider.deleteRequest(_getConfigUrl(type), id); - } - - Future handleConfigServer(SlotEntry entry, num? value, ConfigType type) async { - final configs = entry.getConfigsByType(type); - final config = configs.isNotEmpty ? configs.first : null; - // final value = input.isNotEmpty ? num.parse(input) : null; - - if (value == null && config != null) { - // Value removed, delete entry - configs.removeWhere((c) => c.id! == config.id!); - await deleteConfigServer(config.id!, type); - } else if (config != null) { - // Update existing value - configs.first.value = value!; - await editConfigServer(configs.first, type); - } else if (value != null && config == null) { - // Create new config - configs.add( - await addConfigServer( - BaseConfig.firstIteration(value, entry.id!), - type, - ), - ); - } - } -} diff --git a/lib/providers/routines.g.dart b/lib/providers/routines.g.dart index ac09c753d..a6d48b015 100644 --- a/lib/providers/routines.g.dart +++ b/lib/providers/routines.g.dart @@ -111,7 +111,7 @@ final class RoutinesRiverpodProvider RoutinesRiverpod create() => RoutinesRiverpod(); } -String _$routinesRiverpodHash() => r'd98b72296e7fcf0134123452c5838991d4d80a27'; +String _$routinesRiverpodHash() => r'9574d6cbb8701111e8ec1c8c60081bed56aadc3c'; abstract class _$RoutinesRiverpod extends $StreamNotifier { Stream build(); @@ -130,45 +130,3 @@ abstract class _$RoutinesRiverpod extends $StreamNotifier { element.handleCreate(ref, build); } } - -@ProviderFor(routinesRepository) -final routinesRepositoryProvider = RoutinesRepositoryProvider._(); - -final class RoutinesRepositoryProvider - extends $FunctionalProvider - with $Provider { - RoutinesRepositoryProvider._() - : super( - from: null, - argument: null, - retry: null, - name: r'routinesRepositoryProvider', - isAutoDispose: false, - dependencies: null, - $allTransitiveDependencies: null, - ); - - @override - String debugGetCreateSourceHash() => _$routinesRepositoryHash(); - - @$internal - @override - $ProviderElement $createElement( - $ProviderPointer pointer, - ) => $ProviderElement(pointer); - - @override - RoutinesRepository create(Ref ref) { - return routinesRepository(ref); - } - - /// {@macro riverpod.override_with_value} - Override overrideWithValue(RoutinesRepository value) { - return $ProviderOverride( - origin: this, - providerOverride: $SyncValueProvider(value), - ); - } -} - -String _$routinesRepositoryHash() => r'249951c94887d0ff4882d7a88bd9dcfb25282f4e'; diff --git a/lib/providers/routines_repository.dart b/lib/providers/routines_repository.dart new file mode 100644 index 000000000..72e8d62d3 --- /dev/null +++ b/lib/providers/routines_repository.dart @@ -0,0 +1,309 @@ +/* + * This file is part of wger Workout Manager . + * 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 + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +import 'package:drift/drift.dart' show OrderingTerm; +import 'package:logging/logging.dart'; +import 'package:riverpod_annotation/riverpod_annotation.dart'; +import 'package:wger/database/powersync/database.dart'; +import 'package:wger/models/workouts/base_config.dart'; +import 'package:wger/models/workouts/day.dart'; +import 'package:wger/models/workouts/day_data.dart'; +import 'package:wger/models/workouts/routine.dart'; +import 'package:wger/models/workouts/slot.dart'; +import 'package:wger/models/workouts/slot_entry.dart'; +import 'package:wger/providers/base_provider.dart'; +import 'package:wger/providers/wger_base.dart'; + +part 'routines_repository.g.dart'; + +@Riverpod(keepAlive: true) +RoutinesRepository routinesRepository(Ref ref) { + final baseProvider = ref.watch(wgerBaseProvider); + final db = ref.read(driftPowerSyncDatabase); + return RoutinesRepository(baseProvider, db); +} + +/// Data access for routine-related entities. +/// +/// HTTP for everything that hasn't been migrated to PowerSync yet (creation +/// of routines, days, slots, slot entries, configs, …). Top-level [Routine] +/// reads as well as edit/delete go through the local PowerSync-backed Drift +/// table — see [watchAllDrift], [editLocalDrift], [deleteLocalDrift]. +class RoutinesRepository { + RoutinesRepository(this._baseProvider, this._db); + + final _logger = Logger('RoutinesRepository'); + final WgerBaseProvider _baseProvider; + final DriftPowersyncDatabase _db; + static const _routinesUrlPath = 'routine'; + static const _routinesStructureSubpath = 'structure'; + static const _routinesDateSequenceDisplaySubpath = 'date-sequence-display'; + static const _routinesDateSequenceGymSubpath = 'date-sequence-gym'; + static const _daysUrlPath = 'day'; + static const _slotsUrlPath = 'slot'; + static const _slotEntriesUrlPath = 'slot-entry'; + static const _routineConfigSets = 'sets-config'; + static const _routineConfigMaxSets = 'max-sets-config'; + static const _routineConfigWeights = 'weight-config'; + static const _routineConfigMaxWeights = 'max-weight-config'; + static const _routineConfigRepetitions = 'repetitions-config'; + static const _routineConfigMaxRepetitions = 'max-repetitions-config'; + static const _routineConfigRir = 'rir-config'; + static const _routineConfigMaxRir = 'max-rir-config'; + static const _routineConfigRestTime = 'rest-config'; + static const _routineConfigMaxRestTime = 'max-rest-config'; + + /* + * Routines + */ + Future fetchAndSetRoutineFullServer(int routineId) async { + // Fetch structure and computed data + final results = await Future.wait([ + _baseProvider.fetch( + _baseProvider.makeUrl( + _routinesUrlPath, + objectMethod: _routinesStructureSubpath, + id: routineId, + ), + ), + _baseProvider.fetch( + _baseProvider.makeUrl( + _routinesUrlPath, + id: routineId, + objectMethod: _routinesDateSequenceDisplaySubpath, + ), + ), + _baseProvider.fetch( + _baseProvider.makeUrl( + _routinesUrlPath, + id: routineId, + objectMethod: _routinesDateSequenceGymSubpath, + ), + ), + ]); + + final routine = Routine.fromJson(results[0] as Map); + final dayData = results[1] as List; + final dayDataGym = results[2] as List; + + routine.dayData = dayData.map((entry) => DayData.fromJson(entry)).toList(); + routine.dayDataGym = dayDataGym.map((entry) => DayData.fromJson(entry)).toList(); + + return routine; + } + + Future addRoutineServer(Routine routine) async { + final data = await _baseProvider.post( + routine.toJson(), + _baseProvider.makeUrl(_routinesUrlPath), + ); + return Routine.fromJson(data); + } + + Future editRoutineServer(Routine routine) async { + await _baseProvider.patch( + routine.toJson(), + _baseProvider.makeUrl(_routinesUrlPath, id: routine.id), + ); + return fetchAndSetRoutineFullServer(routine.id!); + } + + Future deleteRoutineServer(int id) async { + await _baseProvider.deleteRequest(_routinesUrlPath, id); + } + + /// Streams all routines from the local PowerSync-backed Drift table. + /// + /// Templates (`is_template = TRUE`, including public ones) are excluded at + /// the sync-rule level (see `sync_rules.yaml`), so they never reach the + /// local DB — no client-side filter needed here. + /// + /// Sort matches Django's `Routine.Meta.ordering = ['-start', '-created']` so + /// that REST responses and PowerSync emissions agree on the row order. The + /// UI takes the first row as the active routine and the optimistic + /// insertion in `RoutinesRiverpod.addRoutine` assumes newest-first. + Stream> watchAllDrift() { + _logger.finer('Watching all local routines'); + return (_db.select(_db.routineTable)..orderBy([ + (t) => OrderingTerm.desc(t.start), + (t) => OrderingTerm.desc(t.created), + ])) + .watch(); + } + + /// Updates a routine via the local Drift table. + Future editLocalDrift(Routine routine) async { + final id = routine.id; + if (id == null) { + throw StateError('Cannot edit a routine without id'); + } + _logger.finer('Updating local routine $id'); + await (_db.update( + _db.routineTable, + )..where((t) => t.id.equals(id))).write(routine.toCompanion()); + } + + /// Deletes a routine via the local Drift table. + Future deleteLocalDrift(int id) async { + _logger.finer('Deleting local routine $id'); + await (_db.delete(_db.routineTable)..where((t) => t.id.equals(id))).go(); + } + + /* + * Days + */ + Future addDayServer(Day day) async { + final data = await _baseProvider.post( + day.toJson(), + _baseProvider.makeUrl(_daysUrlPath), + ); + day = Day.fromJson(data); + + fetchAndSetRoutineFullServer(day.routineId); + + return day; + } + + Future editDayServer(Day day) async { + await _baseProvider.patch( + day.toJson(), + _baseProvider.makeUrl(_daysUrlPath, id: day.id), + ); + } + + Future deleteDayServer(int dayId) async { + await _baseProvider.deleteRequest(_daysUrlPath, dayId); + } + + /* + * Slots + */ + Future addSlotServer(Slot slot) async { + final data = await _baseProvider.post( + slot.toJson(), + _baseProvider.makeUrl(_slotsUrlPath), + ); + final newSlot = Slot.fromJson(data); + return newSlot; + } + + Future deleteSlotServer(int slotId) async { + await _baseProvider.deleteRequest(_slotsUrlPath, slotId); + } + + Future editSlotServer(Slot slot) async { + await _baseProvider.patch( + slot.toJson(), + _baseProvider.makeUrl(_slotsUrlPath, id: slot.id), + ); + } + + /* + * Slot entries + */ + Future addSlotEntryServer(SlotEntry entry) async { + final data = await _baseProvider.post( + entry.toJson(), + _baseProvider.makeUrl(_slotEntriesUrlPath), + ); + return SlotEntry.fromJson(data); + } + + Future deleteSlotEntryServer(int id) async { + await _baseProvider.deleteRequest(_slotEntriesUrlPath, id); + } + + Future editSlotEntryServer(SlotEntry entry) async { + await _baseProvider.patch( + entry.toJson(), + _baseProvider.makeUrl(_slotEntriesUrlPath, id: entry.id), + ); + } + + /* + * Configs + */ + String _getConfigUrl(ConfigType type) { + switch (type) { + case ConfigType.sets: + return _routineConfigSets; + case ConfigType.maxSets: + return _routineConfigMaxSets; + case ConfigType.weight: + return _routineConfigWeights; + case ConfigType.maxWeight: + return _routineConfigMaxWeights; + case ConfigType.repetitions: + return _routineConfigRepetitions; + case ConfigType.maxRepetitions: + return _routineConfigMaxRepetitions; + case ConfigType.rir: + return _routineConfigRir; + case ConfigType.maxRir: + return _routineConfigMaxRir; + case ConfigType.rest: + return _routineConfigRestTime; + case ConfigType.maxRest: + return _routineConfigMaxRestTime; + } + } + + Future editConfigServer(BaseConfig config, ConfigType type) async { + final data = await _baseProvider.patch( + config.toJson(), + _baseProvider.makeUrl(_getConfigUrl(type), id: config.id), + ); + + return BaseConfig.fromJson(data); + } + + Future addConfigServer(BaseConfig config, ConfigType type) async { + final data = await _baseProvider.post( + config.toJson(), + _baseProvider.makeUrl(_getConfigUrl(type)), + ); + return BaseConfig.fromJson(data); + } + + Future deleteConfigServer(int id, ConfigType type) async { + await _baseProvider.deleteRequest(_getConfigUrl(type), id); + } + + Future handleConfigServer(SlotEntry entry, num? value, ConfigType type) async { + final configs = entry.getConfigsByType(type); + final config = configs.isNotEmpty ? configs.first : null; + + if (value == null && config != null) { + // Value removed, delete entry + configs.removeWhere((c) => c.id! == config.id!); + await deleteConfigServer(config.id!, type); + } else if (config != null) { + // Update existing value + configs.first.value = value!; + await editConfigServer(configs.first, type); + } else if (value != null && config == null) { + // Create new config + configs.add( + await addConfigServer( + BaseConfig.firstIteration(value, entry.id!), + type, + ), + ); + } + } +} diff --git a/lib/providers/routines_repository.g.dart b/lib/providers/routines_repository.g.dart new file mode 100644 index 000000000..f00bc0845 --- /dev/null +++ b/lib/providers/routines_repository.g.dart @@ -0,0 +1,52 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'routines_repository.dart'; + +// ************************************************************************** +// RiverpodGenerator +// ************************************************************************** + +// GENERATED CODE - DO NOT MODIFY BY HAND +// ignore_for_file: type=lint, type=warning + +@ProviderFor(routinesRepository) +final routinesRepositoryProvider = RoutinesRepositoryProvider._(); + +final class RoutinesRepositoryProvider + extends $FunctionalProvider + with $Provider { + RoutinesRepositoryProvider._() + : super( + from: null, + argument: null, + retry: null, + name: r'routinesRepositoryProvider', + isAutoDispose: false, + dependencies: null, + $allTransitiveDependencies: null, + ); + + @override + String debugGetCreateSourceHash() => _$routinesRepositoryHash(); + + @$internal + @override + $ProviderElement $createElement( + $ProviderPointer pointer, + ) => $ProviderElement(pointer); + + @override + RoutinesRepository create(Ref ref) { + return routinesRepository(ref); + } + + /// {@macro riverpod.override_with_value} + Override overrideWithValue(RoutinesRepository value) { + return $ProviderOverride( + origin: this, + providerOverride: $SyncValueProvider(value), + ); + } +} + +String _$routinesRepositoryHash() => r'249951c94887d0ff4882d7a88bd9dcfb25282f4e'; diff --git a/test/routine/day_form_test.dart b/test/routine/day_form_test.dart index 40b6c69e5..6f0aa3183 100644 --- a/test/routine/day_form_test.dart +++ b/test/routine/day_form_test.dart @@ -1,13 +1,13 @@ /* * This file is part of wger Workout Manager . - * 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 * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * - * wger Workout Manager is distributed in the hope that it will be useful, + * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Affero General Public License for more details. @@ -25,7 +25,7 @@ import 'package:wger/helpers/consts.dart'; import 'package:wger/l10n/generated/app_localizations.dart'; import 'package:wger/models/workouts/day.dart'; import 'package:wger/providers/network_provider.dart'; -import 'package:wger/providers/routines.dart'; +import 'package:wger/providers/routines_repository.dart'; import 'package:wger/widgets/routines/forms/day.dart'; import '../../test_data/routines.dart'; diff --git a/test/routine/day_form_test.mocks.dart b/test/routine/day_form_test.mocks.dart index 318da9fcc..9e12cfd2c 100644 --- a/test/routine/day_form_test.mocks.dart +++ b/test/routine/day_form_test.mocks.dart @@ -11,7 +11,7 @@ import 'package:wger/models/workouts/day.dart' as _i3; import 'package:wger/models/workouts/routine.dart' as _i2; import 'package:wger/models/workouts/slot.dart' as _i4; import 'package:wger/models/workouts/slot_entry.dart' as _i5; -import 'package:wger/providers/routines.dart' as _i7; +import 'package:wger/providers/routines_repository.dart' as _i7; // ignore_for_file: type=lint // ignore_for_file: avoid_redundant_argument_values @@ -56,14 +56,6 @@ class MockRoutinesRepository extends _i1.Mock implements _i7.RoutinesRepository _i1.throwOnMissingStub(this); } - @override - _i8.Future> fetchAllRoutinesSparseServer() => - (super.noSuchMethod( - Invocation.method(#fetchAllRoutinesSparseServer, []), - returnValue: _i8.Future>.value(<_i2.Routine>[]), - ) - as _i8.Future>); - @override _i8.Future<_i2.Routine> fetchAndSetRoutineFullServer(int? routineId) => (super.noSuchMethod( diff --git a/test/routine/forms/slot_form_test.dart b/test/routine/forms/slot_form_test.dart index 4672e6de8..0afc0f26c 100644 --- a/test/routine/forms/slot_form_test.dart +++ b/test/routine/forms/slot_form_test.dart @@ -25,6 +25,7 @@ import 'package:wger/l10n/generated/app_localizations.dart'; import 'package:wger/models/workouts/slot.dart'; import 'package:wger/models/workouts/slot_entry.dart'; import 'package:wger/providers/routines.dart'; +import 'package:wger/providers/routines_repository.dart'; import 'package:wger/widgets/routines/forms/slot.dart'; import '../../../test_data/routines.dart'; diff --git a/test/routine/forms/slot_form_test.mocks.dart b/test/routine/forms/slot_form_test.mocks.dart index cfb4ad93f..c776b1e68 100644 --- a/test/routine/forms/slot_form_test.mocks.dart +++ b/test/routine/forms/slot_form_test.mocks.dart @@ -11,7 +11,7 @@ import 'package:wger/models/workouts/day.dart' as _i3; import 'package:wger/models/workouts/routine.dart' as _i2; import 'package:wger/models/workouts/slot.dart' as _i4; import 'package:wger/models/workouts/slot_entry.dart' as _i5; -import 'package:wger/providers/routines.dart' as _i7; +import 'package:wger/providers/routines_repository.dart' as _i7; // ignore_for_file: type=lint // ignore_for_file: avoid_redundant_argument_values @@ -56,14 +56,6 @@ class MockRoutinesRepository extends _i1.Mock implements _i7.RoutinesRepository _i1.throwOnMissingStub(this); } - @override - _i8.Future> fetchAllRoutinesSparseServer() => - (super.noSuchMethod( - Invocation.method(#fetchAllRoutinesSparseServer, []), - returnValue: _i8.Future>.value(<_i2.Routine>[]), - ) - as _i8.Future>); - @override _i8.Future<_i2.Routine> fetchAndSetRoutineFullServer(int? routineId) => (super.noSuchMethod( diff --git a/test/routine/routine_edit_test.dart b/test/routine/routine_edit_test.dart index 3269c5230..9acc7299b 100644 --- a/test/routine/routine_edit_test.dart +++ b/test/routine/routine_edit_test.dart @@ -22,7 +22,7 @@ import 'package:flutter_test/flutter_test.dart'; import 'package:mockito/annotations.dart'; import 'package:mockito/mockito.dart'; import 'package:wger/l10n/generated/app_localizations.dart'; -import 'package:wger/providers/routines.dart'; +import 'package:wger/providers/routines_repository.dart'; import 'package:wger/widgets/routines/forms/day.dart'; import 'package:wger/widgets/routines/routine_edit.dart'; diff --git a/test/routine/routine_edit_test.mocks.dart b/test/routine/routine_edit_test.mocks.dart index b79838c50..169045119 100644 --- a/test/routine/routine_edit_test.mocks.dart +++ b/test/routine/routine_edit_test.mocks.dart @@ -11,7 +11,7 @@ import 'package:wger/models/workouts/day.dart' as _i3; import 'package:wger/models/workouts/routine.dart' as _i2; import 'package:wger/models/workouts/slot.dart' as _i4; import 'package:wger/models/workouts/slot_entry.dart' as _i5; -import 'package:wger/providers/routines.dart' as _i7; +import 'package:wger/providers/routines_repository.dart' as _i7; // ignore_for_file: type=lint // ignore_for_file: avoid_redundant_argument_values @@ -56,14 +56,6 @@ class MockRoutinesRepository extends _i1.Mock implements _i7.RoutinesRepository _i1.throwOnMissingStub(this); } - @override - _i8.Future> fetchAllRoutinesSparseServer() => - (super.noSuchMethod( - Invocation.method(#fetchAllRoutinesSparseServer, []), - returnValue: _i8.Future>.value(<_i2.Routine>[]), - ) - as _i8.Future>); - @override _i8.Future<_i2.Routine> fetchAndSetRoutineFullServer(int? routineId) => (super.noSuchMethod( diff --git a/test/routine/routine_form_test.dart b/test/routine/routine_form_test.dart index 00408bcae..09b270146 100644 --- a/test/routine/routine_form_test.dart +++ b/test/routine/routine_form_test.dart @@ -28,7 +28,7 @@ import 'package:wger/helpers/consts.dart'; import 'package:wger/l10n/generated/app_localizations.dart'; import 'package:wger/models/workouts/routine.dart'; import 'package:wger/providers/network_provider.dart'; -import 'package:wger/providers/routines.dart'; +import 'package:wger/providers/routines_repository.dart'; import 'package:wger/screens/routine_edit_screen.dart'; import 'package:wger/screens/routine_screen.dart'; import 'package:wger/widgets/routines/forms/routine.dart'; diff --git a/test/routine/routine_form_test.mocks.dart b/test/routine/routine_form_test.mocks.dart index 9310725cd..f5d8d6ced 100644 --- a/test/routine/routine_form_test.mocks.dart +++ b/test/routine/routine_form_test.mocks.dart @@ -11,7 +11,7 @@ import 'package:wger/models/workouts/day.dart' as _i3; import 'package:wger/models/workouts/routine.dart' as _i2; import 'package:wger/models/workouts/slot.dart' as _i4; import 'package:wger/models/workouts/slot_entry.dart' as _i5; -import 'package:wger/providers/routines.dart' as _i7; +import 'package:wger/providers/routines_repository.dart' as _i7; // ignore_for_file: type=lint // ignore_for_file: avoid_redundant_argument_values @@ -56,14 +56,6 @@ class MockRoutinesRepository extends _i1.Mock implements _i7.RoutinesRepository _i1.throwOnMissingStub(this); } - @override - _i8.Future> fetchAllRoutinesSparseServer() => - (super.noSuchMethod( - Invocation.method(#fetchAllRoutinesSparseServer, []), - returnValue: _i8.Future>.value(<_i2.Routine>[]), - ) - as _i8.Future>); - @override _i8.Future<_i2.Routine> fetchAndSetRoutineFullServer(int? routineId) => (super.noSuchMethod( diff --git a/test/routine/routines_provider_repository_test.dart b/test/routine/routines_provider_repository_test.dart index 4383404bf..ed7a348a2 100644 --- a/test/routine/routines_provider_repository_test.dart +++ b/test/routine/routines_provider_repository_test.dart @@ -25,7 +25,7 @@ import 'package:mockito/mockito.dart'; import 'package:wger/database/powersync/database.dart'; import 'package:wger/models/workouts/routine.dart'; import 'package:wger/providers/base_provider.dart'; -import 'package:wger/providers/routines.dart'; +import 'package:wger/providers/routines_repository.dart'; import '../fixtures/fixture_reader.dart'; import 'routines_provider_repository_test.mocks.dart'; diff --git a/test/routine/routines_provider_test.dart b/test/routine/routines_provider_test.dart index 275289e1b..99b5aa365 100644 --- a/test/routine/routines_provider_test.dart +++ b/test/routine/routines_provider_test.dart @@ -23,6 +23,7 @@ import 'package:mockito/mockito.dart'; import 'package:wger/models/workouts/day.dart'; import 'package:wger/models/workouts/routine.dart'; import 'package:wger/providers/routines.dart'; +import 'package:wger/providers/routines_repository.dart'; import '../../test_data/routines.dart'; import '../fake_connectivity.dart'; diff --git a/test/routine/routines_provider_test.mocks.dart b/test/routine/routines_provider_test.mocks.dart index f3528e8e9..91a9f850f 100644 --- a/test/routine/routines_provider_test.mocks.dart +++ b/test/routine/routines_provider_test.mocks.dart @@ -11,7 +11,7 @@ import 'package:wger/models/workouts/day.dart' as _i3; import 'package:wger/models/workouts/routine.dart' as _i2; import 'package:wger/models/workouts/slot.dart' as _i4; import 'package:wger/models/workouts/slot_entry.dart' as _i5; -import 'package:wger/providers/routines.dart' as _i7; +import 'package:wger/providers/routines_repository.dart' as _i7; // ignore_for_file: type=lint // ignore_for_file: avoid_redundant_argument_values @@ -56,14 +56,6 @@ class MockRoutinesRepository extends _i1.Mock implements _i7.RoutinesRepository _i1.throwOnMissingStub(this); } - @override - _i8.Future> fetchAllRoutinesSparseServer() => - (super.noSuchMethod( - Invocation.method(#fetchAllRoutinesSparseServer, []), - returnValue: _i8.Future>.value(<_i2.Routine>[]), - ) - as _i8.Future>); - @override _i8.Future<_i2.Routine> fetchAndSetRoutineFullServer(int? routineId) => (super.noSuchMethod( diff --git a/test/routine/routines_screen_test.dart b/test/routine/routines_screen_test.dart index 13edd72ac..ffbccb5b4 100644 --- a/test/routine/routines_screen_test.dart +++ b/test/routine/routines_screen_test.dart @@ -24,7 +24,7 @@ import 'package:mockito/mockito.dart'; import 'package:wger/l10n/generated/app_localizations.dart'; import 'package:wger/models/workouts/routine.dart'; import 'package:wger/providers/network_provider.dart'; -import 'package:wger/providers/routines.dart'; +import 'package:wger/providers/routines_repository.dart'; import 'package:wger/screens/form_screen.dart'; import 'package:wger/screens/routine_list_screen.dart'; import 'package:wger/screens/routine_screen.dart'; diff --git a/test/routine/routines_screen_test.mocks.dart b/test/routine/routines_screen_test.mocks.dart index 711e5cc2c..2de369bef 100644 --- a/test/routine/routines_screen_test.mocks.dart +++ b/test/routine/routines_screen_test.mocks.dart @@ -11,7 +11,7 @@ import 'package:wger/models/workouts/day.dart' as _i3; import 'package:wger/models/workouts/routine.dart' as _i2; import 'package:wger/models/workouts/slot.dart' as _i4; import 'package:wger/models/workouts/slot_entry.dart' as _i5; -import 'package:wger/providers/routines.dart' as _i7; +import 'package:wger/providers/routines_repository.dart' as _i7; // ignore_for_file: type=lint // ignore_for_file: avoid_redundant_argument_values @@ -56,14 +56,6 @@ class MockRoutinesRepository extends _i1.Mock implements _i7.RoutinesRepository _i1.throwOnMissingStub(this); } - @override - _i8.Future> fetchAllRoutinesSparseServer() => - (super.noSuchMethod( - Invocation.method(#fetchAllRoutinesSparseServer, []), - returnValue: _i8.Future>.value(<_i2.Routine>[]), - ) - as _i8.Future>); - @override _i8.Future<_i2.Routine> fetchAndSetRoutineFullServer(int? routineId) => (super.noSuchMethod( diff --git a/test/routine/slot_entry_form_test.dart b/test/routine/slot_entry_form_test.dart index bd3aa3a14..1829a9b84 100644 --- a/test/routine/slot_entry_form_test.dart +++ b/test/routine/slot_entry_form_test.dart @@ -25,6 +25,7 @@ import 'package:wger/helpers/consts.dart'; import 'package:wger/l10n/generated/app_localizations.dart'; import 'package:wger/models/workouts/slot_entry.dart'; import 'package:wger/providers/routines.dart'; +import 'package:wger/providers/routines_repository.dart'; import 'package:wger/widgets/routines/forms/repetitions.dart'; import 'package:wger/widgets/routines/forms/rir.dart'; import 'package:wger/widgets/routines/forms/slot_entry.dart'; diff --git a/test/routine/slot_entry_form_test.mocks.dart b/test/routine/slot_entry_form_test.mocks.dart index 7eaf79a56..f884e2a69 100644 --- a/test/routine/slot_entry_form_test.mocks.dart +++ b/test/routine/slot_entry_form_test.mocks.dart @@ -11,7 +11,7 @@ import 'package:wger/models/workouts/day.dart' as _i3; import 'package:wger/models/workouts/routine.dart' as _i2; import 'package:wger/models/workouts/slot.dart' as _i4; import 'package:wger/models/workouts/slot_entry.dart' as _i5; -import 'package:wger/providers/routines.dart' as _i7; +import 'package:wger/providers/routines_repository.dart' as _i7; // ignore_for_file: type=lint // ignore_for_file: avoid_redundant_argument_values @@ -56,14 +56,6 @@ class MockRoutinesRepository extends _i1.Mock implements _i7.RoutinesRepository _i1.throwOnMissingStub(this); } - @override - _i8.Future> fetchAllRoutinesSparseServer() => - (super.noSuchMethod( - Invocation.method(#fetchAllRoutinesSparseServer, []), - returnValue: _i8.Future>.value(<_i2.Routine>[]), - ) - as _i8.Future>); - @override _i8.Future<_i2.Routine> fetchAndSetRoutineFullServer(int? routineId) => (super.noSuchMethod(