[O] Optimize count unread for overall-course
This commit is contained in:
@@ -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;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user