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 v-if="store.user_doors.length > 0">
<Calendar :doors="doors" />
<Calendar :doors="store.user_doors" />
<hr />
<div class="content" v-html="store.site_config.content" />
<div class="content has-text-primary">
@ -17,7 +17,6 @@
</template>
<script lang="ts">
import { Door } from "@/lib/door";
import { advent22Store } from "@/plugins/store";
import { Options, Vue } from "vue-class-component";
@ -32,15 +31,5 @@ import CountDown from "./CountDown.vue";
})
export default class extends Vue {
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>

View file

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