From b74c698866c1074ce2236ede549c94555667e6a5 Mon Sep 17 00:00:00 2001 From: Samuel Gunter <29130894+Samathingamajig@users.noreply.github.com> Date: Mon, 20 Jan 2025 23:04:14 -0600 Subject: [PATCH] feat(settings): allow disabling of auto-loading courses (#489) --- src/views/components/CourseCatalogMain.tsx | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/views/components/CourseCatalogMain.tsx b/src/views/components/CourseCatalogMain.tsx index fda10b7e..4654f4e9 100644 --- a/src/views/components/CourseCatalogMain.tsx +++ b/src/views/components/CourseCatalogMain.tsx @@ -1,3 +1,4 @@ +import { OptionsStore } from '@shared/storage/OptionsStore'; import type { Course, ScrapedRow } from '@shared/types/Course'; import ExtensionRoot from '@views/components/common/ExtensionRoot/ExtensionRoot'; import AutoLoad from '@views/components/injected/AutoLoad/AutoLoad'; @@ -25,6 +26,7 @@ export default function CourseCatalogMain({ support }: Props): JSX.Element | nul const [rows, setRows] = React.useState([]); const [selectedCourse, setSelectedCourse] = useState(null); const [showPopup, setShowPopup] = useState(false); + const [enableScrollToLoad, setEnableScrollToLoad] = useState(false); useEffect(() => { populateSearchInputs(); @@ -43,6 +45,10 @@ export default function CourseCatalogMain({ support }: Props): JSX.Element | nul setRows(scrapedRows); }, [support]); + useEffect(() => { + OptionsStore.get('enableScrollToLoad').then(setEnableScrollToLoad); + }, []); + const addRows = (newRows: ScrapedRow[]) => { newRows.forEach(row => { document.querySelector('table tbody')!.appendChild(row.element); @@ -83,7 +89,7 @@ export default function CourseCatalogMain({ support }: Props): JSX.Element | nul onClose={() => setShowPopup(false)} afterLeave={() => setSelectedCourse(null)} /> - + {enableScrollToLoad && } ); }