improve chat ui
All checks were successful
Build Container / Build Container (push) Successful in 1m29s
All checks were successful
Build Container / Build Container (push) Successful in 1m29s
This commit is contained in:
parent
2ef2b04e49
commit
81923c4f8c
7 changed files with 170 additions and 48 deletions
|
|
@ -1,5 +1,6 @@
|
|||
import {Fetcher} from "openapi-typescript-fetch"
|
||||
import type {paths} from "../api/schema"
|
||||
import type {ui} from "../i18n/ui.ts"
|
||||
|
||||
const fetcher = Fetcher.for<paths>()
|
||||
|
||||
|
|
@ -25,7 +26,7 @@ export type AuthType = {
|
|||
|
||||
declare global {
|
||||
interface Window {
|
||||
lang: string;
|
||||
lang: keyof typeof ui;
|
||||
doors: Array<DoorType>;
|
||||
auth: AuthType;
|
||||
doorAction: (action: 'unlock' | 'lock', doorId: string) => void;
|
||||
|
|
@ -160,6 +161,9 @@ async function fetchDoors() {
|
|||
jammed: door.status.is_error_jammed,
|
||||
})
|
||||
})
|
||||
|
||||
loading.doors = false
|
||||
refresh()
|
||||
} catch (e) {
|
||||
// check which operation threw the exception
|
||||
if (e instanceof getDoors.Error) {
|
||||
|
|
@ -167,6 +171,8 @@ async function fetchDoors() {
|
|||
|
||||
if (error.status === 401) {
|
||||
console.log("unauthorized")
|
||||
loading.doors = false
|
||||
refresh()
|
||||
} else if (error.status >= 500 && error.status < 600) {
|
||||
apiError.current = "serverError"
|
||||
clearInterval(doorsInterval)
|
||||
|
|
@ -181,9 +187,6 @@ async function fetchDoors() {
|
|||
apiError.current = "networkError"
|
||||
}
|
||||
}
|
||||
} finally {
|
||||
loading.doors = false
|
||||
refresh()
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue