update "store" from ConfigView
This commit is contained in:
parent
41889d9160
commit
e2a14821ba
2 changed files with 64 additions and 42 deletions
|
@ -255,10 +255,13 @@ export default class extends Vue {
|
|||
|
||||
public on_open(ready: () => void, fail: () => void): void {
|
||||
Promise.all([
|
||||
this.store.update(),
|
||||
this.$advent22.api_get<AdminConfigModel>("admin/config_model"),
|
||||
this.$advent22.api_get<DoorSaved[]>("admin/doors"),
|
||||
])
|
||||
.then(([admin_config_model, doors]) => {
|
||||
.then(([store_update, admin_config_model, doors]) => {
|
||||
store_update; // discard value
|
||||
|
||||
this.admin_config_model = admin_config_model;
|
||||
this.doors = doors;
|
||||
|
||||
|
|
|
@ -60,8 +60,16 @@ export const advent22Store = defineStore({
|
|||
|
||||
actions: {
|
||||
init(): void {
|
||||
this.update_is_admin();
|
||||
this.update()
|
||||
.then(() => {
|
||||
this.is_initialized = true;
|
||||
for (const callback of this.on_initialized) callback();
|
||||
})
|
||||
.catch(this.advent22.alert_user_error);
|
||||
},
|
||||
|
||||
update(): Promise<void> {
|
||||
return new Promise((resolve, reject) => {
|
||||
this.advent22
|
||||
.api_get_blob("user/favicon")
|
||||
.then((favicon_src) => {
|
||||
|
@ -78,12 +86,22 @@ export const advent22Store = defineStore({
|
|||
.catch(() => {});
|
||||
|
||||
Promise.all([
|
||||
this.update_is_admin(),
|
||||
this.advent22.api_get<SiteConfigModel>("user/site_config"),
|
||||
this.advent22.api_get_blob("user/background_image"),
|
||||
this.advent22.api_get<DoorSaved[]>("user/doors"),
|
||||
this.advent22.api_get<number | null>("user/next_door"),
|
||||
])
|
||||
.then(([site_config, background_image, user_doors, next_door]) => {
|
||||
.then(
|
||||
([
|
||||
is_admin,
|
||||
site_config,
|
||||
background_image,
|
||||
user_doors,
|
||||
next_door,
|
||||
]) => {
|
||||
is_admin; // discard value
|
||||
|
||||
document.title = site_config.title;
|
||||
|
||||
if (site_config.subtitle !== "")
|
||||
|
@ -101,10 +119,11 @@ export const advent22Store = defineStore({
|
|||
if (next_door !== null)
|
||||
this.next_door_target = Date.now() + next_door;
|
||||
|
||||
this.is_initialized = true;
|
||||
for (const callback of this.on_initialized) callback();
|
||||
})
|
||||
.catch(this.advent22.alert_user_error);
|
||||
resolve();
|
||||
},
|
||||
)
|
||||
.catch(reject);
|
||||
});
|
||||
},
|
||||
|
||||
when_initialized(callback: () => void): void {
|
||||
|
|
Loading…
Reference in a new issue