From 59f90f6ef47dcbe4e121571a9bca4325eca40493 Mon Sep 17 00:00:00 2001 From: Thomas Ballmann Date: Fri, 4 Dec 2020 21:21:16 +0100 Subject: [PATCH] auto-detect initial app state and redirect user --- app/src/App.vue | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/app/src/App.vue b/app/src/App.vue index 439c266..638503f 100644 --- a/app/src/App.vue +++ b/app/src/App.vue @@ -40,8 +40,28 @@ }, }, created () { - // load Promise.all([this.loadStats(), this.loadSettings()]).then(() => { + // init app + let goto + const setupFinished = true // TODO + const wifiConnected = this.stats.wifi.connected + + // only on initial navigation + if (!setupFinished) { + if (this.$route.path !== '/setup/start') { + goto = '/setup/start' + } + } else if (!wifiConnected) { + if (this.$route.path !== '/wifi') { + goto = '/wifi' + } + } + + if (goto) { + this.$router.push(goto) + } + + // initialization done this.isLoading = false }) },