From fe03554fbf50881cf475c28ddb516d1f6fa151d0 Mon Sep 17 00:00:00 2001 From: hihihaha Date: Sat, 10 Jun 2023 21:19:49 +0200 Subject: [PATCH] backend changes --- filcnaplo/lib/helpers/notification_helper.dart | 3 ++- filcnaplo/lib/ui/filter/widgets.dart | 1 + filcnaplo_kreta_api/lib/providers/grade_provider.dart | 1 - .../lib/screens/settings/settings_screen.dart | 6 +----- 4 files changed, 4 insertions(+), 7 deletions(-) diff --git a/filcnaplo/lib/helpers/notification_helper.dart b/filcnaplo/lib/helpers/notification_helper.dart index ec7ae41..c1cfcb6 100644 --- a/filcnaplo/lib/helpers/notification_helper.dart +++ b/filcnaplo/lib/helpers/notification_helper.dart @@ -44,7 +44,8 @@ class NotificationsHelper { // loop through grades and see which hasn't been seen yet for (Grade grade in grades) { - if (grade.seenDate.isAfter(lastSeenGrade)) { + // if the grade was added over a week ago, don't show it to avoid notification spam + if (grade.seenDate.isAfter(lastSeenGrade) && grade.date.difference(DateTime.now()).inDays * -1 < 7) { // send notificiation about new grade const AndroidNotificationDetails androidNotificationDetails = AndroidNotificationDetails('GRADES', 'Jegyek', diff --git a/filcnaplo/lib/ui/filter/widgets.dart b/filcnaplo/lib/ui/filter/widgets.dart index 9632adf..bce82ae 100644 --- a/filcnaplo/lib/ui/filter/widgets.dart +++ b/filcnaplo/lib/ui/filter/widgets.dart @@ -89,6 +89,7 @@ Future> getFilterWidgets(FilterType activeData, // Grades case FilterType.grades: + gradeProvider.seenAll(); items = grade_filter.getWidgets( gradeProvider.grades, gradeProvider.lastSeenDate); if (settingsProvider.gradeOpeningFun) { diff --git a/filcnaplo_kreta_api/lib/providers/grade_provider.dart b/filcnaplo_kreta_api/lib/providers/grade_provider.dart index cc8e6ee..68d8db9 100644 --- a/filcnaplo_kreta_api/lib/providers/grade_provider.dart +++ b/filcnaplo_kreta_api/lib/providers/grade_provider.dart @@ -51,7 +51,6 @@ class GradeProvider with ChangeNotifier { final userStore = _database.userStore; userStore.storeLastSeenGrade(DateTime.now(), userId: userId); _lastSeen = DateTime.now(); - notifyListeners(); } } diff --git a/filcnaplo_mobile_ui/lib/screens/settings/settings_screen.dart b/filcnaplo_mobile_ui/lib/screens/settings/settings_screen.dart index 082c316..1aebdf0 100755 --- a/filcnaplo_mobile_ui/lib/screens/settings/settings_screen.dart +++ b/filcnaplo_mobile_ui/lib/screens/settings/settings_screen.dart @@ -444,11 +444,7 @@ class _SettingsScreenState extends State borderRadius: BorderRadius.circular(12.0)), title: Row(children: [ Icon(FeatherIcons.messageSquare, - color: Theme.of(context) - .colorScheme - .secondary - .withOpacity( - settings.notificationsEnabled ? 1 : .25)), + color: settings.notificationsEnabled ? Theme.of(context).colorScheme.secondary : AppColors.of(context).text.withOpacity(.25)), const SizedBox(width: 14.0), Text( "notifications".i18n,