@@ -85,7 +85,7 @@ import CourseEditor from '@/components/Courses/CourseEditor.vue';
8585import CourseStubCard from ' @/components/Courses/CourseStubCard.vue' ;
8686import _ from ' lodash' ;
8787import serverRequest from ' ../server' ;
88- import { ServerRequestType , CourseConfig } from ' @vue-skuilder/common' ;
88+ import { ServerRequestType , CourseConfig , Status } from ' @vue-skuilder/common' ;
8989import { alertUser } from ' @vue-skuilder/common-ui' ;
9090import { UserDBInterface , getDataLayer } from ' @vue-skuilder/db' ;
9191import { getCurrentUser } from ' @/stores/useAuthStore' ;
@@ -176,28 +176,36 @@ export default defineComponent({
176176
177177 async refreshData(): Promise <void > {
178178 console .log (` Pulling user course data... ` );
179- const userCourseIDs = (await this .user ! .getCourseRegistrationsDoc ()).courses
180- .filter ((c ) => {
181- return c .status === ' active' || c .status === ' maintenance-mode' || c .status === undefined ;
182- })
183- .map ((c ) => {
184- return c .courseID ;
185- });
186- console .log (` userCourseIDs: ${userCourseIDs } ` );
179+ try {
180+ const userCourseIDs = (await this .user ! .getCourseRegistrationsDoc ()).courses
181+ .filter ((c ) => {
182+ return c .status === ' active' || c .status === ' maintenance-mode' || c .status === undefined ;
183+ })
184+ .map ((c ) => {
185+ return c .courseID ;
186+ });
187+ console .log (` userCourseIDs: ${userCourseIDs } ` );
187188
188- this .existingCourses = (await getDataLayer ().getCoursesDB ().getCourseList ()) as DBCourseConfig [];
189+ this .existingCourses = (await getDataLayer ().getCoursesDB ().getCourseList ()) as DBCourseConfig [];
190+ console .log (` existingCourses: \n\t ${this .existingCourses .map ((c ) => c .name ).join (' ,\n\t ' )} ` );
189191
190- this .registeredCourses = this .existingCourses .filter ((course ) => {
191- let match: boolean = false ;
192- userCourseIDs .forEach ((id : string ) => {
193- if (course .courseID === id ) {
194- match = true ;
195- }
192+ this .registeredCourses = this .existingCourses .filter ((course ) => {
193+ let match: boolean = false ;
194+ userCourseIDs .forEach ((id : string ) => {
195+ if (course .courseID === id ) {
196+ match = true ;
197+ }
198+ });
199+ return match ;
196200 });
197- return match ;
198- });
201+ } catch (e ) {
202+ console .error (` Error refreshing course data: ` , e );
203+ alertUser ({
204+ status: Status .error ,
205+ text: ` Failed to load courses: ${e .message || ' Database access error' } ` ,
206+ });
207+ }
199208 },
200-
201209 async createCourse(): Promise <void > {
202210 this .awaitingCreateCourse = true ;
203211 const resp = await serverRequest ({
0 commit comments