Skip to content

Commit

Permalink
try to make typing experience better
Browse files Browse the repository at this point in the history
  • Loading branch information
trinity-1686a committed May 11, 2024
1 parent a609282 commit 613a245
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 11 deletions.
28 changes: 18 additions & 10 deletions quickwit/quickwit-ui/src/components/SearchResult/SearchResult.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.

import { useMemo } from 'react';
import { Box, Typography } from "@mui/material";
import NumberFormat from "react-number-format";
import { Index, ResponseError, SearchResponse } from "../../utils/models";
Expand Down Expand Up @@ -64,16 +65,23 @@ export default function SearchResult(props: SearchResultProps) {
if (props.searchResponse == null || props.index == null) {
return <></>
}
let result;
console.log(props.searchResponse);
if (props.searchResponse.aggregations === undefined) {
console.log("result table");
result = (<ResultTable searchResponse={props.searchResponse} index={props.index} />);
} else {
console.log("aggregation result");
result = (<AggregationResult searchResponse={props.searchResponse} />);
}
(<ResultTable searchResponse={props.searchResponse} index={props.index} />);
// try to improve typing experience by caching the costly-to-render components
// in practice this doesn't seem to have much impact
const result = useMemo(
() => {
if (props.searchResponse == null || props.index == null) {
return null;
} else if (props.searchResponse.aggregations === undefined) {
console.log("result table");
return (<ResultTable searchResponse={props.searchResponse} index={props.index} />);
} else {
console.log("aggregation result");
return (<AggregationResult searchResponse={props.searchResponse} />);
}
},
[props.searchResponse, props.index]
);

return (
<Box sx={{ pt: 1, flexGrow: '1', flexBasis: '0%', overflow: 'hidden'}} >
<Box sx={{ height: '100%', flexDirection: 'column', flexGrow: 1, display: 'flex'}}>
Expand Down
1 change: 0 additions & 1 deletion quickwit/quickwit-ui/src/views/SearchView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,6 @@ function SearchView() {
});
}
const onSearchRequestUpdate = (searchRequest: SearchRequest) => {
console.log("on search request update:", searchRequest);
setSearchRequest(searchRequest);
}
useEffect(() => {
Expand Down

0 comments on commit 613a245

Please sign in to comment.