Fetch fire data on new locations
This commit is contained in:
parent
d40859c5d8
commit
46026917c7
1 changed files with 37 additions and 28 deletions
|
|
@ -58,6 +58,7 @@ void fetchDataMiddleware(Store<AppState> store, action, NextDispatcher next) {
|
|||
store.dispatch(new AddedYourLocationAction(action.loc));
|
||||
persistYourLocations(store.state.yourLocations);
|
||||
}
|
||||
getFiresStatsInLocation(store, action.loc);
|
||||
}
|
||||
|
||||
if (action is DeleteYourLocationAction) {
|
||||
|
|
@ -87,13 +88,7 @@ void fetchDataMiddleware(Store<AppState> store, action, NextDispatcher next) {
|
|||
}
|
||||
|
||||
if (action is ShowYourLocationMapAction) {
|
||||
api
|
||||
.getFiresInLocation(
|
||||
state: store.state,
|
||||
lat: action.loc.lat,
|
||||
lon: action.loc.lon,
|
||||
distance: action.loc.distance)
|
||||
.then((result) => store.dispatch(result));
|
||||
getFiresStatsInLocation(store, action.loc);
|
||||
}
|
||||
|
||||
if (action is ShowFireNotificationMapAction) {
|
||||
|
|
@ -111,9 +106,6 @@ void fetchDataMiddleware(Store<AppState> store, action, NextDispatcher next) {
|
|||
lon: action.loc.lon,
|
||||
distance: action.loc.distance)
|
||||
.then((result) => store.dispatch(result)));
|
||||
else {
|
||||
// FIXME do something?
|
||||
}
|
||||
store.dispatch(new UpdatedYourLocationAction(action.loc));
|
||||
persistYourLocations(store.state.yourLocations);
|
||||
}
|
||||
|
|
@ -211,18 +203,21 @@ void fetchDataMiddleware(Store<AppState> store, action, NextDispatcher next) {
|
|||
}
|
||||
|
||||
if (action is FetchMonitoredAreasAction) {
|
||||
api.getMonitoredAreas(state: store.state).then((result) { // store.dispatch()
|
||||
store.dispatch(
|
||||
new FetchMonitoredAreasSucceededAction(result));
|
||||
api.getMonitoredAreas(state: store.state).then((result) {
|
||||
// store.dispatch()
|
||||
store.dispatch(new FetchMonitoredAreasSucceededAction(result));
|
||||
});
|
||||
}
|
||||
|
||||
if (action is MarkFireAsFalsePositiveAction) {
|
||||
api.markFalsePositive(store.state, store.state.user.token, action.notif.sealed, action.type).then((result) {
|
||||
api
|
||||
.markFalsePositive(store.state, store.state.user.token,
|
||||
action.notif.sealed, action.type)
|
||||
.then((result) {
|
||||
if (result) {
|
||||
// Not necessary
|
||||
// store.dispatch(new UpdatedFireNotificationAction(action.notif));
|
||||
getFiresStatsInFire(store, action.notif);
|
||||
store.dispatch(new UpdatedFireNotificationAction(action.notif));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
@ -231,6 +226,20 @@ void fetchDataMiddleware(Store<AppState> store, action, NextDispatcher next) {
|
|||
next(action);
|
||||
}
|
||||
|
||||
void getFiresStatsInLocation(Store<AppState> store, YourLocation loc) {
|
||||
api
|
||||
.getFiresInLocation(
|
||||
state: store.state,
|
||||
lat: loc.lat,
|
||||
lon: loc.lon,
|
||||
distance: loc.distance)
|
||||
.then((result) {
|
||||
store.dispatch(result);
|
||||
loc.currentNumFires = result.numFires;
|
||||
store.dispatch(new UpdateYourLocationAction(loc));
|
||||
});
|
||||
}
|
||||
|
||||
void getFiresStatsInFire(Store<AppState> store, FireNotification notif) {
|
||||
api
|
||||
.getFiresInLocation(
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue