From 19a202a04c576a19a96961c06c8dc280c9cf5cd8 Mon Sep 17 00:00:00 2001 From: Dan Ballard Date: Thu, 3 Feb 2022 13:58:51 -0800 Subject: [PATCH] formating, and moving active=true up to be better --- lib/notification_manager.dart | 23 ++++++----------------- 1 file changed, 6 insertions(+), 17 deletions(-) diff --git a/lib/notification_manager.dart b/lib/notification_manager.dart index 68f56f3e..91d6ada8 100644 --- a/lib/notification_manager.dart +++ b/lib/notification_manager.dart @@ -31,12 +31,7 @@ class LinuxNotificationsManager implements NotificationsManager { Future notify(String message) async { var iconPath = Uri.file(path.join(path.current, "cwtch.png")); - client - .notify(message, - appName: "cwtch", - appIcon: iconPath.toString(), - replacesId: this.previous_id) - .then((Notification value) => previous_id = value.id); + client.notify(message, appName: "cwtch", appIcon: iconPath.toString(), replacesId: this.previous_id).then((Notification value) => previous_id = value.id); } } @@ -48,20 +43,16 @@ class WindowsNotificationManager implements NotificationsManager { WindowsNotificationManager() { scheduleMicrotask(() async { - initialized = await WinToast.instance().initialize( - appName: 'cwtch', - productName: 'Cwtch', - companyName: 'Open Privacy Research Society'); + initialized = await WinToast.instance().initialize(appName: 'cwtch', productName: 'Cwtch', companyName: 'Open Privacy Research Society'); }); } Future notify(String message) async { if (initialized && !globalAppState.focus) { if (!active) { - WinToast.instance().clear(); - final toast = await WinToast.instance() - .showToast(type: ToastType.text01, title: message); active = true; + WinToast.instance().clear(); + final toast = await WinToast.instance().showToast(type: ToastType.text01, title: message); toast?.eventStream.listen((event) { if (event is ActivatedEvent) { WinToast.instance().bringWindowToFront(); @@ -82,15 +73,13 @@ NotificationsManager newDesktopNotificationsManager() { client.getCapabilities(); return LinuxNotificationsManager(client); } catch (e) { - EnvironmentConfig.debugLog( - "Attempted to access DBUS for notifications but failed. Switching off notifications."); + EnvironmentConfig.debugLog("Attempted to access DBUS for notifications but failed. Switching off notifications."); } } else if (Platform.isWindows) { try { return WindowsNotificationManager(); } catch (e) { - EnvironmentConfig.debugLog( - "Failed to create Windows desktoasts notification manager"); + EnvironmentConfig.debugLog("Failed to create Windows desktoasts notification manager"); } } return NullNotificationsManager();