From a73ae345afe8f6883d778b422ee1643137dad903 Mon Sep 17 00:00:00 2001 From: Joy <29514446+fillwithjoy1@users.noreply.github.com> Date: Wed, 24 Jan 2024 12:34:12 +0530 Subject: [PATCH 1/2] Update notification_manager.dart --- noterly/lib/managers/notification_manager.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/noterly/lib/managers/notification_manager.dart b/noterly/lib/managers/notification_manager.dart index 8eb95cc..8457195 100644 --- a/noterly/lib/managers/notification_manager.dart +++ b/noterly/lib/managers/notification_manager.dart @@ -323,7 +323,7 @@ class NotificationManager { item.isImmediate ? 'Immediate notifications' : 'Scheduled notifications', channelDescription: item.isImmediate ? 'Notifications that are shown immediately' : 'Notifications that are scheduled for a future time', actions: [ - const AndroidNotificationAction('done', 'Mark as done'), + const AndroidNotificationAction('done', 'Done'), const AndroidNotificationAction('snooze', 'Snooze'), ], category: AndroidNotificationCategory.reminder, From 288eb0858945ee063deceabe3cb39375cea5f1f0 Mon Sep 17 00:00:00 2001 From: Joy <29514446+fillwithjoy1@users.noreply.github.com> Date: Wed, 24 Jan 2024 12:47:30 +0530 Subject: [PATCH 2/2] Update notification_manager.dart --- .../lib/managers/notification_manager.dart | 20 +++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/noterly/lib/managers/notification_manager.dart b/noterly/lib/managers/notification_manager.dart index 8457195..74c584e 100644 --- a/noterly/lib/managers/notification_manager.dart +++ b/noterly/lib/managers/notification_manager.dart @@ -91,8 +91,8 @@ class NotificationManager { await NotificationManager.instance.updateRepeatingNotification(item); await FirebaseAnalytics.instance.logEvent(name: 'mark_repeating_notification_done'); } else { - Log.logger.d('Archiving notification "${item.title}"'); - await AppManager.instance.archiveItem(item.id, deferNotificationManagerCall: true); + Log.logger.d('Deleting notification "${item.title}"'); + await AppManager.instance.deleteItem(item.id, deferNotificationManagerCall: true); await FirebaseAnalytics.instance.logEvent(name: 'mark_notification_done'); } @@ -151,6 +151,21 @@ class NotificationManager { } } + if (response.actionId === 'archive') { + Log.logger.d('Archiving notification "${item.title}"'); + await AppManager.instance.archiveItem(item.id, deferNotificationManagerCall: true); + + // just stole this code, hopefully nothing breaks 💀💀💀💀 + // If we're in the background, we need to send a message to the main isolate to update the UI + if (isBackground) { + var sendPort = IsolateNameServer.lookupPortByName(IsolateManager.mainPortName); + sendPort?.send('update'); + if (sendPort == null) { + Log.logger.w('Failed to send message to main isolate (port not found).'); + } + } + } + static Future onResponse(NotificationResponse response) async => handleResponse(response, isBackground: false); @pragma('vm:entry-point') @@ -324,6 +339,7 @@ class NotificationManager { channelDescription: item.isImmediate ? 'Notifications that are shown immediately' : 'Notifications that are scheduled for a future time', actions: [ const AndroidNotificationAction('done', 'Done'), + const AndroidNotificationAction('archive', 'Archive'), const AndroidNotificationAction('snooze', 'Snooze'), ], category: AndroidNotificationCategory.reminder,