Skip to content

Commit

Permalink
Fix formatting + lint errors
Browse files Browse the repository at this point in the history
  • Loading branch information
js0mmer committed Feb 1, 2024
1 parent 9c3caaf commit b3cb733
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
20 changes: 10 additions & 10 deletions site/src/component/SearchModule/SearchModule.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,11 @@ const SearchModule: FC<SearchModuleProps> = ({ index }) => {
searchResults('professors', professorSearch.pageNumber, professorSearch.names);
}, [professorSearch.names, professorSearch.pageNumber]);

let searchNames = (query: string) => {
const searchNames = (query: string) => {
try {
// Get all results only when query changes or user reaches the fourth page or after
const currentPage = index === 'courses' ? courseSearch.pageNumber : professorSearch.pageNumber;
let nameResults = wfs({
const nameResults = wfs({
query: query,
resultType: index === 'courses' ? 'COURSE' : 'INSTRUCTOR',
// Load INITIAL_MAX_PAGE pages first
Expand Down Expand Up @@ -80,31 +80,31 @@ const SearchModule: FC<SearchModuleProps> = ({ index }) => {
}
};

let searchResults = async (index: SearchIndex, pageNumber: number, names: string[]) => {
const searchResults = async (index: SearchIndex, pageNumber: number, names: string[]) => {
if (!hasFullResults && pageNumber >= FULL_RESULT_THRESHOLD) {
setHasFullResults(true);
searchNames(lastQuery);
}
// Get the subset of names based on the page
let pageNames = names.slice(NUM_RESULTS_PER_PAGE * pageNumber, NUM_RESULTS_PER_PAGE * (pageNumber + 1));
let results = await searchAPIResults(index, pageNames);
const pageNames = names.slice(NUM_RESULTS_PER_PAGE * pageNumber, NUM_RESULTS_PER_PAGE * (pageNumber + 1));
const results = await searchAPIResults(index, pageNames);
dispatch(setResults({ index, results: Object.values(results) }));
};

let searchNamesAfterTimeout = (query: string) => {
const searchNamesAfterTimeout = (query: string) => {
if (pendingRequest) {
clearTimeout(pendingRequest);
}
let timeout = setTimeout(() => {
const timeout = setTimeout(() => {
searchNames(query);
pendingRequest = null;
}, SEARCH_TIMEOUT_MS);
pendingRequest = timeout;
};

let coursePlaceholder = 'Search a course number or department';
let professorPlaceholder = 'Search a professor';
let placeholder = index === 'courses' ? coursePlaceholder : professorPlaceholder;
const coursePlaceholder = 'Search a course number or department';
const professorPlaceholder = 'Search a professor';
const placeholder = index === 'courses' ? coursePlaceholder : professorPlaceholder;

return (
<div className="search-module">
Expand Down
2 changes: 1 addition & 1 deletion site/src/helpers/constants.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// SearchPage
// Defined in the constants file because it is used in both
// SearchModule (the search bar) and SearchPagination (the pagination buttons)
export const NUM_RESULTS_PER_PAGE = 10;
export const NUM_RESULTS_PER_PAGE = 10;

0 comments on commit b3cb733

Please sign in to comment.