Fix children not properly refreshing across different categories for #207

This commit is contained in:
crschnick 2024-03-12 13:08:54 +00:00
parent c2ac2481e4
commit a4faa7c04c

View file

@ -101,7 +101,7 @@ public class StoreSection {
var matchesSelector = section.anyMatches(entryFilter); var matchesSelector = section.anyMatches(entryFilter);
var sameCategory = category == null var sameCategory = category == null
|| category.getValue() == null || category.getValue() == null
|| category.getValue().contains(section.getWrapper()); || inCategory(category.getValue(),section.getWrapper());
return showFilter && matchesSelector && sameCategory; return showFilter && matchesSelector && sameCategory;
}, },
category, category,
@ -140,7 +140,7 @@ public class StoreSection {
var matchesSelector = section.anyMatches(entryFilter); var matchesSelector = section.anyMatches(entryFilter);
var sameCategory = category == null var sameCategory = category == null
|| category.getValue() == null || category.getValue() == null
|| category.getValue().contains(section.getWrapper()); || inCategory(category.getValue(),section.getWrapper());
// If this entry is already shown as root due to a different category than parent, don't show it // If this entry is already shown as root due to a different category than parent, don't show it
// again here // again here
var notRoot = var notRoot =
@ -161,4 +161,16 @@ public class StoreSection {
|| c.test(wrapper) || c.test(wrapper)
|| allChildren.stream().anyMatch(storeEntrySection -> storeEntrySection.anyMatches(c)); || allChildren.stream().anyMatch(storeEntrySection -> storeEntrySection.anyMatches(c));
} }
private static boolean inCategory(StoreCategoryWrapper categoryWrapper, StoreEntryWrapper entryWrapper) {
var current = entryWrapper.getCategory().getValue();
while (current != null) {
if (categoryWrapper.getCategory().getUuid().equals(current.getCategory().getUuid())) {
return true;
}
current = current.getParent();
}
return false;
}
} }