Debug: add localstorage debug overview

This commit is contained in:
Pieter Vander Vennet 2025-02-03 22:03:14 +01:00
parent 833b827523
commit b5b79601f9
2 changed files with 46 additions and 2 deletions

View file

@ -1520,6 +1520,34 @@
],
"condition": "mapcomplete-show_debug=yes",
"render": "{all_tags()}"
},
{
"id": "debug_storage_accordeon",
"render": {
"special": {
"type": "group",
"header": "debug_storage_accordeon_title",
"labels": "debug_storage"
}
}
},
{
"id": "debug_storage_accordeon_title",
"labels": [
"hidden"
],
"render": {
"en": "Debug information about local storage"
}
},
{
"id": "debug_storage",
"labels": [
"hidden"
],
"render": {
"*": "{storage_all_tags()}"
}
}
],
"allowMove": false

View file

@ -7,7 +7,7 @@ import LoginButton from "../Base/LoginButton.svelte"
import ThemeViewState from "../../Models/ThemeViewState"
import OrientationDebugPanel from "../Debug/OrientationDebugPanel.svelte"
import AllTagsPanel from "../Popup/AllTagsPanel.svelte"
import { UIEventSource } from "../../Logic/UIEventSource"
import { ImmutableStore, UIEventSource } from "../../Logic/UIEventSource"
import ClearCaches from "../Popup/ClearCaches.svelte"
import Locale from "../i18n/Locale"
import LanguageUtils from "../../Utils/LanguageUtils"
@ -75,6 +75,22 @@ export class SettingsVisualisations {
})
}
},
{
funcName: "storage_all_tags",
group: "settings",
docs: "Shows the current state of storage",
args: [],
constr(
state: SpecialVisualizationState
): SvelteUIElement {
const data = {}
for (const key in localStorage) {
data[key] = localStorage[key]
}
const tags = new ImmutableStore(data)
return new SvelteUIElement(AllTagsPanel, { state, tags })
}
},
{
funcName: "clear_caches",
docs: "A button which clears the locally downloaded data and the service worker. Login status etc will be kept",
@ -89,7 +105,7 @@ export class SettingsVisualisations {
constr(
_: SpecialVisualizationState,
__: UIEventSource<Record<string, string>>,
argument: string[],
argument: string[]
): SvelteUIElement {
return new SvelteUIElement(ClearCaches, {
msg: argument[0] ?? "Clear local caches"