-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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 filtered INDEX view not loading #7501
Conversation
const setUnsavedViewFilter = useSetRecoilComponentFamilyStateV2( | ||
unsavedToUpsertViewFiltersComponentFamilyState, | ||
{ viewId: viewIdQueryParam }, | ||
{ viewId: viewIdQueryParam ?? currentViewId }, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
also, viewIdQueryParam is not always defined. If viewId is in the URL, we use this view as our support, if not we will take the key=INDEX view
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
PR Summary
This pull request addresses an issue with filtered INDEX views not loading correctly in the Twenty application. The main changes focus on the QueryParamsFiltersEffect component, resolving an infinite loop problem and simplifying the component's logic.
Key points:
- Removed dependency on useGetCurrentView hook in QueryParamsFiltersEffect.tsx
- Directly loaded currentViewId using Recoil atom to prevent infinite loop
- Eliminated unmounting logic for unsaved filters, deemed unnecessary
- Simplified component logic to fix filtered INDEX view loading issues
- Removed potential redundant state updates, improving performance
1 file(s) reviewed, 2 comment(s)
Edit PR Review Bot Settings
const setUnsavedViewFilter = useSetRecoilComponentFamilyStateV2( | ||
unsavedToUpsertViewFiltersComponentFamilyState, | ||
{ viewId: viewIdQueryParam }, | ||
{ viewId: viewIdQueryParam ?? currentViewId }, | ||
); | ||
|
||
const { resetUnsavedViewStates } = useResetUnsavedViewStates(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
logic: resetUnsavedViewStates is imported but never used
if (isDefined(currentViewId)) { | ||
resetUnsavedViewStates(currentViewId); | ||
} | ||
}; | ||
}, [ | ||
getFiltersFromQueryParams, | ||
hasFiltersQueryParams, | ||
resetUnsavedViewStates, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
logic: resetUnsavedViewStates is in the dependency array but not used in the effect
## Context We have recently merged a refactoring of our view module. However, one case was forgotten which is to test our dynamic filtering logic. It is currently possible to pass unsaved filters through the URL and these filters will be applied to the currentView through `QueryParamsFiltersEffect`. This component was saving filters but also listening to them through useGetCurrentView hook. ## How 1) I'm removing this infinite loop by directly loading currentViewId through the right recoil atom. Bonus: I'm also removing the unmounting logic which seems wrong to me as unsaved filters are mounted on a specific view, there is no need to remove them while switching views in my opinion.
Context
We have recently merged a refactoring of our view module. However, one case was forgotten which is to test our dynamic filtering logic.
It is currently possible to pass unsaved filters through the URL and these filters will be applied to the currentView through
QueryParamsFiltersEffect
. This component was saving filters but also listening to them through useGetCurrentView hook.How
Bonus: I'm also removing the unmounting logic which seems wrong to me as unsaved filters are mounted on a specific view, there is no need to remove them while switching views in my opinion.