store.user_doors handling

This commit is contained in:
Jörn-Michael Miehe 2023-11-09 23:14:19 +00:00
parent 9e303f898a
commit 223cc584a7
2 changed files with 8 additions and 14 deletions

View file

@ -1,6 +1,6 @@
<template> <template>
<template v-if="store.user_doors.length > 0"> <template v-if="store.user_doors.length > 0">
<Calendar :doors="doors" /> <Calendar :doors="store.user_doors" />
<hr /> <hr />
<div class="content" v-html="store.site_config.content" /> <div class="content" v-html="store.site_config.content" />
<div class="content has-text-primary"> <div class="content has-text-primary">
@ -17,7 +17,6 @@
</template> </template>
<script lang="ts"> <script lang="ts">
import { Door } from "@/lib/door";
import { advent22Store } from "@/plugins/store"; import { advent22Store } from "@/plugins/store";
import { Options, Vue } from "vue-class-component"; import { Options, Vue } from "vue-class-component";
@ -32,15 +31,5 @@ import CountDown from "./CountDown.vue";
}) })
export default class extends Vue { export default class extends Vue {
public readonly store = advent22Store(); public readonly store = advent22Store();
public get doors(): Door[] {
const result = [];
for (const value of this.store.user_doors) {
result.push(Door.load(value));
}
return result;
}
} }
</script> </script>

View file

@ -1,4 +1,5 @@
import { Credentials, DoorSaved, SiteConfigModel } from "@/lib/api"; import { Credentials, DoorSaved, SiteConfigModel } from "@/lib/api";
import { Door } from "@/lib/door";
import { Advent22 } from "@/plugins/advent22"; import { Advent22 } from "@/plugins/advent22";
import { RemovableRef, useLocalStorage } from "@vueuse/core"; import { RemovableRef, useLocalStorage } from "@vueuse/core";
import { AxiosBasicCredentials } from "axios"; import { AxiosBasicCredentials } from "axios";
@ -17,7 +18,7 @@ type State = {
is_admin: boolean; is_admin: boolean;
site_config: SiteConfigModel; site_config: SiteConfigModel;
calendar_aspect_ratio: number; calendar_aspect_ratio: number;
user_doors: DoorSaved[]; user_doors: Door[];
next_door_target: number | null; next_door_target: number | null;
}; };
@ -82,7 +83,11 @@ export const advent22Store = defineStore({
document.title += " " + site_config.subtitle; document.title += " " + site_config.subtitle;
this.site_config = site_config; this.site_config = site_config;
this.user_doors = user_doors;
this.user_doors.length = 0;
for (const door_saved of user_doors) {
this.user_doors.push(Door.load(door_saved));
}
if (next_door !== null) if (next_door !== null)
this.next_door_target = Date.now() + next_door; this.next_door_target = Date.now() + next_door;