Fix bug: versions are reloaded now

This commit is contained in:
Pieter Vander Vennet 2021-07-09 19:56:00 +02:00
parent 6d4af01c38
commit e8bf46a759
2 changed files with 13 additions and 6 deletions

View file

@ -36,15 +36,22 @@ export abstract class OsmObject {
this.backendURL = url; this.backendURL = url;
} }
static DownloadObject(id): UIEventSource<OsmObject> { static DownloadObject(id: string, forceRefresh: boolean = false): UIEventSource<OsmObject> {
let src : UIEventSource<OsmObject>;
if (OsmObject.objectCache.has(id)) { if (OsmObject.objectCache.has(id)) {
return OsmObject.objectCache.get(id) src = OsmObject.objectCache.get(id)
if(forceRefresh){
src.setData(undefined)
}else{
return src;
}
}else{
src = new UIEventSource<OsmObject>(undefined)
} }
const splitted = id.split("/"); const splitted = id.split("/");
const type = splitted[0]; const type = splitted[0];
const idN = splitted[1]; const idN = splitted[1];
const src = new UIEventSource<OsmObject>(undefined)
OsmObject.objectCache.set(id, src); OsmObject.objectCache.set(id, src);
const newContinuation = (element: OsmObject) => { const newContinuation = (element: OsmObject) => {
src.setData(element) src.setData(element)
@ -158,11 +165,11 @@ export abstract class OsmObject {
}) })
} }
public static DownloadAll(neededIds): UIEventSource<OsmObject[]> { public static DownloadAll(neededIds, forceRefresh = true): UIEventSource<OsmObject[]> {
// local function which downloads all the objects one by one // local function which downloads all the objects one by one
// this is one big loop, running one download, then rerunning the entire function // this is one big loop, running one download, then rerunning the entire function
const allSources: UIEventSource<OsmObject> [] = neededIds.map(id => OsmObject.DownloadObject(id)) const allSources: UIEventSource<OsmObject> [] = neededIds.map(id => OsmObject.DownloadObject(id, forceRefresh))
const allCompleted = new UIEventSource(undefined).map(_ => { const allCompleted = new UIEventSource(undefined).map(_ => {
return !allSources.some(uiEventSource => uiEventSource.data === undefined) return !allSources.some(uiEventSource => uiEventSource.data === undefined)
}, allSources) }, allSources)

View file

@ -2,7 +2,7 @@ import { Utils } from "../Utils";
export default class Constants { export default class Constants {
public static vNumber = "0.8.3c"; public static vNumber = "0.8.3d";
// The user journey states thresholds when a new feature gets unlocked // The user journey states thresholds when a new feature gets unlocked
public static userJourney = { public static userJourney = {