mirror of
https://github.com/xpipe-io/xpipe.git
synced 2026-08-25 18:56:39 +00:00
Fix nested script hierarchy display
This commit is contained in:
@@ -21,7 +21,7 @@ public class ScriptHierarchy {
|
||||
var enabled =
|
||||
ScriptStoreSetup.getEnabledScripts().stream().filter(include).toList();
|
||||
|
||||
var categories = new HashSet<DataStoreCategory>();
|
||||
var categories = new LinkedHashSet<DataStoreCategory>();
|
||||
for (DataStoreEntryRef<ScriptStore> ref : enabled) {
|
||||
var cat = DataStorage.get().getStoreCategory(ref.get());
|
||||
var catParents = DataStorage.get().getCategoryParentHierarchy(cat);
|
||||
@@ -40,7 +40,8 @@ public class ScriptHierarchy {
|
||||
var toAdd = new ScriptHierarchy(cat.getName(), cat, null, new ArrayList<>());
|
||||
|
||||
if (cat.getParentCategory().equals(DataStorage.ALL_SCRIPTS_CATEGORY_UUID)) {
|
||||
if (!hierarchy.getChildren().contains(toAdd)) {
|
||||
if (hierarchy.getChildren().stream().noneMatch(scriptHierarchy ->
|
||||
scriptHierarchy.getCategory() != null && scriptHierarchy.getCategory().getUuid().equals(cat.getUuid()))) {
|
||||
hierarchy.getChildren().add(toAdd);
|
||||
changed = true;
|
||||
}
|
||||
@@ -52,7 +53,8 @@ public class ScriptHierarchy {
|
||||
continue;
|
||||
}
|
||||
|
||||
var alreadyAdded = parentHierarchy.get().getChildren().contains(toAdd);
|
||||
var alreadyAdded = parentHierarchy.get().getChildren().stream().anyMatch(scriptHierarchy ->
|
||||
scriptHierarchy.getCategory() != null && cat.getUuid().equals(scriptHierarchy.getCategory().getUuid()));
|
||||
if (alreadyAdded) {
|
||||
continue;
|
||||
}
|
||||
@@ -90,7 +92,7 @@ public class ScriptHierarchy {
|
||||
}
|
||||
|
||||
private static Optional<ScriptHierarchy> findParent(ScriptHierarchy hierarchy, DataStoreCategory category) {
|
||||
if (category.equals(hierarchy.getCategory())) {
|
||||
if (hierarchy.getCategory() != null && category.getParentCategory().equals(hierarchy.getCategory().getUuid())) {
|
||||
return Optional.of(hierarchy);
|
||||
}
|
||||
|
||||
@@ -121,14 +123,6 @@ public class ScriptHierarchy {
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isEmptyBranch() {
|
||||
if (category == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return children.isEmpty();
|
||||
}
|
||||
|
||||
public boolean isLeaf() {
|
||||
return script != null;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user