todos-contra-el-fuego-mobile/lib/redux/yourLocationsReducer.dart
vjrj 68ad4adbcf refactor: continue lint cleanup - 96 more issues fixed
- Add @immutable to classes with ==/hashCode (homePage, basicLocation, fireNotification, yourLocation, monitoredAreas)
- Fix camel_case_types (genericMap → GenericMap)
- Fix avoid_dynamic_calls (firesApi - typed responses)
- Fix use_build_context_synchronously (locationUtils)
- Fix always_put_control_body_on_new_line (4 reducers)
- Fix always_specify_types (placesAutocompleteUtils, reducers)
- Fix eol_at_end_of_file (4 files)
- Fix prefer_function_declarations_over_variables (introPage)
- Fix flutter_style_todos (fireMapReducer)

Build: APK generated, 0 errors, 0 warnings
2026-03-07 11:17:01 +01:00

43 lines
1.5 KiB
Dart

import 'package:redux/redux.dart';
import '../models/yourLocation.dart';
import 'actions.dart';
final Reducer<List<YourLocation>> yourLocationsReducer =
combineReducers<List<YourLocation>>(<Reducer<List<YourLocation>>>[
TypedReducer<List<YourLocation>, AddedYourLocationAction>(_addedYourLocation),
TypedReducer<List<YourLocation>, DeletedYourLocationAction>(
_deletedYourLocation),
TypedReducer<List<YourLocation>, UpdatedYourLocationAction>(
_updatedYourLocation),
TypedReducer<List<YourLocation>, ToggledSubscriptionAction>(
_toggledSubscriptionAction)
]);
List<YourLocation> _addedYourLocation(
List<YourLocation> yourLocations, AddedYourLocationAction action) {
return List<YourLocation>.from(yourLocations)..add(action.loc);
}
List<YourLocation> _deletedYourLocation(
List<YourLocation> yourLocations, DeletedYourLocationAction action) {
return yourLocations
.where((YourLocation yourLocation) => yourLocation.id != action.id)
.toList();
}
List<YourLocation> _updatedYourLocation(
List<YourLocation> yourLocations, UpdatedYourLocationAction action) {
return yourLocations
.map((YourLocation yourLocation) =>
yourLocation.id == action.loc.id ? action.loc : yourLocation)
.toList();
}
List<YourLocation> _toggledSubscriptionAction(
List<YourLocation> yourLocations, ToggledSubscriptionAction action) {
return yourLocations
.map((YourLocation yourLocation) =>
yourLocation.id == action.loc.id ? action.loc : yourLocation)
.toList();
}