Procházet zdrojové kódy

🐛 fix the layer load for the third time

with yet another method FTW
jmacura před 4 roky
rodič
revize
583adb58e7

+ 0 - 1
src/adjuster/adjuster.component.ts

@@ -34,7 +34,6 @@ export class AdjusterComponent implements HsPanelComponent {
   }
 
   ngOnInit(): void {
-    this.adjusterService.init();
     this.hsDialogContainerService.create(AdjusterLoaderComponent, {});
   }
 

+ 12 - 16
src/adjuster/adjuster.service.ts

@@ -3,6 +3,7 @@ import {Injectable} from '@angular/core';
 import {Vector as VectorLayer} from 'ol/layer';
 
 import {HsConfig} from 'hslayers-ng/config.service';
+import {HsEventBusService} from 'hslayers-ng/components/core/event-bus.service';
 import {HsLayerManagerMetadataService} from 'hslayers-ng/components/layermanager/layermanager-metadata.service';
 import {HsLayerManagerService} from 'hslayers-ng/components/layermanager';
 import {HsUtilsService} from 'hslayers-ng/components/utils/utils.service';
@@ -36,6 +37,7 @@ export class AdjusterService {
   constructor(
     public adjusterEventService: AdjusterEventService,
     public hsConfig: HsConfig,
+    public hsEventBus: HsEventBusService,
     public hsLayerMetadataService: HsLayerManagerMetadataService,
     public hsLayerManagerService: HsLayerManagerService,
     public hsUtilsService: HsUtilsService,
@@ -276,15 +278,10 @@ export class AdjusterService {
   }
 
   processIndex(codeRecordRelations: Record<string, unknown>): void {
-    if (obce.getFeatures()?.length < 1) {
-      this.hsUtilsService.debounce(
-        this.processIndex(codeRecordRelations),
-        300,
-        false,
-        this
-      );
+    /*if (obce.getFeatures()?.length < 1) {
+      obce.once('changefeature', () => this.processIndex(codeRecordRelations));
       return;
-    }
+    }*/
     let errs = 0;
     //let logs = 0;
     obce.forEachFeature((feature) => {
@@ -316,15 +313,14 @@ export class AdjusterService {
     method: MethodDescription,
     codeRecordRelations: Record<string, unknown>
   ): void {
-    if (method.layer?.getSource().getFeatures()?.length < 1) {
-      this.hsUtilsService.debounce(
-        this.processClusters(method, codeRecordRelations),
-        300,
-        false,
-        this
-      );
+    /*if (method.layer?.getSource().getFeatures()?.length < 1) {
+      method.layer
+        .getSource()
+        .once('changefeature', () =>
+          this.processClusters(method, codeRecordRelations)
+        );
       return;
-    }
+    }*/
     let errs = 0;
     //let logs = 0;
     method.layer.getSource().forEachFeature((feature) => {

+ 1 - 0
src/app.service.ts

@@ -108,6 +108,7 @@ export class AppService {
     this.hsConfig.default_layers.push(obceIndexLayer);
     this.hsConfig.default_layers.push(okresyLayer);
     this.hsConfig.default_layers.push(krajeLayer);
+    obceIndexLayer.on('featuresloadend', this.adjusterService.init());
   }
 
   /**