Process yourLocations even without response
This commit is contained in:
parent
8025d9c3d5
commit
add46379bd
1 changed files with 13 additions and 10 deletions
|
|
@ -142,16 +142,19 @@ void fetchDataMiddleware(Store<AppState> store, action, NextDispatcher next) {
|
|||
// Our reducer will then update the State using these YourLocations.
|
||||
// print('Subscribed to: ${subscribedLocations.length}');
|
||||
loadYourLocations().then((localLocations) {
|
||||
// unsubscribe all locally to sync the subs state
|
||||
localLocations.forEach((location) => location.subscribed = false);
|
||||
// print('Local persisted: ${localLocations.length}');
|
||||
subscribedLocations.forEach((subsLoc) {
|
||||
localLocations.firstWhere(
|
||||
(localLocation) => localLocation.id == subsLoc.id, orElse: () {
|
||||
localLocations.add(subsLoc);
|
||||
}).subscribed = true;
|
||||
});
|
||||
|
||||
if (subscribedLocations is List) {
|
||||
// unsubscribe all locally to sync the subs state
|
||||
localLocations.forEach((location) => location.subscribed = false);
|
||||
// print('Local persisted: ${localLocations.length}');
|
||||
subscribedLocations.forEach((subsLoc) {
|
||||
localLocations
|
||||
.firstWhere(
|
||||
(localLocation) => localLocation.id == subsLoc.id, orElse: () {
|
||||
localLocations.add(subsLoc);
|
||||
})
|
||||
.subscribed = true;
|
||||
});
|
||||
}
|
||||
localLocations.forEach((yl) {
|
||||
api.getYourLocationFireStats(store.state, yl).then((value) {
|
||||
yl.currentNumFires = value.numFires;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue