Remember hide/show status of marker-sets

This commit is contained in:
Lukas Rieger (Blue) 2023-06-18 17:15:44 +02:00
parent 85f4735050
commit cb638910ce
No known key found for this signature in database
GPG Key ID: 2D09EC5ED2687FF2
2 changed files with 14 additions and 4 deletions

View File

@ -65,6 +65,7 @@ export default {
if (this.markerSet.toggleable) {
// eslint-disable-next-line vue/no-mutating-props
this.markerSet.visible = !this.markerSet.visible
this.markerSet.saveState();
}
},
more(event) {

View File

@ -30,6 +30,7 @@ import {LineMarker} from "./LineMarker";
import {HtmlMarker} from "./HtmlMarker";
import {PoiMarker} from "./PoiMarker";
import {reactive} from "vue";
import {getLocalStorage, setLocalStorage} from "../Utils";
export class MarkerSet extends Scene {
@ -58,6 +59,9 @@ export class MarkerSet extends Scene {
return this.toggleable ||
this.markers.filter(marker => marker.listed).length > 0 ||
this.markerSets.filter(markerSet => markerSet.listed).length > 0
},
saveState: () => {
setLocalStorage("markerset-" + this.data.id + "-visible", this.visible);
}
});
@ -65,6 +69,15 @@ export class MarkerSet extends Scene {
get() { return this.data.visible },
set(value) { this.data.visible = value }
});
if (this.data.toggleable) {
let storedVisible = getLocalStorage("markerset-" + this.data.id + "-visible");
if (storedVisible !== undefined) {
this.visible = !!storedVisible;
} else if (this.data.defaultHide) {
this.visible = false;
}
}
}
updateFromData(data) {
@ -112,10 +125,6 @@ export class MarkerSet extends Scene {
if (!markerSet) {
markerSet = new MarkerSet(markerSetId);
this.add(markerSet);
if (data.defaultHidden) {
markerSet.visible = false;
}
}
// update