From fec0d2c0470ecc0cea62e3d05f674f162dfe5cc1 Mon Sep 17 00:00:00 2001 From: krille-chan Date: Thu, 3 Oct 2024 17:33:44 +0200 Subject: [PATCH] feat: Add notification actions --- lib/utils/notification_background_handler.dart | 13 +++++++++++++ lib/utils/push_helper.dart | 4 +--- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/lib/utils/notification_background_handler.dart b/lib/utils/notification_background_handler.dart index 08fbba926..a7d45fad5 100644 --- a/lib/utils/notification_background_handler.dart +++ b/lib/utils/notification_background_handler.dart @@ -10,11 +10,20 @@ import 'package:fluffychat/utils/client_manager.dart'; void notificationTapBackground( NotificationResponse notificationResponse, ) async { + Logs().i('Notification tap in background'); final client = (await ClientManager.getClients( initialize: false, store: await SharedPreferences.getInstance(), )) .first; + await client.abortSync(); + await client.init( + waitForFirstSync: false, + waitUntilLoadCompletedLoaded: false, + ); + if (!client.isLogged()) { + throw Exception('Notification tab in background but not logged in!'); + } notificationTap(notificationResponse, client: client); } @@ -23,6 +32,10 @@ void notificationTap( GoRouter? router, required Client client, }) async { + Logs().d( + 'Notification action handler started', + notificationResponse.notificationResponseType.name, + ); switch (notificationResponse.notificationResponseType) { case NotificationResponseType.selectedNotification: final roomId = notificationResponse.payload; diff --git a/lib/utils/push_helper.dart b/lib/utils/push_helper.dart index 9cbc4aa67..1a0ec9f2e 100644 --- a/lib/utils/push_helper.dart +++ b/lib/utils/push_helper.dart @@ -283,9 +283,7 @@ Future _tryPushHelper( AndroidNotificationAction( FluffyChatNotificationActions.reply.name, l10n.reply, - inputs: [ - const AndroidNotificationActionInput(), - ], + inputs: [const AndroidNotificationActionInput()], ), ], );