Fix request canceling
All checks were successful
FarmMaps.Develop/FarmMapsLib/pipeline/head This commit looks good

This commit is contained in:
Willem Dantuma
2021-03-05 18:41:09 +01:00
parent 9d5cd0fa88
commit aa308abbb0
3 changed files with 23 additions and 8 deletions

View File

@@ -300,13 +300,25 @@ export class MapEffects {
@Effect()
getLayerValue$: Observable<Action> = this.actions$.pipe(
ofType(mapActions.GETLAYERVALUE),
switchMap((action:mapActions.GetLayerValue) => {
mergeMap((action:mapActions.GetLayerValue) => {
var l = action.itemLayer.item.data["layers"][action.itemLayer.layerIndex];
var scale = l.scale?l.scale:1;
return this.itemService$.getLayerValue(action.itemLayer.item.code,action.itemLayer.layerIndex,action.x,action.y).pipe(
switchMap((v: number) => {
mergeMap((v: number) => {
let a=[];
if(v) a.push(new mapActions.GetLayerValueSuccess({date:"",value:v*scale,layerName:l.name,quantity:l.quantity,unit:l.unit}));
if(v) {
if(l.renderer && l.renderer.colorMap && l.renderer.colorMap.colormapType == "manual") {
l.renderer.colorMap.entries.forEach((e) => {
if(e.value == v) {
v=e.label;
return;
}
});
a.push(new mapActions.GetLayerValueSuccess({date:action.itemLayer.item.dataDate,value:v,layerName:l.name,quantity:"",unit:l.unit}));
} else {
a.push(new mapActions.GetLayerValueSuccess({date:action.itemLayer.item.dataDate,value:v*scale,layerName:l.name,quantity:l.quantity,unit:l.unit}));
}
}
return a;
}))
}
@@ -327,7 +339,7 @@ export class MapEffects {
withLatestFrom(this.store$.select(mapReducers.selectGetSelectedItemLayer)),
withLatestFrom(this.store$.select(mapReducers.selectGetLayerValuesEnabled)),
withLatestFrom(this.store$.select(mapReducers.selectGetOverlayLayers)),
switchMap(([[[action, selected], enabled],overlayLayers]) => {
mergeMap(([[[action, selected], enabled],overlayLayers]) => {
let layers = [];
if(selected) layers.push(selected);
overlayLayers.forEach((ol) => {