feat(settings): allow disabling of auto-loading courses (#489)
This commit is contained in:
@@ -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<ScrapedRow[]>([]);
|
||||
const [selectedCourse, setSelectedCourse] = useState<Course | null>(null);
|
||||
const [showPopup, setShowPopup] = useState(false);
|
||||
const [enableScrollToLoad, setEnableScrollToLoad] = useState<boolean>(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)}
|
||||
/>
|
||||
<AutoLoad addRows={addRows} />
|
||||
{enableScrollToLoad && <AutoLoad addRows={addRows} />}
|
||||
</ExtensionRoot>
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user