formating, and moving active=true up to be better
continuous-integration/drone/pr Build is passing Details

This commit is contained in:
Dan Ballard 2022-02-03 13:58:51 -08:00
parent 715b2c6876
commit 19a202a04c
1 changed files with 6 additions and 17 deletions

View File

@ -31,12 +31,7 @@ class LinuxNotificationsManager implements NotificationsManager {
Future<void> notify(String message) async { Future<void> notify(String message) async {
var iconPath = Uri.file(path.join(path.current, "cwtch.png")); var iconPath = Uri.file(path.join(path.current, "cwtch.png"));
client client.notify(message, appName: "cwtch", appIcon: iconPath.toString(), replacesId: this.previous_id).then((Notification value) => previous_id = value.id);
.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() { WindowsNotificationManager() {
scheduleMicrotask(() async { scheduleMicrotask(() async {
initialized = await WinToast.instance().initialize( initialized = await WinToast.instance().initialize(appName: 'cwtch', productName: 'Cwtch', companyName: 'Open Privacy Research Society');
appName: 'cwtch',
productName: 'Cwtch',
companyName: 'Open Privacy Research Society');
}); });
} }
Future<void> notify(String message) async { Future<void> notify(String message) async {
if (initialized && !globalAppState.focus) { if (initialized && !globalAppState.focus) {
if (!active) { if (!active) {
WinToast.instance().clear();
final toast = await WinToast.instance()
.showToast(type: ToastType.text01, title: message);
active = true; active = true;
WinToast.instance().clear();
final toast = await WinToast.instance().showToast(type: ToastType.text01, title: message);
toast?.eventStream.listen((event) { toast?.eventStream.listen((event) {
if (event is ActivatedEvent) { if (event is ActivatedEvent) {
WinToast.instance().bringWindowToFront(); WinToast.instance().bringWindowToFront();
@ -82,15 +73,13 @@ NotificationsManager newDesktopNotificationsManager() {
client.getCapabilities(); client.getCapabilities();
return LinuxNotificationsManager(client); return LinuxNotificationsManager(client);
} catch (e) { } catch (e) {
EnvironmentConfig.debugLog( EnvironmentConfig.debugLog("Attempted to access DBUS for notifications but failed. Switching off notifications.");
"Attempted to access DBUS for notifications but failed. Switching off notifications.");
} }
} else if (Platform.isWindows) { } else if (Platform.isWindows) {
try { try {
return WindowsNotificationManager(); return WindowsNotificationManager();
} catch (e) { } catch (e) {
EnvironmentConfig.debugLog( EnvironmentConfig.debugLog("Failed to create Windows desktoasts notification manager");
"Failed to create Windows desktoasts notification manager");
} }
} }
return NullNotificationsManager(); return NullNotificationsManager();