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 {
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<void> 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();