[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;
private unread: number = -1;
private unreadAssignments: Assignment[] = [];
/**
* Count the number of unread assignments with cache
*/
countUnread(): number
get unreadAssignments(): Assignment[]
{
if (this.unread == -1)
{
this.unreadAssignments = this.course.assignments.filter(a => a.unread);
return this.unread = this.unreadAssignments.length;
}
else return this.unread;
return this.course.assignments.filter(a => a.unread);
}
get unread(): number
{
return this.unreadAssignments.length;
}
/**