From ddfdb47b934f03d2ac469997a939b4794101dc3e Mon Sep 17 00:00:00 2001 From: Hykilpikonna Date: Sun, 20 Oct 2019 21:49:51 -0400 Subject: [PATCH] [+] Encapsulate findCourse --- src/components/navigation/navigation.ts | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/components/navigation/navigation.ts b/src/components/navigation/navigation.ts index ac70fc4..b52665b 100644 --- a/src/components/navigation/navigation.ts +++ b/src/components/navigation/navigation.ts @@ -107,9 +107,17 @@ export default class Navigation extends Vue */ public findNextCourse(indexOffset: number) { - // Find current course - let courseId = this.activeIndex.split('/')[1]; + return this.findCourse(this.activeIndex.split('/')[1], indexOffset); + } + /** + * Find course + * + * @param courseId Course ID + * @param indexOffset Index offset (Eg. 1 for next) + */ + public findCourse(courseId: string, indexOffset: number) + { // Find current course index let courseIndex = this.courses.findIndex(c => c.id == +courseId);