Rework store visibility updates

This commit is contained in:
crschnick 2024-05-28 06:10:00 +00:00
parent e6b70ff60c
commit f3557bb715
4 changed files with 25 additions and 14 deletions

View file

@ -52,7 +52,6 @@ public class StoreToggleComp extends SimpleComp {
initial.apply(section.getWrapper().getEntry().getStore().asNeeded())),
v -> {
setter.accept(section.getWrapper().getEntry().getStore().asNeeded(), v);
section.getWrapper().refreshChildren();
});
}

View file

@ -59,12 +59,13 @@ public class StoreEntryListStatusComp extends SimpleComp {
var all = ListBindingsHelper.filteredContentBinding(
StoreViewState.get().getAllEntries(),
storeEntryWrapper -> {
var storeRoot = storeEntryWrapper.getCategory().getValue().getRoot();
return StoreViewState.get()
.getActiveCategory()
.getValue()
.getRoot()
.equals(storeRoot);
var rootCategory = storeEntryWrapper.getCategory().getValue().getRoot();
var inRootCategory = StoreViewState.get().getActiveCategory().getValue().getRoot().equals(rootCategory);
// Sadly the all binding does not update when the individual visibility of entries changes
// But it is good enough.
var showProvider = storeEntryWrapper.getEntry().getProvider() == null ||
storeEntryWrapper.getEntry().getProvider().shouldShow(storeEntryWrapper);
return inRootCategory && showProvider;
},
StoreViewState.get().getActiveCategory());
var shownList = ListBindingsHelper.filteredContentBinding(

View file

@ -103,7 +103,7 @@ public class StoreSection {
var shown = ListBindingsHelper.filteredContentBinding(
ordered,
section -> {
var showFilter = filterString == null || section.shouldShow(filterString.get());
var showFilter = filterString == null || section.matchesFilter(filterString.get());
var matchesSelector = section.anyMatches(entryFilter);
var sameCategory = category == null
|| category.getValue() == null
@ -134,8 +134,11 @@ public class StoreSection {
// .orElse(false);
// This check is fast as the children are cached in the storage
return DataStorage.get().getStoreChildren(e.getEntry()).contains(other.getEntry());
});
var isChildren = DataStorage.get().getStoreChildren(e.getEntry()).contains(other.getEntry());
var showProvider = other.getEntry().getProvider() == null ||
other.getEntry().getProvider().shouldShow(other);
return isChildren && showProvider;
}, e.getPersistentState(), e.getCache());
var cached = ListBindingsHelper.cachedMappedContentBinding(
allChildren,
allChildren,
@ -144,7 +147,7 @@ public class StoreSection {
var filtered = ListBindingsHelper.filteredContentBinding(
ordered,
section -> {
var showFilter = filterString == null || section.shouldShow(filterString.get());
var showFilter = filterString == null || section.matchesFilter(filterString.get());
var matchesSelector = section.anyMatches(entryFilter);
var sameCategory = category == null
|| category.getValue() == null
@ -153,10 +156,14 @@ public class StoreSection {
// again here
var notRoot =
!DataStorage.get().isRootEntry(section.getWrapper().getEntry());
return showFilter && matchesSelector && sameCategory && notRoot;
var showProvider = section.getWrapper().getEntry().getProvider() == null ||
section.getWrapper().getEntry().getProvider().shouldShow(section.getWrapper());
return showFilter && matchesSelector && sameCategory && notRoot && showProvider;
},
category,
filterString);
filterString,
e.getPersistentState(),
e.getCache());
return new StoreSection(e, cached, filtered, depth);
}
@ -179,7 +186,7 @@ public class StoreSection {
return false;
}
public boolean shouldShow(String filter) {
public boolean matchesFilter(String filter) {
return anyMatches(storeEntryWrapper -> storeEntryWrapper.shouldShow(filter));
}

View file

@ -28,6 +28,10 @@ import java.util.List;
public interface DataStoreProvider {
default boolean shouldShow(StoreEntryWrapper w) {
return true;
}
default ObservableBooleanValue busy(StoreEntryWrapper wrapper) {
return new SimpleBooleanProperty(false);
}