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:
@@ -1,4 +1,6 @@
|
||||
import { addCourseByURL } from '@pages/background/lib/addCourseByURL';
|
||||
import { background } from '@shared/messages';
|
||||
import { validateLoginStatus } from '@shared/util/checkLoginStatus';
|
||||
import { Button } from '@views/components/common/Button';
|
||||
import ExtensionRoot from '@views/components/common/ExtensionRoot/ExtensionRoot';
|
||||
import useSchedules from '@views/hooks/useSchedules';
|
||||
@@ -30,9 +32,18 @@ export default function InjectedButton(): JSX.Element | null {
|
||||
// Make sure to remove duplicate anchorTags using set
|
||||
const uniqueAnchorTags = Array.from(new Set(anchorTags.map(a => a.href)));
|
||||
|
||||
for (const a of uniqueAnchorTags) {
|
||||
// eslint-disable-next-line no-await-in-loop
|
||||
await addCourseByURL(activeSchedule, a);
|
||||
// Make sure user is logged in
|
||||
const loggedInToUT = await background.validateLoginStatus({
|
||||
url: 'https://utdirect.utexas.edu/apps/registrar/course_schedule/utrp_login/',
|
||||
});
|
||||
|
||||
if (loggedInToUT) {
|
||||
for (const a of uniqueAnchorTags) {
|
||||
// eslint-disable-next-line no-await-in-loop
|
||||
await addCourseByURL(activeSchedule, a);
|
||||
}
|
||||
} else {
|
||||
window.alert('Logged into UT Registrar.');
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user