Cleanup of changeset handler, prep for #2082

This commit is contained in:
Pieter Vander Vennet 2024-08-24 12:01:46 +02:00
parent e3a0a1dbcb
commit 90916cdd32
5 changed files with 161 additions and 138 deletions

View file

@ -278,7 +278,7 @@ export default class ThemeViewState implements SpecialVisualizationState {
featureSwitches: this.featureSwitches,
},
layout?.isLeftRightSensitive() ?? false,
(e) => this.reportError(e),
(e, extraMsg) => this.reportError(e, extraMsg),
)
this.historicalUserLocations = this.geolocation.historicalUserLocations
this.newFeatures = new NewGeometryFromChangesFeatureSource(
@ -650,9 +650,9 @@ export default class ThemeViewState implements SpecialVisualizationState {
available,
category,
current.data,
skipLayers
skipLayers,
)
if(!best){
if (!best) {
return
}
console.log("Best layer for category", category, "is", best?.properties?.id)
@ -680,19 +680,19 @@ export default class ThemeViewState implements SpecialVisualizationState {
Hotkeys.RegisterHotkey(
{ shift: "O" },
Translations.t.hotkeyDocumentation.selectOsmbasedmap,
() => setLayerCategory("osmbasedmap",2),
() => setLayerCategory("osmbasedmap", 2),
)
Hotkeys.RegisterHotkey(
{ shift: "M" },
Translations.t.hotkeyDocumentation.selectMap,
() => setLayerCategory("map",2),
() => setLayerCategory("map", 2),
)
Hotkeys.RegisterHotkey(
{ shift: "P" },
Translations.t.hotkeyDocumentation.selectAerial,
() => setLayerCategory("photo",2),
() => setLayerCategory("photo", 2),
)
Hotkeys.RegisterHotkey(
{ nomod: "L" },
@ -907,7 +907,7 @@ export default class ThemeViewState implements SpecialVisualizationState {
this.selectedElement.setData(this.currentView.features?.data?.[0])
}
public async reportError(message: string | Error | XMLHttpRequest) {
public async reportError(message: string | Error | XMLHttpRequest, extramessage: string = "") {
const isTesting = this.featureSwitchIsTesting.data
console.log(
isTesting
@ -922,7 +922,17 @@ export default class ThemeViewState implements SpecialVisualizationState {
if ("" + message === "[object XMLHttpRequest]") {
const req = <XMLHttpRequest>message
message = "XMLHttpRequest with status code " + req.status + ", " + req.statusText
let body = ""
try {
body = req.responseText
} catch (e) {
// pass
}
message = "XMLHttpRequest with status code " + req.status + ", " + req.statusText + ", received: " + body
}
if (extramessage) {
message += "(" + extramessage + ")"
}
const stacktrace: string = new Error().stack