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: avoid unnecessary initial filter loading state #2503

Merged
merged 1 commit into from
Jan 16, 2024

Conversation

mstykow
Copy link
Collaborator

@mstykow mstykow commented Jan 16, 2024

Summary of changes

  • use all manual attributions as filtered attributions when no filter is set
  • separate concerns of signals worker hook from those of the hooks accessing variables from the Redux store

Context and reason for change

closes #2502

How can the changes be tested

Open a large Opossum file and notice that the attribution list immediately displays attributions without any filter loading spinner spinning.

- use all manual attributions as filtered attributions when no filter is set
- separate concerns of signals worker hook from those of the hooks accessing variables from the Redux store

closes #2502

Signed-off-by: Maxim Stykow <maxim.stykow@tngtech.com>
@mstykow mstykow force-pushed the fix-avoid-unnecessary-initial-filter-load-times branch from 5f1bb8c to 26144b0 Compare January 16, 2024 10:41

export const FOLDER_PROGRESS_DATA = 'folder-progress-data';

export function useFolderProgressData() {
Copy link
Member

Choose a reason for hiding this comment

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

We could also have the simple hooks accumulated in one file, but I think it is nice to have them separated like you did it.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

yes, i was considering along the same lines

import { getManualAttributions } from '../selectors/all-views-resource-selectors';
import { useVariable } from './use-variable';

export const FILTERED_ATTRIBUTIONS = 'filtered-attributions';
Copy link
Member

@antonbauhofer antonbauhofer Jan 16, 2024

Choose a reason for hiding this comment

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

We should always do that 👍
I was thinking we could add _KEY to these variable names to make their purpose clear.

Comment on lines +44 to +47
setFilteredAttributions((prev) => ({
...prev,
attributions,
}));
Copy link
Member

Choose a reason for hiding this comment

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

Why do we pass an arrow function here instead of just passing attributions?

Suggested change
setFilteredAttributions((prev) => ({
...prev,
attributions,
}));
setFilteredAttributions(
attributions,
);

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

because i need to preserve the other attributes that are inside prev but not part of attributions

});
});

it('sends selected filters when some are set', () => {
Copy link
Member

Choose a reason for hiding this comment

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

👍

useFilteredAttributions,
} from '../use-filtered-attributions';

describe('useFilteredAttributions', () => {
Copy link
Member

Choose a reason for hiding this comment

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

👍

Copy link
Member

@antonbauhofer antonbauhofer left a comment

Choose a reason for hiding this comment

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

Looks good to me and works as expected.
For a more pleasant review, I would have preferred to have the refactorings in a separate pull request, though.

@mstykow mstykow merged commit 98c42d7 into main Jan 16, 2024
5 checks passed
@mstykow mstykow deleted the fix-avoid-unnecessary-initial-filter-load-times branch January 16, 2024 14:32
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.

Loading attribution list in attribution view for the first time is very slow
2 participants