mirror of
https://github.com/wger-project/flutter.git
synced 2026-12-01 02:02:35 +01:00
Properly set or remove newly created objects
This commit is contained in:
@@ -462,10 +462,33 @@ class RoutinesProvider with ChangeNotifier {
|
||||
baseProvider.makeUrl(_slotsUrlPath),
|
||||
);
|
||||
final set = Slot.fromJson(data);
|
||||
|
||||
for (final routine in _routines) {
|
||||
for (final day in routine.days) {
|
||||
if (day.id == slot.day) {
|
||||
day.slots.add(set);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
notifyListeners();
|
||||
return set;
|
||||
}
|
||||
|
||||
Future<void> deleteSlot(int slotId) async {
|
||||
final data = await baseProvider.deleteRequest(_slotsUrlPath, slotId);
|
||||
|
||||
for (final routine in _routines) {
|
||||
for (final day in routine.days) {
|
||||
day.slots.removeWhere((s) => s.id == slotId);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
Future<void> editSlot(Slot workoutSet) async {
|
||||
await baseProvider.patch(
|
||||
workoutSet.toJson(),
|
||||
@@ -583,17 +606,6 @@ class RoutinesProvider with ChangeNotifier {
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
Future<void> deleteSlot(int slotId) async {
|
||||
await baseProvider.deleteRequest(_slotsUrlPath, slotId);
|
||||
|
||||
for (final workout in _routines) {
|
||||
for (final day in workout.days) {
|
||||
day.slots.removeWhere((slot) => slot.id == slotId);
|
||||
}
|
||||
}
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
/*
|
||||
* Setting
|
||||
*/
|
||||
|
||||
@@ -460,6 +460,16 @@ class MockRoutinesProvider extends _i1.Mock implements _i12.RoutinesProvider {
|
||||
)),
|
||||
) as _i13.Future<_i7.Slot>);
|
||||
|
||||
@override
|
||||
_i13.Future<void> deleteSlot(int? slotId) => (super.noSuchMethod(
|
||||
Invocation.method(
|
||||
#deleteSlot,
|
||||
[slotId],
|
||||
),
|
||||
returnValue: _i13.Future<void>.value(),
|
||||
returnValueForMissingStub: _i13.Future<void>.value(),
|
||||
) as _i13.Future<void>);
|
||||
|
||||
@override
|
||||
_i13.Future<void> editSlot(_i7.Slot? workoutSet) => (super.noSuchMethod(
|
||||
Invocation.method(
|
||||
@@ -480,6 +490,16 @@ class MockRoutinesProvider extends _i1.Mock implements _i12.RoutinesProvider {
|
||||
returnValueForMissingStub: _i13.Future<void>.value(),
|
||||
) as _i13.Future<void>);
|
||||
|
||||
@override
|
||||
_i13.Future<void> deleteSlotEntry(int? id) => (super.noSuchMethod(
|
||||
Invocation.method(
|
||||
#deleteSlotEntry,
|
||||
[id],
|
||||
),
|
||||
returnValue: _i13.Future<void>.value(),
|
||||
returnValueForMissingStub: _i13.Future<void>.value(),
|
||||
) as _i13.Future<void>);
|
||||
|
||||
@override
|
||||
String getConfigUrl(_i9.ConfigType? type) => (super.noSuchMethod(
|
||||
Invocation.method(
|
||||
@@ -563,7 +583,7 @@ class MockRoutinesProvider extends _i1.Mock implements _i12.RoutinesProvider {
|
||||
) as _i13.Future<void>);
|
||||
|
||||
@override
|
||||
_i13.Future<dynamic> handleConfig(
|
||||
_i13.Future<void> handleConfig(
|
||||
_i9.SlotEntry? entry,
|
||||
String? input,
|
||||
_i9.ConfigType? type,
|
||||
@@ -577,24 +597,15 @@ class MockRoutinesProvider extends _i1.Mock implements _i12.RoutinesProvider {
|
||||
type,
|
||||
],
|
||||
),
|
||||
returnValue: _i13.Future<dynamic>.value(),
|
||||
) as _i13.Future<dynamic>);
|
||||
|
||||
@override
|
||||
_i13.Future<void> fetchComputedSettings(_i7.Slot? workoutSet) => (super.noSuchMethod(
|
||||
Invocation.method(
|
||||
#fetchComputedSettings,
|
||||
[workoutSet],
|
||||
),
|
||||
returnValue: _i13.Future<void>.value(),
|
||||
returnValueForMissingStub: _i13.Future<void>.value(),
|
||||
) as _i13.Future<void>);
|
||||
|
||||
@override
|
||||
_i13.Future<void> deleteSlot(int? setId) => (super.noSuchMethod(
|
||||
_i13.Future<void> fetchComputedSettings(_i7.Slot? slot) => (super.noSuchMethod(
|
||||
Invocation.method(
|
||||
#deleteSet,
|
||||
[setId],
|
||||
#fetchComputedSettings,
|
||||
[slot],
|
||||
),
|
||||
returnValue: _i13.Future<void>.value(),
|
||||
returnValueForMissingStub: _i13.Future<void>.value(),
|
||||
|
||||
@@ -460,6 +460,16 @@ class MockRoutinesProvider extends _i1.Mock implements _i12.RoutinesProvider {
|
||||
)),
|
||||
) as _i13.Future<_i7.Slot>);
|
||||
|
||||
@override
|
||||
_i13.Future<void> deleteSlot(int? slotId) => (super.noSuchMethod(
|
||||
Invocation.method(
|
||||
#deleteSlot,
|
||||
[slotId],
|
||||
),
|
||||
returnValue: _i13.Future<void>.value(),
|
||||
returnValueForMissingStub: _i13.Future<void>.value(),
|
||||
) as _i13.Future<void>);
|
||||
|
||||
@override
|
||||
_i13.Future<void> editSlot(_i7.Slot? workoutSet) => (super.noSuchMethod(
|
||||
Invocation.method(
|
||||
@@ -480,6 +490,16 @@ class MockRoutinesProvider extends _i1.Mock implements _i12.RoutinesProvider {
|
||||
returnValueForMissingStub: _i13.Future<void>.value(),
|
||||
) as _i13.Future<void>);
|
||||
|
||||
@override
|
||||
_i13.Future<void> deleteSlotEntry(int? id) => (super.noSuchMethod(
|
||||
Invocation.method(
|
||||
#deleteSlotEntry,
|
||||
[id],
|
||||
),
|
||||
returnValue: _i13.Future<void>.value(),
|
||||
returnValueForMissingStub: _i13.Future<void>.value(),
|
||||
) as _i13.Future<void>);
|
||||
|
||||
@override
|
||||
String getConfigUrl(_i9.ConfigType? type) => (super.noSuchMethod(
|
||||
Invocation.method(
|
||||
@@ -563,7 +583,7 @@ class MockRoutinesProvider extends _i1.Mock implements _i12.RoutinesProvider {
|
||||
) as _i13.Future<void>);
|
||||
|
||||
@override
|
||||
_i13.Future<dynamic> handleConfig(
|
||||
_i13.Future<void> handleConfig(
|
||||
_i9.SlotEntry? entry,
|
||||
String? input,
|
||||
_i9.ConfigType? type,
|
||||
@@ -577,24 +597,15 @@ class MockRoutinesProvider extends _i1.Mock implements _i12.RoutinesProvider {
|
||||
type,
|
||||
],
|
||||
),
|
||||
returnValue: _i13.Future<dynamic>.value(),
|
||||
) as _i13.Future<dynamic>);
|
||||
|
||||
@override
|
||||
_i13.Future<void> fetchComputedSettings(_i7.Slot? workoutSet) => (super.noSuchMethod(
|
||||
Invocation.method(
|
||||
#fetchComputedSettings,
|
||||
[workoutSet],
|
||||
),
|
||||
returnValue: _i13.Future<void>.value(),
|
||||
returnValueForMissingStub: _i13.Future<void>.value(),
|
||||
) as _i13.Future<void>);
|
||||
|
||||
@override
|
||||
_i13.Future<void> deleteSlot(int? setId) => (super.noSuchMethod(
|
||||
_i13.Future<void> fetchComputedSettings(_i7.Slot? slot) => (super.noSuchMethod(
|
||||
Invocation.method(
|
||||
#deleteSet,
|
||||
[setId],
|
||||
#fetchComputedSettings,
|
||||
[slot],
|
||||
),
|
||||
returnValue: _i13.Future<void>.value(),
|
||||
returnValueForMissingStub: _i13.Future<void>.value(),
|
||||
|
||||
@@ -460,6 +460,16 @@ class MockRoutinesProvider extends _i1.Mock implements _i12.RoutinesProvider {
|
||||
)),
|
||||
) as _i13.Future<_i7.Slot>);
|
||||
|
||||
@override
|
||||
_i13.Future<void> deleteSlot(int? slotId) => (super.noSuchMethod(
|
||||
Invocation.method(
|
||||
#deleteSlot,
|
||||
[slotId],
|
||||
),
|
||||
returnValue: _i13.Future<void>.value(),
|
||||
returnValueForMissingStub: _i13.Future<void>.value(),
|
||||
) as _i13.Future<void>);
|
||||
|
||||
@override
|
||||
_i13.Future<void> editSlot(_i7.Slot? workoutSet) => (super.noSuchMethod(
|
||||
Invocation.method(
|
||||
@@ -480,6 +490,16 @@ class MockRoutinesProvider extends _i1.Mock implements _i12.RoutinesProvider {
|
||||
returnValueForMissingStub: _i13.Future<void>.value(),
|
||||
) as _i13.Future<void>);
|
||||
|
||||
@override
|
||||
_i13.Future<void> deleteSlotEntry(int? id) => (super.noSuchMethod(
|
||||
Invocation.method(
|
||||
#deleteSlotEntry,
|
||||
[id],
|
||||
),
|
||||
returnValue: _i13.Future<void>.value(),
|
||||
returnValueForMissingStub: _i13.Future<void>.value(),
|
||||
) as _i13.Future<void>);
|
||||
|
||||
@override
|
||||
String getConfigUrl(_i9.ConfigType? type) => (super.noSuchMethod(
|
||||
Invocation.method(
|
||||
@@ -563,7 +583,7 @@ class MockRoutinesProvider extends _i1.Mock implements _i12.RoutinesProvider {
|
||||
) as _i13.Future<void>);
|
||||
|
||||
@override
|
||||
_i13.Future<dynamic> handleConfig(
|
||||
_i13.Future<void> handleConfig(
|
||||
_i9.SlotEntry? entry,
|
||||
String? input,
|
||||
_i9.ConfigType? type,
|
||||
@@ -577,24 +597,15 @@ class MockRoutinesProvider extends _i1.Mock implements _i12.RoutinesProvider {
|
||||
type,
|
||||
],
|
||||
),
|
||||
returnValue: _i13.Future<dynamic>.value(),
|
||||
) as _i13.Future<dynamic>);
|
||||
|
||||
@override
|
||||
_i13.Future<void> fetchComputedSettings(_i7.Slot? workoutSet) => (super.noSuchMethod(
|
||||
Invocation.method(
|
||||
#fetchComputedSettings,
|
||||
[workoutSet],
|
||||
),
|
||||
returnValue: _i13.Future<void>.value(),
|
||||
returnValueForMissingStub: _i13.Future<void>.value(),
|
||||
) as _i13.Future<void>);
|
||||
|
||||
@override
|
||||
_i13.Future<void> deleteSlot(int? setId) => (super.noSuchMethod(
|
||||
_i13.Future<void> fetchComputedSettings(_i7.Slot? slot) => (super.noSuchMethod(
|
||||
Invocation.method(
|
||||
#deleteSet,
|
||||
[setId],
|
||||
#fetchComputedSettings,
|
||||
[slot],
|
||||
),
|
||||
returnValue: _i13.Future<void>.value(),
|
||||
returnValueForMissingStub: _i13.Future<void>.value(),
|
||||
|
||||
@@ -1181,6 +1181,16 @@ class MockRoutinesProvider extends _i1.Mock implements _i23.RoutinesProvider {
|
||||
)),
|
||||
) as _i21.Future<_i15.Slot>);
|
||||
|
||||
@override
|
||||
_i21.Future<void> deleteSlot(int? slotId) => (super.noSuchMethod(
|
||||
Invocation.method(
|
||||
#deleteSlot,
|
||||
[slotId],
|
||||
),
|
||||
returnValue: _i21.Future<void>.value(),
|
||||
returnValueForMissingStub: _i21.Future<void>.value(),
|
||||
) as _i21.Future<void>);
|
||||
|
||||
@override
|
||||
_i21.Future<void> editSlot(_i15.Slot? workoutSet) => (super.noSuchMethod(
|
||||
Invocation.method(
|
||||
@@ -1201,6 +1211,16 @@ class MockRoutinesProvider extends _i1.Mock implements _i23.RoutinesProvider {
|
||||
returnValueForMissingStub: _i21.Future<void>.value(),
|
||||
) as _i21.Future<void>);
|
||||
|
||||
@override
|
||||
_i21.Future<void> deleteSlotEntry(int? id) => (super.noSuchMethod(
|
||||
Invocation.method(
|
||||
#deleteSlotEntry,
|
||||
[id],
|
||||
),
|
||||
returnValue: _i21.Future<void>.value(),
|
||||
returnValueForMissingStub: _i21.Future<void>.value(),
|
||||
) as _i21.Future<void>);
|
||||
|
||||
@override
|
||||
String getConfigUrl(_i17.ConfigType? type) => (super.noSuchMethod(
|
||||
Invocation.method(
|
||||
@@ -1284,7 +1304,7 @@ class MockRoutinesProvider extends _i1.Mock implements _i23.RoutinesProvider {
|
||||
) as _i21.Future<void>);
|
||||
|
||||
@override
|
||||
_i21.Future<dynamic> handleConfig(
|
||||
_i21.Future<void> handleConfig(
|
||||
_i17.SlotEntry? entry,
|
||||
String? input,
|
||||
_i17.ConfigType? type,
|
||||
@@ -1298,24 +1318,15 @@ class MockRoutinesProvider extends _i1.Mock implements _i23.RoutinesProvider {
|
||||
type,
|
||||
],
|
||||
),
|
||||
returnValue: _i21.Future<dynamic>.value(),
|
||||
) as _i21.Future<dynamic>);
|
||||
|
||||
@override
|
||||
_i21.Future<void> fetchComputedSettings(_i15.Slot? workoutSet) => (super.noSuchMethod(
|
||||
Invocation.method(
|
||||
#fetchComputedSettings,
|
||||
[workoutSet],
|
||||
),
|
||||
returnValue: _i21.Future<void>.value(),
|
||||
returnValueForMissingStub: _i21.Future<void>.value(),
|
||||
) as _i21.Future<void>);
|
||||
|
||||
@override
|
||||
_i21.Future<void> deleteSlot(int? setId) => (super.noSuchMethod(
|
||||
_i21.Future<void> fetchComputedSettings(_i15.Slot? slot) => (super.noSuchMethod(
|
||||
Invocation.method(
|
||||
#deleteSet,
|
||||
[setId],
|
||||
#fetchComputedSettings,
|
||||
[slot],
|
||||
),
|
||||
returnValue: _i21.Future<void>.value(),
|
||||
returnValueForMissingStub: _i21.Future<void>.value(),
|
||||
|
||||
Reference in New Issue
Block a user