From 39aff86c76b51d6ed1b6277bbc365257fb6426d8 Mon Sep 17 00:00:00 2001 From: Pieter Vander Vennet Date: Wed, 17 May 2023 13:19:43 +0200 Subject: [PATCH] Refactoring: tweak some featuresources to allow them to run in the tests --- Logic/FeatureSource/Actors/TileLocalStorage.ts | 7 +++++++ Logic/FeatureSource/PerLayerFeatureSourceSplitter.ts | 10 +++++++--- Logic/FeatureSource/Sources/LastClickFeatureSource.ts | 2 +- 3 files changed, 15 insertions(+), 4 deletions(-) diff --git a/Logic/FeatureSource/Actors/TileLocalStorage.ts b/Logic/FeatureSource/Actors/TileLocalStorage.ts index 22e7dbb03..897c2e852 100644 --- a/Logic/FeatureSource/Actors/TileLocalStorage.ts +++ b/Logic/FeatureSource/Actors/TileLocalStorage.ts @@ -14,6 +14,7 @@ export default class TileLocalStorage { private readonly inUse = new UIEventSource(false) private readonly cachedSources: Record & { flush: () => void }> = {} + private static readonly useIndexedDb = typeof indexedDB !== "undefined" private constructor(layername: string) { this._layername = layername } @@ -49,6 +50,9 @@ export default class TileLocalStorage { } private async SetIdb(tileIndex: number, data: any): Promise { + if(!TileLocalStorage.useIndexedDb){ + return + } try { await this.inUse.AsPromise((inUse) => !inUse) this.inUse.setData(true) @@ -69,6 +73,9 @@ export default class TileLocalStorage { } private GetIdb(tileIndex: number): Promise { + if(!TileLocalStorage.useIndexedDb){ + return undefined + } return IdbLocalStorage.GetDirectly(this._layername + "_" + tileIndex) } } diff --git a/Logic/FeatureSource/PerLayerFeatureSourceSplitter.ts b/Logic/FeatureSource/PerLayerFeatureSourceSplitter.ts index 38b64748b..4e782b5e1 100644 --- a/Logic/FeatureSource/PerLayerFeatureSourceSplitter.ts +++ b/Logic/FeatureSource/PerLayerFeatureSourceSplitter.ts @@ -1,8 +1,8 @@ -import { FeatureSource, IndexedFeatureSource } from "./FeatureSource" +import {FeatureSource} from "./FeatureSource" import FilteredLayer from "../../Models/FilteredLayer" import SimpleFeatureSource from "./Sources/SimpleFeatureSource" -import { Feature } from "geojson" -import { UIEventSource } from "../UIEventSource" +import {Feature} from "geojson" +import {UIEventSource} from "../UIEventSource" /** * In some rare cases, some elements are shown on multiple layers (when 'passthrough' is enabled) @@ -59,6 +59,10 @@ export default class PerLayerFeatureSourceSplitter uiElem.ConstructElement().innerHTML) + allPresets.map((uiElem) => Utils.runningFromConsole ? "" : uiElem.ConstructElement().innerHTML) ) const properties = {