[O] Optimize count unread for overall-course

This commit is contained in:
Hykilpikonna
2019-12-21 18:54:50 -05:00
parent e8aeecb27c
commit aeadb6fc8b
@@ -11,20 +11,14 @@ export default class OverallCourse extends Vue
{ {
@Prop({required: true}) course: Course; @Prop({required: true}) course: Course;
private unread: number = -1; get unreadAssignments(): Assignment[]
private unreadAssignments: Assignment[] = [];
/**
* Count the number of unread assignments with cache
*/
countUnread(): number
{ {
if (this.unread == -1) return this.course.assignments.filter(a => a.unread);
{ }
this.unreadAssignments = this.course.assignments.filter(a => a.unread);
return this.unread = this.unreadAssignments.length; get unread(): number
} {
else return this.unread; return this.unreadAssignments.length;
} }
/** /**