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

Add filter state management #18602

Open
wants to merge 13 commits into
base: main
Choose a base branch
from
Open

Add filter state management #18602

wants to merge 13 commits into from

Conversation

cssuh
Copy link
Member

@cssuh cssuh commented Jan 28, 2025

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.

filterFixFinal

Fixes #18514

Copy link

github-actions bot commented Jan 28, 2025

PR Changes

Category Main Branch PR Branch Difference
Code Coverage 50.41% 50.55% $${\color{lightgreen} .14\% }$$
VSIX Size 12140 KB 12142 KB $${\color{lightgreen} 2 KB \space (0\%) }$$
Webview Bundle Size 3176 KB 3176 KB $${\color{lightgreen} 0 KB \space (0\%) }$$

src/reactviews/common/singletonStore.ts Outdated Show resolved Hide resolved
src/reactviews/common/vscodeWebviewProvider.tsx Outdated Show resolved Hide resolved
src/reactviews/common/vscodeWebviewProvider.tsx Outdated Show resolved Hide resolved
Comment on lines 421 to 434
this._queryResultWebviewPanelControllerMap
.get(uri)
.postNotification(
DefaultWebviewNotifications.updateStorage,
uri,
);
} else {
try {
this._queryResultWebviewPanelControllerMap
.get(uri)
.postNotification(
DefaultWebviewNotifications.updateStorage,
uri,
);
Copy link
Contributor

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?

Copy link
Member Author

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) -

  1. The user has the usePanelController setting checked and is applying filters to a grid in the "new tab" area
  2. 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.
  3. 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 {
Copy link
Contributor

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?

Copy link
Member Author

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.

const gridColumnMapArray = store.get(
this.queryResultState.state.uri!,
) as GridColumnMap[];
if (gridColumnMapArray) {
Copy link
Contributor

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

@cssuh cssuh requested a review from Benjin January 30, 2025 00:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Applying a filter to a column affects all result sets containing a column with that name
2 participants