From 2e527684bb136609e096619babc5a0a149fd491e Mon Sep 17 00:00:00 2001 From: crschnick Date: Sun, 8 Jun 2025 01:20:58 +0000 Subject: [PATCH] Fix store choice popover performance --- .../file/BrowserConnectionListComp.java | 3 +- .../xpipe/app/comp/store/StoreChoiceComp.java | 8 ++--- .../io/xpipe/app/comp/store/StoreSection.java | 34 ++++++++++++++++--- .../xpipe/app/comp/store/StoreViewState.java | 3 +- 4 files changed, 37 insertions(+), 11 deletions(-) diff --git a/app/src/main/java/io/xpipe/app/browser/file/BrowserConnectionListComp.java b/app/src/main/java/io/xpipe/app/browser/file/BrowserConnectionListComp.java index d1d541861..62685b8f1 100644 --- a/app/src/main/java/io/xpipe/app/browser/file/BrowserConnectionListComp.java +++ b/app/src/main/java/io/xpipe/app/browser/file/BrowserConnectionListComp.java @@ -73,7 +73,8 @@ public final class BrowserConnectionListComp extends SimpleComp { filter, category, StoreViewState.get().getEntriesListVisibilityObservable(), - StoreViewState.get().getEntriesListUpdateObservable()), + StoreViewState.get().getEntriesListUpdateObservable(), + new ReadOnlyBooleanWrapper(true)), augment, selectedAction -> { BooleanProperty busy = new SimpleBooleanProperty(false); diff --git a/app/src/main/java/io/xpipe/app/comp/store/StoreChoiceComp.java b/app/src/main/java/io/xpipe/app/comp/store/StoreChoiceComp.java index ace9b85c6..29c5117ea 100644 --- a/app/src/main/java/io/xpipe/app/comp/store/StoreChoiceComp.java +++ b/app/src/main/java/io/xpipe/app/comp/store/StoreChoiceComp.java @@ -17,10 +17,7 @@ import io.xpipe.app.util.LabelGraphic; import io.xpipe.core.store.DataStore; import javafx.beans.binding.Bindings; -import javafx.beans.property.Property; -import javafx.beans.property.SimpleBooleanProperty; -import javafx.beans.property.SimpleObjectProperty; -import javafx.beans.property.SimpleStringProperty; +import javafx.beans.property.*; import javafx.collections.ListChangeListener; import javafx.geometry.Insets; import javafx.geometry.Pos; @@ -116,7 +113,8 @@ public class StoreChoiceComp extends SimpleComp { filterText, selectedCategory, StoreViewState.get().getEntriesListVisibilityObservable(), - StoreViewState.get().getEntriesListUpdateObservable()), + StoreViewState.get().getEntriesListUpdateObservable(), + popover.showingProperty()), (s, comp) -> { if (!applicable.test(s.getWrapper())) { comp.disable(new SimpleBooleanProperty(true)); diff --git a/app/src/main/java/io/xpipe/app/comp/store/StoreSection.java b/app/src/main/java/io/xpipe/app/comp/store/StoreSection.java index 900e5c87e..cd7d1602f 100644 --- a/app/src/main/java/io/xpipe/app/comp/store/StoreSection.java +++ b/app/src/main/java/io/xpipe/app/comp/store/StoreSection.java @@ -8,6 +8,7 @@ import io.xpipe.app.util.BindingsHelper; import io.xpipe.app.util.DerivedObservableList; import javafx.beans.binding.Bindings; +import javafx.beans.property.BooleanProperty; import javafx.beans.property.SimpleBooleanProperty; import javafx.beans.value.ObservableBooleanValue; import javafx.beans.value.ObservableIntegerValue; @@ -107,12 +108,19 @@ public class StoreSection { ObservableValue filterString, ObservableValue category, ObservableIntegerValue visibilityObservable, - ObservableIntegerValue updateObservable) { + ObservableIntegerValue updateObservable, + ObservableValue enabled + ) { var topLevel = all.filtered( section -> { + if (!enabled.getValue()) { + return false; + } + return DataStorage.get() .isRootEntry(section.getEntry(), category.getValue().getCategory()); }, + enabled, category, updateObservable); var cached = topLevel.mapped(storeEntryWrapper -> create( @@ -125,10 +133,15 @@ public class StoreSection { filterString, category, visibilityObservable, - updateObservable)); + updateObservable, + enabled)); var ordered = sorted(cached, category, updateObservable); var shown = ordered.filtered( section -> { + if (!enabled.getValue()) { + return false; + } + // matches filter return (filterString == null || section.matchesFilter(filterString.getValue())) && @@ -138,6 +151,7 @@ public class StoreSection { // same category (showInCategory(category.getValue(), section.getWrapper())); }, + enabled, category, filterString, updateObservable); @@ -154,7 +168,8 @@ public class StoreSection { ObservableValue filterString, ObservableValue category, ObservableIntegerValue visibilityObservable, - ObservableIntegerValue updateObservable) { + ObservableIntegerValue updateObservable, + ObservableValue enabled) { if (e.getEntry().getValidity() == DataStoreEntry.Validity.LOAD_FAILED) { return new StoreSection( e, DerivedObservableList.arrayList(true), DerivedObservableList.arrayList(true), depth); @@ -162,6 +177,10 @@ public class StoreSection { var allChildren = all.filtered( other -> { + if (!enabled.getValue()) { + return false; + } + // Legacy implementation that does not use children caches. Use for testing // if (true) return DataStorage.get() // .getDefaultDisplayParent(other.getEntry()) @@ -176,6 +195,7 @@ public class StoreSection { return true; }, + enabled, e.getPersistentState(), e.getCache(), visibilityObservable, @@ -192,10 +212,15 @@ public class StoreSection { filterString, category, visibilityObservable, - updateObservable)); + updateObservable, + enabled)); var ordered = sorted(cached, category, updateObservable); var filtered = ordered.filtered( section -> { + if (!enabled.getValue()) { + return false; + } + var isBatchSelected = selected.contains(section.getWrapper()); var matchesFilter = filterString == null @@ -246,6 +271,7 @@ public class StoreSection { return true; }, + enabled, category, filterString, e.getPersistentState(), 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 c2f415ebc..8f8a9898a 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 @@ -156,7 +156,8 @@ public class StoreViewState { filter, activeCategory, entriesListVisibilityObservable, - entriesListUpdateObservable); + entriesListUpdateObservable, + new ReadOnlyBooleanWrapper(true)); } catch (Exception exception) { currentTopLevelSection = new StoreSection( null, DerivedObservableList.arrayList(true), DerivedObservableList.arrayList(true), 0);