chore: automated housekeeping...

This commit is contained in:
Pieter Vander Vennet 2025-06-18 21:40:01 +02:00
parent 94c61744c0
commit 04c8ccb0d2
89 changed files with 2353 additions and 1390 deletions

View file

@ -66,15 +66,19 @@ export default class InitialMapPositioning {
defaultLon,
"The initial/current longitude of the app"
)
const geouri = QueryParameters.GetQueryParameter("geouri", undefined, "Alternative format to set lat/lon; but with an entire geouri instead. ")
console.log("geouri", geouri.data, !!geouri.data)
if (geouri.data) {
const geouri = QueryParameters.GetQueryParameter(
"geouri",
undefined,
"Alternative format to set lat/lon; but with an entire geouri instead. "
)
console.log("geouri", geouri.data, !!geouri.data)
if (geouri.data) {
try {
const url = new URL("geo:"+decodeURIComponent(geouri.data))
const [latN, lonN] = url.pathname.split(",").map(n => parseFloat(n))
const url = new URL("geo:" + decodeURIComponent(geouri.data))
const [latN, lonN] = url.pathname.split(",").map((n) => parseFloat(n))
lat.set(latN)
lon.set(lonN)
if(url.searchParams.has("q")){
if (url.searchParams.has("q")) {
QueryParameters.GetQueryParameter("q", undefined).set(url.searchParams.get("q"))
}
} catch (e) {

View file

@ -35,8 +35,9 @@ export default class GenericImageProvider extends ImageProvider {
id: value,
isSpherical: undefined,
originalAttribute: {
key, value
}
key,
value,
},
},
]
}

View file

@ -26,7 +26,7 @@ export interface ProvidedImage {
host?: string
isSpherical: boolean
license?: LicenseInfo
originalAttribute?: {key: string, value: string}
originalAttribute?: { key: string; value: string }
}
export interface PanoramaView {

View file

@ -180,13 +180,13 @@ export class ImageUploadManager {
queue = [...queue]
while (queue.length > 0) {
const currentItem = queue.shift()
if(!currentItem){
if (!currentItem) {
continue
}
const uploadOk = await this.handleQueueItem(currentItem)
if(uploadOk){
if (uploadOk) {
this._queue.delete(currentItem)
}else{
} else {
// Our local 'queue' is a copy where we've removed the failed item from
// A next attempt to 'uploadQueue' will retry the upload
}
@ -255,7 +255,7 @@ export class ImageUploadManager {
if (properties === undefined) {
const downloaded = await new OsmObjectDownloader(
this._osmConnection.Backend(),
this._changes,
this._changes
).DownloadObjectAsync(args.featureId)
if (downloaded === "deleted") {
this._queue.delete(args)
@ -264,16 +264,10 @@ export class ImageUploadManager {
this._featureProperties.trackFeature(downloaded.asGeoJson())
properties = this._featureProperties.getStore(args.featureId)
}
const action = new LinkImageAction(
args.featureId,
result.key,
result.value,
properties,
{
theme: args.layoutId ?? properties?.data?.["_orig_theme"] ?? this._theme.id,
changeType: "add-image",
},
)
const action = new LinkImageAction(args.featureId, result.key, result.value, properties, {
theme: args.layoutId ?? properties?.data?.["_orig_theme"] ?? this._theme.id,
changeType: "add-image",
})
await this._changes.applyAction(action)
await this._changes.flushChanges("Image upload completed")
return true

View file

@ -33,7 +33,7 @@ export class Imgur extends ImageProvider {
provider: this,
id: value,
isSpherical: false,
originalAttribute: {key, value}
originalAttribute: { key, value },
},
]
}

View file

@ -246,7 +246,7 @@ export class Mapillary extends ImageProvider {
response.camera_type === "spherical" || response.camera_type === "equirectangular",
lat: geometry.coordinates[1],
lon: geometry.coordinates[0],
originalAttribute: {key, value}
originalAttribute: { key, value },
}
}
@ -260,14 +260,15 @@ export class Mapillary extends ImageProvider {
return Mapillary.createLink(location, 17, image.id)
}
/**
* Returns true if we are in firefox strict mode (or if we are offline)
* @private
*/
private static async checkStrictMode(): Promise<boolean> {
try {
const result = await fetch("https://scontent-bru2-1.xx.fbcdn.net/m1/v/t6/Xn8-ISUUYQyBD9FyACzPFRGZnBJRqIFmnQ_yd7FU6vxFYwD21fvAcZwDQoMzsScxcQyCWeBviKpWO4nX8yf--neJDvVjC4JlQtfBYb6TrpXQTniyafSFeZeePT_NVx3H6gMjceEvXHyvBqOOcCB_xQ?stp=c2048.2048.2000.988a_s1000x1000&_nc_gid=E2oHnrAtHutVvjaIm9qDLg&_nc_oc=AdkcScR9HuKt1X_K5-GrUeR5Paj8d7MsNFFYEBSmgc0IiBey_wS3RiNJpflWIKaQzNE&ccb=10-5&oh=00_AfNJ1Ki1IeGdUMxdFUc3ZX9VYIVFxVfXZ9MUATU3vj_RJw&oe=686AF002&_nc_sid=201bca")
const result = await fetch(
"https://scontent-bru2-1.xx.fbcdn.net/m1/v/t6/Xn8-ISUUYQyBD9FyACzPFRGZnBJRqIFmnQ_yd7FU6vxFYwD21fvAcZwDQoMzsScxcQyCWeBviKpWO4nX8yf--neJDvVjC4JlQtfBYb6TrpXQTniyafSFeZeePT_NVx3H6gMjceEvXHyvBqOOcCB_xQ?stp=c2048.2048.2000.988a_s1000x1000&_nc_gid=E2oHnrAtHutVvjaIm9qDLg&_nc_oc=AdkcScR9HuKt1X_K5-GrUeR5Paj8d7MsNFFYEBSmgc0IiBey_wS3RiNJpflWIKaQzNE&ccb=10-5&oh=00_AfNJ1Ki1IeGdUMxdFUc3ZX9VYIVFxVfXZ9MUATU3vj_RJw&oe=686AF002&_nc_sid=201bca"
)
console.log("Not blocked, got a forbidden", result.status)
return false
} catch (e) {

View file

@ -174,7 +174,7 @@ export default class PanoramaxImageProvider extends ImageProvider {
}
const providedImage = await this.getInfo(value)
providedImage.alt_id = alt_id
providedImage.originalAttribute = {key, value}
providedImage.originalAttribute = { key, value }
return [providedImage]
}

View file

@ -61,9 +61,9 @@ export class WikidataImageProvider extends ImageProvider {
allImages.push(promises)
}
const resolved = await Promise.all(Utils.NoNull(allImages))
const flattened = resolved.flatMap( x => x)
if(flattened.length === 1){
flattened[0].originalAttribute = {key, value}
const flattened = resolved.flatMap((x) => x)
if (flattened.length === 1) {
flattened[0].originalAttribute = { key, value }
}
return flattened
}

View file

@ -221,8 +221,8 @@ export class WikimediaImageProvider extends ImageProvider {
id: image,
isSpherical: false,
}
if(key && value){
providedImage.originalAttribute = {key, value}
if (key && value) {
providedImage.originalAttribute = { key, value }
}
return providedImage
}

View file

@ -269,20 +269,23 @@ export default class UserRelatedState {
)
this.language = this.osmConnection.getPreference("language")
this.showTags = this.osmConnection.getPreference("show_tags")
this.showTagsB = this.showTags.map(showTags => {
if (showTags === "always" || showTags === "full") {
return true
}
if (showTags === "no") {
return false
}
const userdetails = this.osmConnection.userDetails.data
if (!userdetails) {
return false
}
const csCount = userdetails.csCount
return csCount >= Constants.userJourney.tagsVisibleAt
}, [this.osmConnection.userDetails])
this.showTagsB = this.showTags.map(
(showTags) => {
if (showTags === "always" || showTags === "full") {
return true
}
if (showTags === "no") {
return false
}
const userdetails = this.osmConnection.userDetails.data
if (!userdetails) {
return false
}
const csCount = userdetails.csCount
return csCount >= Constants.userJourney.tagsVisibleAt
},
[this.osmConnection.userDetails]
)
this.showCrosshair = this.osmConnection.getPreference("show_crosshair")
this.fixateNorth = this.osmConnection.getPreference("fixate-north")
this.morePrivacy = this.osmConnection.getPreference("more_privacy", { defaultValue: "no" })

View file

@ -1,14 +1,42 @@
import { Utils } from "../../Utils"
/** This code is autogenerated - do not edit. Edit ./assets/layers/usersettings/usersettings.json instead */
export class ThemeMetaTagging {
public static readonly themeName = "usersettings"
public static readonly themeName = "usersettings"
public metaTaggging_for_usersettings(feat: {properties: Record<string, string>}) {
Utils.AddLazyProperty(feat.properties, '_mastodon_candidate_md', () => feat.properties._description.match(/\[[^\]]*\]\((.*(mastodon|en.osm.town).*)\).*/)?.at(1) )
Utils.AddLazyProperty(feat.properties, '_d', () => feat.properties._description?.replace(/&lt;/g,'<')?.replace(/&gt;/g,'>') ?? '' )
Utils.AddLazyProperty(feat.properties, '_mastodon_candidate_a', () => (feat => {const e = document.createElement('div');e.innerHTML = feat.properties._d;return Array.from(e.getElementsByTagName("a")).filter(a => a.href.match(/mastodon|en.osm.town/) !== null)[0]?.href }) (feat) )
Utils.AddLazyProperty(feat.properties, '_mastodon_link', () => (feat => {const e = document.createElement('div');e.innerHTML = feat.properties._d;return Array.from(e.getElementsByTagName("a")).filter(a => a.getAttribute("rel")?.indexOf('me') >= 0)[0]?.href})(feat) )
Utils.AddLazyProperty(feat.properties, '_mastodon_candidate', () => feat.properties._mastodon_candidate_md ?? feat.properties._mastodon_candidate_a )
feat.properties['__current_backgroun'] = 'initial_value'
}
}
public metaTaggging_for_usersettings(feat: { properties: Record<string, string> }) {
Utils.AddLazyProperty(feat.properties, "_mastodon_candidate_md", () =>
feat.properties._description
.match(/\[[^\]]*\]\((.*(mastodon|en.osm.town).*)\).*/)
?.at(1)
)
Utils.AddLazyProperty(
feat.properties,
"_d",
() => feat.properties._description?.replace(/&lt;/g, "<")?.replace(/&gt;/g, ">") ?? ""
)
Utils.AddLazyProperty(feat.properties, "_mastodon_candidate_a", () =>
((feat) => {
const e = document.createElement("div")
e.innerHTML = feat.properties._d
return Array.from(e.getElementsByTagName("a")).filter(
(a) => a.href.match(/mastodon|en.osm.town/) !== null
)[0]?.href
})(feat)
)
Utils.AddLazyProperty(feat.properties, "_mastodon_link", () =>
((feat) => {
const e = document.createElement("div")
e.innerHTML = feat.properties._d
return Array.from(e.getElementsByTagName("a")).filter(
(a) => a.getAttribute("rel")?.indexOf("me") >= 0
)[0]?.href
})(feat)
)
Utils.AddLazyProperty(
feat.properties,
"_mastodon_candidate",
() => feat.properties._mastodon_candidate_md ?? feat.properties._mastodon_candidate_a
)
feat.properties["__current_backgroun"] = "initial_value"
}
}