diff --git a/Logic/SimpleMetaTagger.ts b/Logic/SimpleMetaTagger.ts index a62ee74b5..af00de028 100644 --- a/Logic/SimpleMetaTagger.ts +++ b/Logic/SimpleMetaTagger.ts @@ -294,83 +294,43 @@ export default class SimpleMetaTaggers { return true; } + // _isOpen is calculated dynamically on every call Object.defineProperty(feature.properties, "_isOpen", { enumerable: false, configurable: true, get: () => { - if (feature.properties.id === "node/7464543832") { - console.log("Getting _isOpen for ", feature.properties.i) + const tags = feature.properties + if (tags.opening_hours === undefined) { + return; + } + if (tags._country === undefined) { + return; } - delete feature.properties._isOpen - feature.properties._isOpen = undefined - const tagsSource = state.allElements.getEventSourceById(feature.properties.id); - tagsSource.addCallbackAndRunD(tags => { - // Install a listener to the tags... - if (tags.opening_hours === undefined) { - return; - } - if (tags._country === undefined) { - return; - } - try { - const [lon, lat] = GeoOperations.centerpointCoordinates(feature) - const oh = new opening_hours(tags["opening_hours"], { - lat: lat, - lon: lon, - address: { - country_code: tags._country.toLowerCase() - } - }, {tag_key: "opening_hours"}); - // AUtomatically triggered on the next change (and a bit below) - const updateTags = () => { - const oldValueIsOpen = tags["_isOpen"]; - const oldNextChange = tags["_isOpen:nextTrigger"] ?? 0; - - if (oldNextChange > (new Date()).getTime() && - tags["_isOpen:oldvalue"] === tags["opening_hours"] // Check that changes have to be made - && tags["_isOpen"] !== undefined) { - // Already calculated and should not yet be triggered - return false; - } - - // Recalculate! - tags["_isOpen"] = oh.getState() ? "yes" : "no"; - const comment = oh.getComment(); - if (comment) { - tags["_isOpen:description"] = comment; - } - - if (oldValueIsOpen !== tags._isOpen) { - tagsSource.ping(); - } - - const nextChange = oh.getNextChange(); - if (nextChange !== undefined) { - const timeout = nextChange.getTime() - (new Date()).getTime(); - tags["_isOpen:nextTrigger"] = nextChange.getTime(); - tags["_isOpen:oldvalue"] = tags.opening_hours - window.setTimeout( - () => { - console.log("Updating the _isOpen tag for ", tags.id, ", it's timer expired after", timeout); - updateTags(); - }, - timeout - ) - } + try { + const [lon, lat] = GeoOperations.centerpointCoordinates(feature) + const oh = new opening_hours(tags["opening_hours"], { + lat: lat, + lon: lon, + address: { + country_code: tags._country.toLowerCase() } - updateTags(); - } catch (e) { - console.warn("Error while parsing opening hours of ", tags.id, e); - delete tags._isOpen - tags["_isOpen"] = "parse_error"; - } + }, {tag_key: "opening_hours"}); - }) - return undefined - } - }) - return true; + // Recalculate! + return oh.getState() ? "yes" : "no"; + + } catch (e) { + console.warn("Error while parsing opening hours of ", tags.id, e); + delete tags._isOpen + tags["_isOpen"] = "parse_error"; + } + }}); + + + const tagsSource = state.allElements.getEventSourceById(feature.properties.id); + + }) ) diff --git a/index.manifest b/index.manifest index 53b295e9e..9109a8b09 100644 --- a/index.manifest +++ b/index.manifest @@ -9,57 +9,57 @@ "orientation": "portrait-primary, landscape-primary", "icons": [ { - "src": "./assets/generated/svg_mapcomplete_logo72.png", + "src": "assets/generated/svg_mapcomplete_logo72.png", "sizes": "72x72", "type": "image/png" }, { - "src": "./assets/generated/svg_mapcomplete_logo96.png", + "src": "assets/generated/svg_mapcomplete_logo96.png", "sizes": "96x96", "type": "image/png" }, { - "src": "./assets/generated/svg_mapcomplete_logo120.png", + "src": "assets/generated/svg_mapcomplete_logo120.png", "sizes": "120x120", "type": "image/png" }, { - "src": "./assets/generated/svg_mapcomplete_logo128.png", + "src": "assets/generated/svg_mapcomplete_logo128.png", "sizes": "128x128", "type": "image/png" }, { - "src": "./assets/generated/svg_mapcomplete_logo144.png", + "src": "assets/generated/svg_mapcomplete_logo144.png", "sizes": "144x144", "type": "image/png" }, { - "src": "./assets/generated/svg_mapcomplete_logo152.png", + "src": "assets/generated/svg_mapcomplete_logo152.png", "sizes": "152x152", "type": "image/png" }, { - "src": "./assets/generated/svg_mapcomplete_logo180.png", + "src": "assets/generated/svg_mapcomplete_logo180.png", "sizes": "180x180", "type": "image/png" }, { - "src": "./assets/generated/svg_mapcomplete_logo192.png", + "src": "assets/generated/svg_mapcomplete_logo192.png", "sizes": "192x192", "type": "image/png" }, { - "src": "./assets/generated/svg_mapcomplete_logo384.png", + "src": "assets/generated/svg_mapcomplete_logo384.png", "sizes": "384x384", "type": "image/png" }, { - "src": "./assets/generated/svg_mapcomplete_logo512.png", + "src": "assets/generated/svg_mapcomplete_logo512.png", "sizes": "512x512", "type": "image/png" }, { - "src": "assets/svg/mapcomplete_logo.svg", + "src": "./assets/svg/mapcomplete_logo.svg", "sizes": "513x513", "type": "image/svg" } diff --git a/langs/en.json b/langs/en.json index 2262d8f86..579b00934 100644 --- a/langs/en.json +++ b/langs/en.json @@ -271,7 +271,9 @@ "apply_button": { "isApplied": "The changes are applied", "appliedOnAnotherObject": "The object {id} will receive {tags}" - } + }, + "loadingTheme": "Loading {theme}...", + "poweredByOsm": "Powered by OpenStreetMap" }, "favourite": { "panelIntro": "
Powered by OpenStreetMap