Skip to content

An open-source cross-platform alternative to AirDrop

fix: guard RefenaScope.defaultRef access in tray helper (#2927) (#2949)

ramyaramyarao11278-cmd22d41c88ffaf
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<void> 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<void> showFromTray() async {
@@ -86,7 +90,11 @@ Future<void> 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<void> destroyTray() async {