From 30030a0ca5b8fe3de8c1d26653790a5027e9c32e Mon Sep 17 00:00:00 2001 From: Hykilpikonna Date: Sat, 21 Dec 2019 19:38:28 -0500 Subject: [PATCH] [+] Encapsulate markAsRead() --- src/logic/course.ts | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/src/logic/course.ts b/src/logic/course.ts index b9c559f..045235c 100644 --- a/src/logic/course.ts +++ b/src/logic/course.ts @@ -5,6 +5,7 @@ import {GPAUtils} from '@/logic/utils/gpa-utils'; import CacheUtils from '@/logic/utils/cache-utils'; import Constants from '@/constants'; import {Index} from '@/logic/nav-controller'; +import App from '@/components/app/app'; /** * Objects of this interface represent assignment grades. @@ -60,6 +61,27 @@ export class Assignment { return this.complete == 'Complete'; } + + /** + * Mark as read + */ + markAsRead(): Promise + { + return new Promise((resolve, reject) => { + App.http.post('/mark-as-read', {scoreId: this.scoreId}) + .then(response => + { + // Check success + if (response.success) + { + this.unread = false; + resolve(); + } + else reject(response.data); + }) + .catch(reject) + }) + } } export interface AssignmentType