-
Notifications
You must be signed in to change notification settings - Fork 463
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
Add filter state management #18602
base: main
Are you sure you want to change the base?
Add filter state management #18602
Conversation
PR Changes
|
this._queryResultWebviewPanelControllerMap | ||
.get(uri) | ||
.postNotification( | ||
DefaultWebviewNotifications.updateStorage, | ||
uri, | ||
); | ||
} else { | ||
try { | ||
this._queryResultWebviewPanelControllerMap | ||
.get(uri) | ||
.postNotification( | ||
DefaultWebviewNotifications.updateStorage, | ||
uri, | ||
); |
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.
These are identical, right? So the only thing that differs based on usePanelController
is whether to catch exceptions? What happens if usePanelController
is true
and it throws?
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.
Yeah so there are a few scenarios I'm trying to account for here (in the same order) -
- The user has the usePanelController setting checked and is applying filters to a grid in the "new tab" area
- The user doesn't have the usePanelController setting checked, but is still working in the panel area (they selected open in new tab, but don't have the setting updated to reflect this). In this case the panelControllerMap will exist in which case we want to send the notiification to the panelcontrollermap.
- The user is just working in the default area for the resultgrid, the bottom area where the vscode terminal also exists. We want to delete the filters for this grid area in this scenario.
DefaultWebviewNotifications.updateStorage, | ||
uri, | ||
); | ||
} catch { |
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.
what does this throwing mean? Is it an error that needs logging/telemetry?
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.
hopefully the above comment explains this, maybe there's a better way to handle all these scenarios more gracefully.
src/reactviews/pages/QueryResult/table/plugins/headerFilter.plugin.ts
Outdated
Show resolved
Hide resolved
const gridColumnMapArray = store.get( | ||
this.queryResultState.state.uri!, | ||
) as GridColumnMap[]; | ||
if (gridColumnMapArray) { |
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.
some comments in here would be nice; there's a lot of slicing and dicing of data with hardcoded indexes going on
Adds filter state management
Before:
filters were only tracked on a column.id level, which led to issues like #18514.
After:
Filters are tracked at a (query editor) uri level, containing multiple sets of filters for each grid id and column id respectively.
I also added a singleton store, which allows us to store state outside of the react state (this is needed in cases where we don't want to trigger a re-render which happens every time the react state is updated). We don't need to re-render here because that is triggered and managed by the slickgrid library.
Fixes #18514