From a565c795cf0a46978364c8f91a4c845d8c1584f9 Mon Sep 17 00:00:00 2001 From: crschnick Date: Fri, 4 Oct 2024 16:53:55 +0000 Subject: [PATCH] Fix category move updates --- .../main/java/io/xpipe/app/comp/store/StoreViewState.java | 7 +++++++ app/src/main/java/io/xpipe/app/storage/DataStorage.java | 2 ++ .../main/java/io/xpipe/app/storage/StorageListener.java | 2 ++ 3 files changed, 11 insertions(+) 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 c2297d6d2..3bf5c1aab 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 @@ -281,6 +281,13 @@ public class StoreViewState { } }); } + + @Override + public void onEntryCategoryChange(DataStoreCategory from, DataStoreCategory to) { + synchronized (this) { + categories.getList().forEach(storeCategoryWrapper -> storeCategoryWrapper.update()); + } + } }); } diff --git a/app/src/main/java/io/xpipe/app/storage/DataStorage.java b/app/src/main/java/io/xpipe/app/storage/DataStorage.java index 3e96c2219..33eeb41f7 100644 --- a/app/src/main/java/io/xpipe/app/storage/DataStorage.java +++ b/app/src/main/java/io/xpipe/app/storage/DataStorage.java @@ -350,9 +350,11 @@ public abstract class DataStorage { return; } + var oldCat = getStoreCategoryIfPresent(entry.getCategoryUuid()).orElse(getDefaultConnectionsCategory()); entry.setCategoryUuid(newCategory.getUuid()); var children = getDeepStoreChildren(entry); children.forEach(child -> child.setCategoryUuid(newCategory.getUuid())); + listeners.forEach(storageListener -> storageListener.onEntryCategoryChange(oldCat, newCategory)); listeners.forEach(storageListener -> storageListener.onStoreListUpdate()); saveAsync(); } diff --git a/app/src/main/java/io/xpipe/app/storage/StorageListener.java b/app/src/main/java/io/xpipe/app/storage/StorageListener.java index 5b3e80de9..d3a237a90 100644 --- a/app/src/main/java/io/xpipe/app/storage/StorageListener.java +++ b/app/src/main/java/io/xpipe/app/storage/StorageListener.java @@ -11,4 +11,6 @@ public interface StorageListener { void onCategoryAdd(DataStoreCategory category); void onCategoryRemove(DataStoreCategory category); + + void onEntryCategoryChange(DataStoreCategory from, DataStoreCategory to); }