From 05cfdacd1dc7f1e1eb99dff9e3fffccac92acd43 Mon Sep 17 00:00:00 2001 From: crschnick Date: Mon, 2 Jun 2025 15:44:31 +0000 Subject: [PATCH] Fix information updates not being displayed after store change --- .../app/comp/store/DenseStoreEntryComp.java | 4 +- .../app/comp/store/StoreEntryWrapper.java | 37 ++++++++++--------- 2 files changed, 22 insertions(+), 19 deletions(-) diff --git a/app/src/main/java/io/xpipe/app/comp/store/DenseStoreEntryComp.java b/app/src/main/java/io/xpipe/app/comp/store/DenseStoreEntryComp.java index fb1d644d2..4e68f9d10 100644 --- a/app/src/main/java/io/xpipe/app/comp/store/DenseStoreEntryComp.java +++ b/app/src/main/java/io/xpipe/app/comp/store/DenseStoreEntryComp.java @@ -33,7 +33,7 @@ public class DenseStoreEntryComp extends StoreEntryComp { var info = getWrapper().getShownInformation(); information .textProperty() - .bind(PlatformThread.sync(Bindings.createStringBinding( + .bind(Bindings.createStringBinding( () -> { var val = summary.getValue(); var p = getWrapper().getEntry().getProvider(); @@ -47,7 +47,7 @@ public class DenseStoreEntryComp extends StoreEntryComp { }, grid.hoverProperty(), info, - summary))); + summary)); } return information; diff --git a/app/src/main/java/io/xpipe/app/comp/store/StoreEntryWrapper.java b/app/src/main/java/io/xpipe/app/comp/store/StoreEntryWrapper.java index ba3466186..92bbc3a82 100644 --- a/app/src/main/java/io/xpipe/app/comp/store/StoreEntryWrapper.java +++ b/app/src/main/java/io/xpipe/app/comp/store/StoreEntryWrapper.java @@ -9,6 +9,7 @@ import io.xpipe.app.storage.DataStorage; import io.xpipe.app.storage.DataStoreCategory; import io.xpipe.app.storage.DataStoreColor; import io.xpipe.app.storage.DataStoreEntry; +import io.xpipe.app.util.BindingsHelper; import io.xpipe.app.util.PlatformThread; import io.xpipe.app.util.ThreadHelper; import io.xpipe.core.store.DataStore; @@ -55,7 +56,7 @@ public class StoreEntryWrapper { private final BooleanProperty perUser = new SimpleBooleanProperty(); private final ObservableValue shownName; private final ObservableValue shownSummary; - private final ObservableValue shownInformation; + private final Property shownInformation; private final BooleanProperty largeCategoryOptimizations = new SimpleBooleanProperty(); private boolean effectiveBusyProviderBound = false; @@ -79,13 +80,7 @@ public class StoreEntryWrapper { }, AppPrefs.get().censorMode(), summary); - this.shownInformation = Bindings.createStringBinding( - () -> { - var n = information.getValue(); - return n != null && AppPrefs.get().censorMode().get() ? "*".repeat(n.length()) : n; - }, - AppPrefs.get().censorMode(), - information); + this.shownInformation = new SimpleObjectProperty<>(); ActionProvider.ALL_STANDALONE.stream() .filter(dataStoreActionProvider -> { return !entry.isDisabled() @@ -181,20 +176,11 @@ public class StoreEntryWrapper { expanded.setValue(entry.isExpanded()); persistentState.setValue(entry.getStorePersistentState()); - // The property values are only registered as changed once they are queried - // If we use information bindings that depend on some of these properties - // but use the store methods to retrieve data instead of the wrapper properties, - // the bindings do not get updated as the change events are not fired. - // We can also fire them manually with this - persistentState.getValue(); - // Use map copy to recognize update // This is a synchronized map, so we synchronize the access synchronized (entry.getStoreCache()) { if (!entry.getStoreCache().equals(cache.getValue())) { cache.setValue(new HashMap<>(entry.getStoreCache())); - // Same here - cache.getValue(); } } color.setValue(entry.getColor()); @@ -224,9 +210,17 @@ public class StoreEntryWrapper { var section = StoreViewState.get().getSectionForWrapper(this); if (section.isPresent()) { information.unbind(); + shownInformation.unbind(); try { var is = entry.getProvider().informationString(section.get()); information.bind(is); + shownInformation.bind(Bindings.createStringBinding( + () -> { + var n = information.getValue(); + return n != null && AppPrefs.get().censorMode().get() ? "*".repeat(n.length()) : n; + }, + AppPrefs.get().censorMode(), + information)); } catch (Exception e) { ErrorEvent.fromThrowable(e).handle(); information.bind(new SimpleStringProperty()); @@ -287,6 +281,15 @@ public class StoreEntryWrapper { if (!this.effectiveBusy.isBound() && !getValidity().getValue().isUsable()) { this.effectiveBusy.bind(busy); } + + // The property values are only registered as changed once they are queried + // If we use information bindings that depend on some of these properties + // but use the store methods to retrieve data instead of the wrapper properties, + // the bindings do not get updated as the change events are not fired. + // We can also fire them manually with this + persistentState.getValue(); + store.getValue(); + cache.getValue(); } public boolean showActionProvider(ActionProvider p) {