From df0b721557f28135d90fe62e32d0abf4399cc2db Mon Sep 17 00:00:00 2001 From: Bram Kragten Date: Thu, 28 May 2020 16:22:03 +0200 Subject: [PATCH 1/4] Add state to HassConfig --- lib/types.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/types.ts b/lib/types.ts index ff50fa12..c55d88b8 100644 --- a/lib/types.ts +++ b/lib/types.ts @@ -58,6 +58,7 @@ export type HassConfig = { version: string; config_source: string; safe_mode: boolean; + state: "NOT_RUNNING" | "STARTING" | "RUNNING" | "STOPPING" | "FINAL_WRITE"; external_url: string | null; internal_url: string | null; }; From d6ba84c060aa0bb044aadad29c9ec9599af7dcd5 Mon Sep 17 00:00:00 2001 From: Bram Kragten Date: Thu, 28 May 2020 19:48:22 +0200 Subject: [PATCH 2/4] Add state constants --- lib/config.ts | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/lib/config.ts b/lib/config.ts index 16af46cd..71371bb1 100644 --- a/lib/config.ts +++ b/lib/config.ts @@ -41,3 +41,9 @@ export const subscribeConfig = ( conn: Connection, onChange: (state: HassConfig) => void ): UnsubscribeFunc => configColl(conn).subscribe(onChange); + +export const STATE_NOT_RUNNING = "NOT_RUNNING"; +export const STATE_STARTING = "STARTING"; +export const STATE_RUNNING = "RUNNING"; +export const STATE_STOPPING = "STOPPING"; +export const STATE_FINAL_WRITE = "FINAL_WRITE"; \ No newline at end of file From 4a977cc5493bb53546131c1607210dd2eef8cdc9 Mon Sep 17 00:00:00 2001 From: Bram Kragten Date: Thu, 28 May 2020 22:14:56 +0200 Subject: [PATCH 3/4] newline --- lib/config.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/config.ts b/lib/config.ts index 71371bb1..139b0fb1 100644 --- a/lib/config.ts +++ b/lib/config.ts @@ -46,4 +46,4 @@ export const STATE_NOT_RUNNING = "NOT_RUNNING"; export const STATE_STARTING = "STARTING"; export const STATE_RUNNING = "RUNNING"; export const STATE_STOPPING = "STOPPING"; -export const STATE_FINAL_WRITE = "FINAL_WRITE"; \ No newline at end of file +export const STATE_FINAL_WRITE = "FINAL_WRITE"; From ef670b266d462372dec28088150fd6d30663a01c Mon Sep 17 00:00:00 2001 From: Bram Kragten Date: Thu, 28 May 2020 22:15:15 +0200 Subject: [PATCH 4/4] Format --- lib/config.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/config.ts b/lib/config.ts index 139b0fb1..7cf1e790 100644 --- a/lib/config.ts +++ b/lib/config.ts @@ -17,7 +17,7 @@ function processComponentLoaded( if (state === undefined) return null; return { - components: state.components.concat(event.data.component) + components: state.components.concat(event.data.component), }; } @@ -29,10 +29,10 @@ const subscribeUpdates = (conn: Connection, store: Store) => "component_loaded" ), conn.subscribeEvents( - () => fetchConfig(conn).then(config => store.setState(config, true)), + () => fetchConfig(conn).then((config) => store.setState(config, true)), "core_config_updated" - ) - ]).then(unsubs => () => unsubs.forEach(unsub => unsub())); + ), + ]).then((unsubs) => () => unsubs.forEach((unsub) => unsub())); const configColl = (conn: Connection) => getCollection(conn, "_cnf", fetchConfig, subscribeUpdates);