From 864a832e69651dfd20eb8a90c9ac8f781ca35400 Mon Sep 17 00:00:00 2001 From: Philip Abbey Date: Tue, 9 Jan 2024 08:58:58 +0000 Subject: [PATCH] GUI refresh amendments --- source/HomeAssistantApp.mc | 11 +++++++---- source/HomeAssistantView.mc | 4 ++-- source/RootView.mc | 4 ++++ 3 files changed, 13 insertions(+), 6 deletions(-) diff --git a/source/HomeAssistantApp.mc b/source/HomeAssistantApp.mc index 0d4b7b6..ee0e321 100644 --- a/source/HomeAssistantApp.mc +++ b/source/HomeAssistantApp.mc @@ -196,9 +196,11 @@ class HomeAssistantApp extends Application.AppBase { break; case 200: - mMenuStatus = RezStrings.getAvailable(); if (Settings.getCacheConfig()) { Storage.setValue("menu", data as Lang.Dictionary); + mMenuStatus = RezStrings.getCached(); + } else { + mMenuStatus = RezStrings.getAvailable(); } if (!mIsGlance) { buildMenu(data); @@ -268,6 +270,7 @@ class HomeAssistantApp extends Application.AppBase { } } else { mMenuStatus = RezStrings.getCached(); + WatchUi.requestUpdate(); if (!mIsGlance) { buildMenu(menu); } @@ -467,15 +470,15 @@ class HomeAssistantApp extends Application.AppBase { RezStrings.update_glance(); mApiStatus = RezStrings.getChecking(); mMenuStatus = RezStrings.getChecking(); - updateGlance(); + updateStatus(); Settings.update(); mTimer = new Timer.Timer(); - mTimer.start(method(:updateGlance), Globals.scApiBackoff, true); + mTimer.start(method(:updateStatus), Globals.scApiBackoff, true); return [new HomeAssistantGlanceView(self)]; } // Required for the Glance update timer. - function updateGlance() as Void { + function updateStatus() as Void { fetchMenuConfig(); fetchApiStatus(); } diff --git a/source/HomeAssistantView.mc b/source/HomeAssistantView.mc index 37a23f8..e4accd3 100644 --- a/source/HomeAssistantView.mc +++ b/source/HomeAssistantView.mc @@ -104,12 +104,12 @@ class HomeAssistantView extends WatchUi.Menu2 { // class HomeAssistantViewDelegate extends WatchUi.Menu2InputDelegate { private var mIsRootMenuView as Lang.Boolean = false; - private var mTimer as QuitTimer; + private var mTimer as QuitTimer; function initialize(isRootMenuView as Lang.Boolean) { Menu2InputDelegate.initialize(); mIsRootMenuView = isRootMenuView; - mTimer = getApp().getQuitTimer(); + mTimer = getApp().getQuitTimer(); } function onBack() { diff --git a/source/RootView.mc b/source/RootView.mc index 860a785..ac6b581 100644 --- a/source/RootView.mc +++ b/source/RootView.mc @@ -115,6 +115,10 @@ class RootView extends ScalableView { mMenuStatus.setText(mApp.getMenuStatus()); mMenuStatus.draw(dc); } + + function onShow() as Void { + WatchUi.requestUpdate(); + } } class RootViewDelegate extends WatchUi.BehaviorDelegate {