From 22d41c88ffaf6f5d05bcf132c0233a53178029eb Mon Sep 17 00:00:00 2001 From: ramyaramyarao11278-cmd Date: Sun, 22 Feb 2026 23:19:37 +0800 Subject: [PATCH] fix: guard RefenaScope.defaultRef access in tray helper (#2927) (#2949) Co-authored-by: ramyaramyarao11278-cmd --- app/lib/util/native/tray_helper.dart | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/app/lib/util/native/tray_helper.dart b/app/lib/util/native/tray_helper.dart index 255ba10b..43b8860c 100644 --- a/app/lib/util/native/tray_helper.dart +++ b/app/lib/util/native/tray_helper.dart @@ -72,7 +72,11 @@ Future hideToTray() async { } // Disable animations - RefenaScope.defaultRef.notifier(sleepProvider).setState((_) => true); + try { + RefenaScope.defaultRef.notifier(sleepProvider).setState((_) => true); + } catch (e) { + _logger.warning('Failed to update sleep state (Refena not yet initialized)', e); + } } Future showFromTray() async { @@ -86,7 +90,11 @@ Future showFromTray() async { } // Enable animations - RefenaScope.defaultRef.notifier(sleepProvider).setState((_) => false); + try { + RefenaScope.defaultRef.notifier(sleepProvider).setState((_) => false); + } catch (e) { + _logger.warning('Failed to update sleep state (Refena not yet initialized)', e); + } } Future destroyTray() async {