diff --git a/ui/src/lib/store.ts b/ui/src/lib/store.ts index 9b7388f..2bd837f 100644 --- a/ui/src/lib/store.ts +++ b/ui/src/lib/store.ts @@ -67,30 +67,34 @@ export const advent22Store = defineStore({ document.getElementsByTagName("head")[0].appendChild(link); } catch {} - const [is_admin, site_config, background_image, user_doors, next_door] = - await Promise.all([ - this.update_is_admin(), - API.request("user/site_config"), - API.request("user/background_image"), - API.request("user/doors"), - API.request("user/next_door"), - ]); - is_admin; // discard value + try { + const [is_admin, site_config, background_image, user_doors, next_door] = + await Promise.all([ + this.update_is_admin(), + API.request("user/site_config"), + API.request("user/background_image"), + API.request("user/doors"), + API.request("user/next_door"), + ]); + is_admin; // discard value - document.title = site_config.title; + document.title = site_config.title; - if (site_config.subtitle !== "") - document.title += " – " + site_config.subtitle; + if (site_config.subtitle !== "") + document.title += " – " + site_config.subtitle; - this.site_config = site_config; - this.background_image = background_image; + this.site_config = site_config; + this.background_image = background_image; - this.user_doors.length = 0; - for (const door_saved of user_doors) { - this.user_doors.push(Door.load(door_saved)); + 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; + } catch { + this.background_image = "error"; } - - if (next_door !== null) this.next_door_target = Date.now() + next_door; }, when_initialized(callback: () => void): void {