More fire stats
This commit is contained in:
parent
9dd8a7de97
commit
74b0d37839
6 changed files with 54 additions and 9 deletions
|
|
@ -1,9 +1,14 @@
|
|||
import 'package:fires_flutter/models/yourLocation.dart';
|
||||
import 'package:fires_flutter/models/fireNotification.dart';
|
||||
import 'dart:async';
|
||||
|
||||
abstract class AppActions {}
|
||||
|
||||
class FetchYourLocationsAction extends AppActions {}
|
||||
class FetchYourLocationsAction extends AppActions {
|
||||
Completer<Null> refreshCallback;
|
||||
|
||||
FetchYourLocationsAction([this.refreshCallback]);
|
||||
}
|
||||
|
||||
class PersistAppStateAction extends AppActions {}
|
||||
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@ 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';
|
||||
import 'dart:async';
|
||||
|
||||
import '../models/appState.dart';
|
||||
import '../models/fireNotificationsPersist.dart';
|
||||
|
|
@ -150,8 +151,20 @@ void fetchDataMiddleware(Store<AppState> store, action, NextDispatcher next) {
|
|||
localLocations.add(subsLoc);
|
||||
}).subscribed = true;
|
||||
});
|
||||
|
||||
localLocations.forEach((yl) {
|
||||
api.getYourLocationFireStats(store.state, yl).then((value) {
|
||||
yl.currentNumFires = value.numFires;
|
||||
store.dispatch(new UpdateYourLocationAction(yl));
|
||||
});
|
||||
});
|
||||
|
||||
store.dispatch(new FetchYourLocationsSucceededAction(localLocations));
|
||||
persistYourLocations(localLocations);
|
||||
Completer<Null> completer = action.refreshCallback;
|
||||
if (completer != null) {
|
||||
completer.complete(null);
|
||||
}
|
||||
});
|
||||
}).catchError((Exception error) {
|
||||
// If it fails, dispatch a failure action. The reducer will
|
||||
|
|
|
|||
|
|
@ -51,9 +51,7 @@ class ToggledSubscriptionAction extends YourLocationActions {
|
|||
ToggledSubscriptionAction(this.loc);
|
||||
}
|
||||
|
||||
class SubscribeAction extends YourLocationActions {
|
||||
SubscribeAction();
|
||||
}
|
||||
class SubscribeAction extends YourLocationActions {}
|
||||
|
||||
class SubscribeConfirmAction extends YourLocationActions {
|
||||
YourLocation loc;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue