Merge pull request 'Fix: Optimize generateBreadcrumbs' (#32) from nodemember into master
Alle Prüfungen waren erfolgreich
SteamWarCI Build successful
Alle Prüfungen waren erfolgreich
SteamWarCI Build successful
Reviewed-on: #32 Reviewed-by: Lixfel <lixfel@steamwar.de>
Dieser Commit ist enthalten in:
Commit
aaac56754c
@ -501,12 +501,20 @@ public class SchematicNode {
|
||||
public String generateBreadcrumbs(String split) {
|
||||
StringBuilder builder = new StringBuilder(getName());
|
||||
Optional<SchematicNode> currentNode = Optional.of(this);
|
||||
List<SchematicNode> parents = SchematicNode.parentsOfNode(SteamwarUser.get(effectiveOwner), nodeId);
|
||||
if(currentNode.map(SchematicNode::isDir).orElse(false)) {
|
||||
builder.append(split);
|
||||
}
|
||||
while (currentNode.isPresent()) {
|
||||
currentNode = currentNode.flatMap(SchematicNode::getOptionalParent).flatMap(integer -> parents.stream().filter(schematicNode -> schematicNode.getId() == integer).findFirst());
|
||||
currentNode = currentNode.flatMap(SchematicNode::getOptionalParent).map(integer -> {
|
||||
NodeMember member = NodeMember.getNodeMember(integer, nodeOwner);
|
||||
if (member != null) {
|
||||
integer = member.getParent().orElse(null);
|
||||
if(integer == null) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
return SchematicNode.getSchematicNode(integer);
|
||||
});
|
||||
currentNode.ifPresent(node -> builder.insert(0, split).insert(0, node.getName()));
|
||||
}
|
||||
return builder.toString();
|
||||
@ -552,7 +560,8 @@ public class SchematicNode {
|
||||
SchematicNode pa = SchematicNode.getNodeFromPath(user, preTab);
|
||||
if (pa == null) return Collections.emptyList();
|
||||
List<SchematicNode> nodes = SchematicNode.list(user, pa.getId());
|
||||
nodes.forEach(node -> list.add((sws ? "/" : "") + node.generateBreadcrumbs()));
|
||||
String br = pa.generateBreadcrumbs();
|
||||
nodes.forEach(node -> list.add((sws ? "/" : "") + br + node.getName()));
|
||||
} else {
|
||||
List<SchematicNode> nodes = SchematicNode.list(user, null);
|
||||
nodes.forEach(node -> list.add((sws ? "/" : "") + node.getName() + (node.isDir() ? "/" : "")));
|
||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren