diff --git a/src/Logic/ImageProviders/AllImageProviders.ts b/src/Logic/ImageProviders/AllImageProviders.ts index 311d0be43d..6045148f27 100644 --- a/src/Logic/ImageProviders/AllImageProviders.ts +++ b/src/Logic/ImageProviders/AllImageProviders.ts @@ -2,7 +2,7 @@ import { Mapillary } from "./Mapillary" import { WikimediaImageProvider } from "./WikimediaImageProvider" import { Imgur } from "./Imgur" import GenericImageProvider from "./GenericImageProvider" -import { ImmutableStore, Store, UIEventSource } from "../UIEventSource" +import { ImmutableStore, Store, Stores } from "../UIEventSource" import ImageProvider, { ProvidedImage } from "./ImageProvider" import { WikidataImageProvider } from "./WikidataImageProvider" import Panoramax from "./Panoramax" @@ -36,8 +36,8 @@ export default class AllImageProviders { public static apiUrls: string[] = [].concat( ...AllImageProviders.imageAttributionSources.map((src) => src.apiUrls()) ) - public static defaultKeys = [].concat( - AllImageProviders.imageAttributionSources.map((provider) => provider.defaultKeyPrefixes) + public static defaultKeys: string[] = [].concat( + ...AllImageProviders.imageAttributionSources.map((provider) => provider.defaultKeyPrefixes) ) private static providersByName = { imgur: Imgur.singleton, @@ -122,7 +122,6 @@ export default class AllImageProviders { return this._cachedImageStores[cachekey] } - const source = new UIEventSource([]) const allSources: Store[] = [] for (const imageProvider of AllImageProviders.imageAttributionSources) { /* @@ -132,12 +131,11 @@ export default class AllImageProviders { const prefixes = tagKey ?? imageProvider.defaultKeyPrefixes const singleSource = tags.bindD((tags) => imageProvider.getRelevantUrls(tags, prefixes)) allSources.push(singleSource) - singleSource.addCallbackAndRunD((_) => { - const all: ProvidedImage[] = [].concat(...allSources.map((source) => source.data)) - const dedup = Utils.DedupOnId(all, (i) => i?.id ?? i?.url) - source.set(dedup) - }) } + const source = Stores.fromStoresArray(allSources).map(result => { + const all = [].concat(...result) + return Utils.DedupOnId(all, (i) => i?.id ?? i?.url) + }) this._cachedImageStores[cachekey] = source return source }