Fire notification read
This commit is contained in:
parent
04171cdc12
commit
b7468de0d1
10 changed files with 66 additions and 22 deletions
|
|
@ -126,6 +126,11 @@ void fetchDataMiddleware(Store<AppState> store, action, NextDispatcher next) {
|
|||
}
|
||||
}
|
||||
|
||||
if (action is ReadFireNotificationAction) {
|
||||
store.dispatch(new ReadedFireNotificationAction(action.notif));
|
||||
persistFireNotifications(store.state.fireNotifications);
|
||||
}
|
||||
|
||||
if (action is FetchYourLocationsAction) {
|
||||
// Use the api to fetch the YourLocations
|
||||
api
|
||||
|
|
|
|||
|
|
@ -33,3 +33,15 @@ class AddedFireNotificationAction extends FireNotificationActions {
|
|||
|
||||
AddedFireNotificationAction(this.notif);
|
||||
}
|
||||
|
||||
class ReadFireNotificationAction extends FireNotificationActions {
|
||||
final FireNotification notif;
|
||||
|
||||
ReadFireNotificationAction(this.notif);
|
||||
}
|
||||
|
||||
class ReadedFireNotificationAction extends FireNotificationActions {
|
||||
final FireNotification notif;
|
||||
|
||||
ReadedFireNotificationAction(this.notif);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -9,12 +9,14 @@ final fireNotificationReducer = combineReducers<List<FireNotification>>([
|
|||
new TypedReducer<List<FireNotification>, DeletedFireNotificationAction>(
|
||||
_deletedFireNotification),
|
||||
new TypedReducer<List<FireNotification>, DeletedAllFireNotificationAction>(
|
||||
_deletedAllFireNotifications)
|
||||
_deletedAllFireNotifications),
|
||||
new TypedReducer<List<FireNotification>, ReadedFireNotificationAction>(
|
||||
_readedFireNotification)
|
||||
]);
|
||||
|
||||
List<FireNotification> _receivedFireNotification(
|
||||
List<FireNotification> yourLocations, AddedFireNotificationAction action) {
|
||||
return new List.from(yourLocations)..add(action.notif);
|
||||
List<FireNotification> notifications, AddedFireNotificationAction action) {
|
||||
return new List.from(notifications)..add(action.notif);
|
||||
}
|
||||
|
||||
List<FireNotification> _deletedFireNotification(
|
||||
|
|
@ -22,6 +24,14 @@ List<FireNotification> _deletedFireNotification(
|
|||
return new List.from(notifications)..remove(action.notif);
|
||||
}
|
||||
|
||||
List<FireNotification> _readedFireNotification(
|
||||
List<FireNotification> notifications, ReadedFireNotificationAction action) {
|
||||
return notifications
|
||||
.map((yourLocation) =>
|
||||
yourLocation.id == action.notif.id ? action.notif : yourLocation)
|
||||
.toList();
|
||||
}
|
||||
|
||||
List<FireNotification> _deletedAllFireNotifications(
|
||||
List<FireNotification> notifications, DeletedAllFireNotificationAction action) {
|
||||
return new List<FireNotification>();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue