forked from firka/student-legacy
only show normal grade notifications
This commit is contained in:
parent
ee2a42bbe2
commit
8ff4f0b88f
@ -42,31 +42,34 @@ class NotificationsHelper {
|
|||||||
|
|
||||||
// loop through grades and see which hasn't been seen yet
|
// loop through grades and see which hasn't been seen yet
|
||||||
for (Grade grade in grades) {
|
for (Grade grade in grades) {
|
||||||
// if the grade was added over a week ago, don't show it to avoid notification spam
|
// if grade is not a normal grade (1-5), don't show it
|
||||||
if (grade.seenDate.isAfter(lastSeenGrade) &&
|
if ([1, 2, 3, 4, 5].contains(grade.value.value)) {
|
||||||
grade.date.difference(DateTime.now()).inDays * -1 < 7) {
|
// if the grade was added over a week ago, don't show it to avoid notification spam
|
||||||
// send notificiation about new grade
|
if (grade.seenDate.isAfter(lastSeenGrade) &&
|
||||||
const AndroidNotificationDetails androidNotificationDetails =
|
grade.date.difference(DateTime.now()).inDays * -1 < 7) {
|
||||||
AndroidNotificationDetails('GRADES', 'Jegyek',
|
// send notificiation about new grade
|
||||||
channelDescription: 'Értesítés jegyek beírásakor',
|
const AndroidNotificationDetails androidNotificationDetails =
|
||||||
importance: Importance.max,
|
AndroidNotificationDetails('GRADES', 'Jegyek',
|
||||||
priority: Priority.max,
|
channelDescription: 'Értesítés jegyek beírásakor',
|
||||||
color: Color(0xFF3D7BF4),
|
importance: Importance.max,
|
||||||
ticker: 'Jegyek');
|
priority: Priority.max,
|
||||||
const NotificationDetails notificationDetails =
|
color: Color(0xFF3D7BF4),
|
||||||
NotificationDetails(android: androidNotificationDetails);
|
ticker: 'Jegyek');
|
||||||
await flutterLocalNotificationsPlugin.show(
|
const NotificationDetails notificationDetails =
|
||||||
// probably shouldn't use a random int
|
NotificationDetails(android: androidNotificationDetails);
|
||||||
Random().nextInt(432234 * 2),
|
await flutterLocalNotificationsPlugin.show(
|
||||||
"title".i18n,
|
// probably shouldn't use a random int
|
||||||
"body".i18n.fill([
|
Random().nextInt(432234 * 2),
|
||||||
grade.value.value.toString(),
|
"title".i18n,
|
||||||
grade.subject.isRenamed &&
|
"body".i18n.fill([
|
||||||
settingsProvider.renamedSubjectsEnabled
|
grade.value.value.toString(),
|
||||||
? grade.subject.renamedTo!
|
grade.subject.isRenamed &&
|
||||||
: grade.subject.name
|
settingsProvider.renamedSubjectsEnabled
|
||||||
]),
|
? grade.subject.renamedTo!
|
||||||
notificationDetails);
|
: grade.subject.name
|
||||||
|
]),
|
||||||
|
notificationDetails);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// set grade seen status
|
// set grade seen status
|
||||||
|
@ -101,7 +101,16 @@ class GradeValue {
|
|||||||
case "rossz":
|
case "rossz":
|
||||||
return 2;
|
return 2;
|
||||||
case "hanyag":
|
case "hanyag":
|
||||||
|
return 1;
|
||||||
|
// other
|
||||||
|
case "jeles":
|
||||||
|
return 5;
|
||||||
|
case "kozepes":
|
||||||
|
return 3;
|
||||||
|
case "elegseges":
|
||||||
return 2;
|
return 2;
|
||||||
|
case "elegtelen":
|
||||||
|
return 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return _value;
|
return _value;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user