Remove uneeded delay
This commit is contained in:
@@ -3,8 +3,8 @@ import { Injectable } from '@angular/core';
|
||||
import { Store, Action } from '@ngrx/store';
|
||||
import { Effect, Actions,ofType } from '@ngrx/effects';
|
||||
|
||||
import { Observable , of } from 'rxjs';
|
||||
import { withLatestFrom, switchMap, map, catchError, mergeMap,delay } from 'rxjs/operators';
|
||||
import { Observable , of, interval } from 'rxjs';
|
||||
import { withLatestFrom, switchMap, map, catchError, mergeMap,delayWhen } from 'rxjs/operators';
|
||||
|
||||
import {GeoJSON,WKT} from 'ol/format';
|
||||
import {Feature} from 'ol';
|
||||
@@ -113,19 +113,21 @@ export class MapEffects {
|
||||
@Effect()
|
||||
startSearch$: Observable<Action> = this.actions$.pipe(
|
||||
ofType(mapActions.STARTSEARCH),
|
||||
switchMap((action: mapActions.StartSearch) => {
|
||||
var startDate = action.queryState.startDate;
|
||||
var endDate = action.queryState.endDate;
|
||||
withLatestFrom(this.store$.select(mapReducers.selectgetSetStateCount)),
|
||||
switchMap(([action,setStateCount]) => {
|
||||
let a = action as mapActions.StartSearch;
|
||||
var startDate = a.queryState.startDate;
|
||||
var endDate = a.queryState.endDate;
|
||||
var newAction:Observable<Action>;
|
||||
if (action.queryState.itemCode || action.queryState.parentCode || action.queryState.itemType || action.queryState.query || action.queryState.tags) {
|
||||
newAction= this.itemService$.getFeatures(action.queryState.bbox, "EPSG:3857", action.queryState.query, action.queryState.tags, startDate, endDate, action.queryState.itemType, action.queryState.parentCode).pipe(
|
||||
if (a.queryState.itemCode || a.queryState.parentCode || a.queryState.itemType || a.queryState.query || a.queryState.tags) {
|
||||
newAction= this.itemService$.getFeatures(a.queryState.bbox, "EPSG:3857", a.queryState.query, a.queryState.tags, startDate, endDate, a.queryState.itemType, a.queryState.parentCode).pipe(
|
||||
switchMap((features: any) => {
|
||||
for (let f of features.features) {
|
||||
if (f.properties && f.properties["code"]) {
|
||||
f.id = f.properties["code"];
|
||||
}
|
||||
}
|
||||
return of(new mapActions.StartSearchSuccess(this._geojsonFormat.readFeatures(features), action.queryState));
|
||||
return of(new mapActions.StartSearchSuccess(this._geojsonFormat.readFeatures(features), a.queryState,setStateCount));
|
||||
}
|
||||
),
|
||||
catchError(error => of(new commonActions.Fail(error))));
|
||||
@@ -139,7 +141,7 @@ export class MapEffects {
|
||||
@Effect()
|
||||
zoomToExtent$: Observable<Action> = this.actions$.pipe(
|
||||
ofType(mapActions.STARTSEARCHSUCCESS),
|
||||
delay(500),
|
||||
delayWhen(action => (action as mapActions.StartSearchSuccess).setStateCount == 1 ? interval(500):interval(0)),
|
||||
mergeMap((action: mapActions.StartSearchSuccess) => {
|
||||
let actions =[];
|
||||
actions.push(new commonActions.SetMenuVisible(false));
|
||||
|
Reference in New Issue
Block a user