More work with fire notifications

This commit is contained in:
Vicente J. Ruiz Jurado 2018-07-31 12:51:10 +02:00
parent 5fdaf239c0
commit 9dd8a7de97
24 changed files with 512 additions and 288 deletions

View file

@ -1,5 +1,6 @@
import 'package:bson_objectid/bson_objectid.dart';
import 'package:fires_flutter/models/yourLocation.dart';
import 'package:fires_flutter/models/fireNotification.dart';
import 'package:flutter_simple_dependency_injection/injector.dart';
import 'package:just_debounce_it/just_debounce_it.dart';
import 'package:redux/redux.dart';
@ -161,8 +162,12 @@ void fetchDataMiddleware(Store<AppState> store, action, NextDispatcher next) {
if (action is FetchFireNotificationsAction) {
loadFireNotifications().then((fireNotifications) {
int unread = 0;
for (FireNotification notif in fireNotifications) {
if (!notif.read) { unread++; }
}
store.dispatch(
new FetchFireNotificationsSucceededAction(fireNotifications));
new FetchFireNotificationsSucceededAction(fireNotifications, unread));
persistFireNotifications(fireNotifications);
});
}