todos-contra-el-fuego-mobile/lib/redux/appReducer.dart
Vicente J. Ruiz Jurado e50ff5179b Added Monitorized Areas
2018-08-06 10:34:32 +02:00

28 lines
958 B
Dart

import 'actions.dart';
import '../models/appState.dart';
AppState appReducer(AppState state, action) {
if (action is FetchYourLocationsSucceededAction) {
return state.copyWith(yourLocations: action.fetchedYourLocations);
}
if (action is FetchFireNotificationsSucceededAction) {
return state.copyWith(fireNotifications: action.fetchedFireNotifications,
fireNotificationsUnread: action.unreadCount);
}
if (action is FetchMonitoredAreasSucceededAction) {
return state.copyWith(monitoredAreas: action.monitoredAreas);
}
if (action is AddedFireNotificationAction)
return state.copyWith(
fireNotificationsUnread: state.fireNotificationsUnread + 1);
if (action is ReadedFireNotificationAction)
return state.copyWith(
fireNotificationsUnread: state.fireNotificationsUnread - 1);
if (action is DeleteAllFireNotificationAction)
return state.copyWith(
fireNotificationsUnread: 0);
return state;
}