diff --git a/src/renderer/src/App.tsx b/src/renderer/src/App.tsx index a79bcd0..c900711 100644 --- a/src/renderer/src/App.tsx +++ b/src/renderer/src/App.tsx @@ -18,6 +18,7 @@ import { DeviceDetailScreen } from "./components/DeviceDetailScreen"; import { SettingsScreen } from "./components/SettingsScreen"; import { ScenesScreen } from "./components/ScenesScreen"; import { HideOnScroll } from "./components/HideOnScroll"; +import { EnvironmentStatusBar } from "./components/EnvironmentStatusBar"; import { AppDispatch } from "./store/store"; import { createAppTheme } from "./theme"; import { @@ -29,7 +30,14 @@ import { testApiCredentials, selectTheme, } from "./store/slices/settingsSlice"; -import { loadDeviceOrder, pollAllDeviceStatuses, selectAllDevices } from "./store/slices/deviceSlice"; // Added pollAllDeviceStatuses +import { + clearDevices, + clearSelectedDeviceStatus, + fetchDevices, + loadDeviceOrder, + pollAllDeviceStatuses, + selectAllDevices, +} from "./store/slices/deviceSlice"; import { loadNightLightSceneAssignments, loadSceneOrder } from "./store/slices/sceneSlice"; import { useTranslation } from "./useTranslation"; @@ -106,6 +114,17 @@ function App() { dispatch(testApiCredentials()); }, [dispatch, storedToken, storedSecret]); + // Fetch device list at the App level so the environment status bar (and + // polling) work regardless of which view is active on startup. + useEffect(() => { + if (isTokenValid && storedToken) { + dispatch(fetchDevices()); + return; + } + dispatch(clearDevices()); + dispatch(clearSelectedDeviceStatus()); + }, [dispatch, isTokenValid, storedToken]); + // Effect for polling logic useEffect(() => { // Clear any existing timer @@ -204,9 +223,12 @@ function App() { - + {t("App Title")} + + +