From e9438abae06d73dfa12b65b47f2f28562b7e1722 Mon Sep 17 00:00:00 2001 From: problematicconsumer Date: Sat, 9 Dec 2023 23:37:25 +0330 Subject: [PATCH] Fix tray initialization bug --- lib/features/system_tray/system_tray_controller.dart | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/lib/features/system_tray/system_tray_controller.dart b/lib/features/system_tray/system_tray_controller.dart index 589f834e..f2b1bc59 100644 --- a/lib/features/system_tray/system_tray_controller.dart +++ b/lib/features/system_tray/system_tray_controller.dart @@ -32,10 +32,14 @@ class SystemTrayController extends _$SystemTrayController _initialized = true; } - final connection = switch (ref.watch(connectionNotifierProvider)) { - AsyncData(:final value) => value, - _ => const Disconnected(), - }; + ConnectionStatus connection; + try { + connection = await ref.watch(connectionNotifierProvider.future); + } catch (e) { + loggy.warning("error getting connection status", e); + connection = const ConnectionStatus.disconnected(); + } + final serviceMode = await ref .watch(configOptionNotifierProvider.future) .then((value) => value.serviceMode);