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 shop issues with category filtering #1482

Open
wants to merge 1 commit into
base: dev
Choose a base branch
from

Conversation

Pablete1234
Copy link
Member

Fixes bugs regarding filtering categories in the shop:

  • Categories with filters would cause index out of bounds exceptions
  • When the categories change due to filters, they get updated instead of keeping the same list until re-opening
  • Paginated Categories now properly highlight when going back and forth between pages

Comment on lines +148 to +152
boolean anyChanged = false;
for (CategoryItem category : allCategories) {
if (category.changed()) anyChanged = true;
}
if (categories != null && !anyChanged) return false;
Copy link
Member

Choose a reason for hiding this comment

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

nit: Assuming we don't need to run category.changed() for every category every time:

Suggested change
boolean anyChanged = false;
for (CategoryItem category : allCategories) {
if (category.changed()) anyChanged = true;
}
if (categories != null && !anyChanged) return false;
if (categories != null && allCategories.stream().noneMatch((CategoryItem::changed)))
return false;

Copy link
Member Author

@Pablete1234 Pablete1234 Jan 20, 2025

Choose a reason for hiding this comment

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

We do need to check all of them, since that will update the active flag on the category.

If we do a noneMatch as soon as one is changed, all following ones will not get their filter updated.

For most cases, you'll check changed on all categories and none will have changed, in which case that's where it ends. In the odd case that one or more have changed, you will need to re-build the lists etc

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants