todos-contra-el-fuego-mobile/lib/redux/appReducer.dart
2018-07-31 12:51:10 +02:00

21 lines
722 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 AddedFireNotificationAction)
return state.copyWith(
fireNotificationsUnread: state.fireNotificationsUnread + 1);
if (action is ReadedFireNotificationAction)
return state.copyWith(
fireNotificationsUnread: state.fireNotificationsUnread - 1);
return state;
}