From 41a5f7c53945b360b36f98f8abd38f463c3066cf Mon Sep 17 00:00:00 2001 From: Kima Date: Mon, 12 Feb 2024 19:38:11 +0100 Subject: [PATCH] MAYBE fixed notification spam --- filcnaplo/lib/helpers/notification_helper.dart | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/filcnaplo/lib/helpers/notification_helper.dart b/filcnaplo/lib/helpers/notification_helper.dart index 6f6f9a4..da18960 100644 --- a/filcnaplo/lib/helpers/notification_helper.dart +++ b/filcnaplo/lib/helpers/notification_helper.dart @@ -99,8 +99,13 @@ class NotificationsHelper { // if grade is not a normal grade (1-5), don't show it if ([1, 2, 3, 4, 5].contains(grade.value.value)) { // if the grade was added over a week ago, don't show it to avoid notification spam + // it worked in reverse, cuz someone added a * -1 to it, but it has been fixed now :D + // old code below + // if (grade.seenDate.isAfter(lastSeenGrade) && + // grade.date.difference(DateTime.now()).inDays * -1 < 7) { + // new code from here :P if (grade.seenDate.isAfter(lastSeenGrade) && - grade.date.difference(DateTime.now()).inDays * -1 < 7) { + grade.date.difference(DateTime.now()).inDays < 7) { // send notificiation about new grade AndroidNotificationDetails androidNotificationDetails = AndroidNotificationDetails( @@ -195,7 +200,8 @@ class NotificationsHelper { if (userProvider.getUsers().length == 1) { await flutterLocalNotificationsPlugin.show( absence.id.hashCode, - "title_absence".i18n, // https://discord.com/channels/1111649116020285532/1153273625206591528 + "title_absence" + .i18n, // https://discord.com/channels/1111649116020285532/1153273625206591528 "body_absence".i18n.fill( [ DateFormat("yyyy-MM-dd").format(absence.date), @@ -210,7 +216,8 @@ class NotificationsHelper { } else { await flutterLocalNotificationsPlugin.show( absence.id.hashCode, - "title_absence".i18n, // https://discord.com/channels/1111649116020285532/1153273625206591528 + "title_absence" + .i18n, // https://discord.com/channels/1111649116020285532/1153273625206591528 "body_absence_multiuser".i18n.fill( [ userProvider.displayName!,