feat: validate login passed to background and implemented into add all injected button (#443)

* docs: proper captializing

* docs: confirmed that the for loop is entered but on first startup something else

* feat: turns out - validate login status - not in background - pass background now

* feat: kronk.gif

* Update UserScheduleMessages.ts

* Update addCourseByURL.ts

* chore: format

* chore: chore

---------

Co-authored-by: doprz <52579214+doprz@users.noreply.github.com>
This commit is contained in:
2025-01-20 18:42:15 -06:00
committed by GitHub
parent f425510e11
commit cd05e5e7fc
4 changed files with 31 additions and 7 deletions

View File

@@ -23,7 +23,9 @@ export async function addCourseByURL(activeSchedule: UserSchedule, link?: string
if (!link) link = prompt('Enter course link') || undefined;
// Exit if the user cancels the prompt
if (!link) return;
if (!link) {
return;
}
try {
let htmlText: string;
@@ -46,17 +48,16 @@ export async function addCourseByURL(activeSchedule: UserSchedule, link?: string
const scrapedCourses = scraper.scrape(tableRows, false);
if (scrapedCourses.length !== 1) return;
const description = scraper.getDescription(doc);
const row = scrapedCourses[0]!;
const course = row.course!;
course.description = description;
if (activeSchedule.courses.every(c => c.uniqueId !== course.uniqueId)) {
console.log('adding course');
console.log('Adding course');
await addCourse(activeSchedule.id, course);
} else {
console.log('course already exists');
console.log('Course already exists');
}
} catch (error) {
console.error('Error scraping course:', error);