diff --git a/app/src/main/java/io/xpipe/app/comp/store/StoreCategoryWrapper.java b/app/src/main/java/io/xpipe/app/comp/store/StoreCategoryWrapper.java index 1803ad617..245ff061f 100644 --- a/app/src/main/java/io/xpipe/app/comp/store/StoreCategoryWrapper.java +++ b/app/src/main/java/io/xpipe/app/comp/store/StoreCategoryWrapper.java @@ -28,7 +28,8 @@ public class StoreCategoryWrapper { private final Property sortMode; private final Property sync; private final ObservableList children; - private final ObservableList containedEntries; + private final ObservableList directContainedEntries; + private final ObservableList allContainedEntries; private final BooleanProperty expanded = new SimpleBooleanProperty(); private final Property color = new SimpleObjectProperty<>(); @@ -52,7 +53,8 @@ public class StoreCategoryWrapper { this.sortMode = new SimpleObjectProperty<>(category.getSortMode()); this.sync = new SimpleObjectProperty<>(category.isSync()); this.children = FXCollections.observableArrayList(); - this.containedEntries = FXCollections.observableArrayList(); + this.allContainedEntries = FXCollections.observableArrayList(); + this.directContainedEntries = FXCollections.observableArrayList(); this.color.setValue(category.getColor()); setupListeners(); } @@ -70,7 +72,7 @@ public class StoreCategoryWrapper { } public boolean contains(StoreEntryWrapper entry) { - return entry.getEntry().getCategoryUuid().equals(category.getUuid()) || containedEntries.contains(entry); + return entry.getEntry().getCategoryUuid().equals(category.getUuid()) || allContainedEntries.contains(entry); } public void select() { @@ -135,7 +137,12 @@ public class StoreCategoryWrapper { expanded.setValue(category.isExpanded()); color.setValue(category.getColor()); - containedEntries.setAll(StoreViewState.get().getAllEntries().getList().stream() + directContainedEntries.setAll(StoreViewState.get().getAllEntries().getList().stream() + .filter(entry -> { + return entry.getEntry().getCategoryUuid().equals(category.getUuid()); + }) + .toList()); + allContainedEntries.setAll(StoreViewState.get().getAllEntries().getList().stream() .filter(entry -> { return entry.getEntry().getCategoryUuid().equals(category.getUuid()) || (AppPrefs.get() diff --git a/app/src/main/java/io/xpipe/app/comp/store/StoreViewState.java b/app/src/main/java/io/xpipe/app/comp/store/StoreViewState.java index 69506d85b..0914f828d 100644 --- a/app/src/main/java/io/xpipe/app/comp/store/StoreViewState.java +++ b/app/src/main/java/io/xpipe/app/comp/store/StoreViewState.java @@ -55,6 +55,7 @@ public class StoreViewState { INSTANCE = new StoreViewState(); INSTANCE.updateContent(); INSTANCE.initSections(); + INSTANCE.initFilterJump(); } public static void reset() { @@ -94,6 +95,20 @@ public class StoreViewState { } } + private void initFilterJump() { + var all = getAllConnectionsCategory(); + filter.addListener((observable, oldValue, newValue) -> { + var matchingCats = categories.getList().stream().filter(storeCategoryWrapper -> storeCategoryWrapper.getRoot().equals(all)) + .filter(storeCategoryWrapper -> storeCategoryWrapper.getDirectContainedEntries() + .stream() + .anyMatch(wrapper -> wrapper.matchesFilter(newValue))) + .toList(); + if (matchingCats.size() == 1) { + activeCategory.setValue(matchingCats.getFirst()); + } + }); + } + private void initContent() { allEntries .getList() diff --git a/app/src/main/java/io/xpipe/app/fxcomps/impl/StoreCategoryComp.java b/app/src/main/java/io/xpipe/app/fxcomps/impl/StoreCategoryComp.java index af44f8f4c..4438dbaa2 100644 --- a/app/src/main/java/io/xpipe/app/fxcomps/impl/StoreCategoryComp.java +++ b/app/src/main/java/io/xpipe/app/fxcomps/impl/StoreCategoryComp.java @@ -109,7 +109,7 @@ public class StoreCategoryComp extends SimpleComp { })) .styleClass("status-button"); - var shownList = new DerivedObservableList<>(category.getContainedEntries(), true) + var shownList = new DerivedObservableList<>(category.getAllContainedEntries(), true) .filtered( storeEntryWrapper -> { return storeEntryWrapper.matchesFilter( @@ -117,7 +117,7 @@ public class StoreCategoryComp extends SimpleComp { }, StoreViewState.get().getFilterString()) .getList(); - var count = new CountComp<>(shownList, category.getContainedEntries(), string -> "(" + string + ")"); + var count = new CountComp<>(shownList, category.getAllContainedEntries(), string -> "(" + string + ")"); var showStatus = hover.or(new SimpleBooleanProperty(DataStorage.get().supportsSharing())) .or(showing);