From 4ea26dee47ecd0c3759d7eac0f767172b37bde57 Mon Sep 17 00:00:00 2001 From: Christian Pauly Date: Thu, 3 Feb 2022 07:44:50 +0100 Subject: [PATCH] feat: Open chat button from Linux notification --- assets/l10n/intl_en.arb | 2 +- lib/widgets/local_notifications_extension.dart | 10 ++++++---- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/assets/l10n/intl_en.arb b/assets/l10n/intl_en.arb index 2b024355..135fcfc4 100644 --- a/assets/l10n/intl_en.arb +++ b/assets/l10n/intl_en.arb @@ -2707,7 +2707,7 @@ "@storyPrivacyWarning": {}, "iUnderstand": "I understand", "@iUnderstand": {}, - "dismiss": "Dismiss", + "openChat": "Open Chat", "markAsRead": "Mark as read", "reportUser": "Report user" } diff --git a/lib/widgets/local_notifications_extension.dart b/lib/widgets/local_notifications_extension.dart index f71fab80..42c5ac33 100644 --- a/lib/widgets/local_notifications_extension.dart +++ b/lib/widgets/local_notifications_extension.dart @@ -8,6 +8,7 @@ import 'package:http/http.dart' as http; import 'package:matrix/matrix.dart'; import 'package:path_provider/path_provider.dart'; import 'package:universal_html/html.dart' as html; +import 'package:vrouter/vrouter.dart'; import 'package:fluffychat/config/app_config.dart'; import 'package:fluffychat/utils/matrix_sdk_extensions.dart/matrix_locals.dart'; @@ -75,8 +76,8 @@ extension LocalNotificationsExtension on MatrixState { appIcon: appIconFile?.path ?? '', actions: [ NotificationAction( - DesktopNotificationActions.dismiss.name, - L10n.of(widget.context)!.dismiss, + DesktopNotificationActions.openChat.name, + L10n.of(widget.context)!.openChat, ), NotificationAction( DesktopNotificationActions.seen.name, @@ -94,7 +95,8 @@ extension LocalNotificationsExtension on MatrixState { case DesktopNotificationActions.seen: room.setReadMarker(event.eventId, mRead: event.eventId); break; - case DesktopNotificationActions.dismiss: + case DesktopNotificationActions.openChat: + VRouter.of(navigatorContext).toSegments(['rooms', room.id]); break; } }); @@ -103,4 +105,4 @@ extension LocalNotificationsExtension on MatrixState { } } -enum DesktopNotificationActions { seen, dismiss } +enum DesktopNotificationActions { seen, openChat }