Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: chart click nav #97

Merged
merged 4 commits into from
Jul 5, 2023
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions src/js/components/Search/Search.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,12 @@ import { buildQueryParamsUrl } from '@/utils/search';

import type { QueryParams } from '@/types/search';

const checkQueryParamsEqual = (qp1: QueryParams, qp2: QueryParams): boolean =>
[...new Set(...Object.keys(qp1), ...Object.keys(qp2))].reduce((acc, v) => acc && qp1[v] === qp2[v], true);
const checkQueryParamsEqual = (qp1: QueryParams, qp2: QueryParams): boolean => {
const qp1Keys = Object.keys(qp1);
const qp2Keys = Object.keys(qp2);
const params = [...new Set([...qp1Keys, ...qp2Keys])];
return params.reduce((acc, v) => acc && qp1[v] === qp2[v], true);
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

return to original form to reduce diff? or is it better as not a one-liner...

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like one-liners, but in this case I think it is easier to read/debug this way


const RoutedSearch: React.FC = () => {
const dispatch = useAppDispatch();
Expand Down Expand Up @@ -61,6 +65,10 @@ const RoutedSearch: React.FC = () => {
const queryParam = new URLSearchParams(location.search);
const { valid, validQueryParamsObject } = validateQuery(queryParam);
if (valid) {
console.log({
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

change to a console.debug with some kind of info about whats being logged, or remove

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Forgot to remove, was only to debug

valid: validQueryParamsObject,
params: queryParams
});
if (!attemptedFetch || !checkQueryParamsEqual(validQueryParamsObject, queryParams)) {
// Only update the state & refresh if we have a new set of query params from the URL.
dispatch(setQueryParams(validQueryParamsObject));
Expand Down
4 changes: 3 additions & 1 deletion webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,9 @@ const config = {
inject: false,
}),
new CopyWebpackPlugin({
patterns: [{ from: 'src/public', to: 'public' }],
patterns: [
{ from: 'src/public', to: 'public' },
],
}),
],
optimization: {
Expand Down
Loading