From 4047a3e8f670a3920154dcbb4a8bb8d4fba32d4c Mon Sep 17 00:00:00 2001 From: Hykilpikonna Date: Sat, 21 Dec 2019 18:25:43 -0500 Subject: [PATCH] [+] Detect notification count --- src/pages/overall/overall.vue | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/src/pages/overall/overall.vue b/src/pages/overall/overall.vue index e4de948..da6a1bc 100644 --- a/src/pages/overall/overall.vue +++ b/src/pages/overall/overall.vue @@ -65,14 +65,36 @@ { @Prop({required: true}) courses: Course[]; + promptClearNotification = false; + /** * This function is called to get gpa since I can't import another * class in the Vue file. */ - public getGPA() + getGPA() { return GPAUtils.getGPA(this.courses); } + + /** + * On page load - check if the user has too many notifications + */ + mounted() + { + // Check unread + if (!this.$cookies.isKey('IgnoreUnread')) + { + // Count unread + let unread = this.courses.reduce((p, c) => p + + c.assignments.reduce((p, a) => p + (a.unread ? 1 : 0), 0), 0); + + // Prompt clear + if (unread > 15) + { + this.promptClearNotification = true; + } + } + } }