[O] Cache unread assignments

This commit is contained in:
Hykilpikonna
2019-12-21 18:39:47 -05:00
parent 4bc9113b96
commit 9b3a61e5cc
+5 -4
View File
@@ -53,7 +53,7 @@
import OverallLine from '@/pages/overall/overall-line/overall-line'; import OverallLine from '@/pages/overall/overall-line/overall-line';
import OverallBar from '@/pages/overall/overall-bar/overall-bar'; import OverallBar from '@/pages/overall/overall-bar/overall-bar';
import OverallCourse from '@/pages/overall/overall-course/overall-course'; import OverallCourse from '@/pages/overall/overall-course/overall-course';
import Course from '@/logic/course'; import Course, {Assignment} from '@/logic/course';
import {GPAUtils} from '@/logic/utils/gpa-utils'; import {GPAUtils} from '@/logic/utils/gpa-utils';
@Component({ @Component({
@@ -74,6 +74,8 @@
return GPAUtils.getGPA(this.courses); return GPAUtils.getGPA(this.courses);
} }
// For clear unread prompt
unread: Assignment[];
/** /**
* On page load - check if the user has too many notifications * On page load - check if the user has too many notifications
*/ */
@@ -83,11 +85,10 @@
if (!this.$cookies.isKey('IgnoreUnread')) if (!this.$cookies.isKey('IgnoreUnread'))
{ {
// Count unread // Count unread
let unread = this.courses.reduce((p, c) => p + this.unread = this.courses.flatMap(c => c.assignments.filter(a => a.unread));
c.assignments.reduce((p, a) => p + (a.unread ? 1 : 0), 0), 0);
// Prompt clear // Prompt clear
if (unread > 15) if (this.unread.length > 15)
{ {
this.promptClearNotification = true; this.promptClearNotification = true;
} }