From 6fae306465fe24e54ee08b8997df22833b436be7 Mon Sep 17 00:00:00 2001 From: Philip Abbey Date: Tue, 27 Jan 2026 19:39:12 +0000 Subject: [PATCH] Update HomeAssistantApp.mc Fixed determination of cached menu when the Glance view cannot cache it, now we know it sometimes has insufficient memory. --- source/HomeAssistantApp.mc | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/source/HomeAssistantApp.mc b/source/HomeAssistantApp.mc index e6383b3..1be312c 100644 --- a/source/HomeAssistantApp.mc +++ b/source/HomeAssistantApp.mc @@ -208,16 +208,17 @@ class HomeAssistantApp extends Application.AppBase { if (data == null) { mMenuStatus = WatchUi.loadResource($.Rez.Strings.Unavailable) as Lang.String; } else { - if (Settings.getCacheConfig()) { + if (hasCachedMenu()) { + mMenuStatus = WatchUi.loadResource($.Rez.Strings.Cached) as Lang.String; + } else if (mIsApp) { // var stats = System.getSystemStats(); // stats.* values in bytes // System.println("HomeAssistantApp onReturnFetchMenuConfig() Memory: total=" + stats.totalMemory + ", used=" + stats.usedMemory + ", free=" + stats.freeMemory); - if (mIsApp) { - // This call can crash a glance with "Error: Out Of Memory Error" - // https://forums.garmin.com/developer/connect-iq/i/bug-reports/storage-setvalue-should-handle-memory-limits-gracefully - // "Keys and values are limited to 8 KB each, and a total of 128 KB of storage is available." - // "Storage.setValue() fails with an uncatchable out-of-memory error." - Storage.setValue(scStorageKeyMenu, data as Lang.Dictionary); - } + + // This call can crash a glance with "Error: Out Of Memory Error" + // https://forums.garmin.com/developer/connect-iq/i/bug-reports/storage-setvalue-should-handle-memory-limits-gracefully + // "Keys and values are limited to 8 KB each, and a total of 128 KB of storage is available." + // "Storage.setValue() fails with an uncatchable out-of-memory error." + Storage.setValue(scStorageKeyMenu, data as Lang.Dictionary); mMenuStatus = WatchUi.loadResource($.Rez.Strings.Cached) as Lang.String; } else { mMenuStatus = WatchUi.loadResource($.Rez.Strings.Available) as Lang.String;