File tree Expand file tree Collapse file tree 1 file changed +4
-5
lines changed
srv/src/main/java/my/bookshop/handlers Expand file tree Collapse file tree 1 file changed +4
-5
lines changed Original file line number Diff line number Diff line change @@ -51,9 +51,6 @@ void onMoveSiblingAction(GenreHierarchyMoveSiblingContext event) {
5151 .where (c -> c .parent_ID ().eq (parentId )))
5252 .listOf (GenreHierarchy .class );
5353
54- // Shift the sibling ranks to reflect the sort order
55- List <Integer > siblingRanksCopy = siblingNodes .stream ().map (ch -> ch .getSiblingRank ()).toList ();
56-
5754 String nextSiblingId = event .getNextSibling () == null ? null : event .getNextSibling ().getId ();
5855 Optional <GenreHierarchy > nextSibling = siblingNodes .stream ().filter (el -> el .getId ().equals (nextSiblingId ))
5956 .findFirst ();
@@ -63,9 +60,11 @@ void onMoveSiblingAction(GenreHierarchyMoveSiblingContext event) {
6360 // Exchange siblings
6461 nextSibling .ifPresentOrElse (n -> siblingNodes .add (siblingNodes .indexOf (n ), moved ),
6562 () -> siblingNodes .addLast (moved ));
63+
6664 // Apply ranks
67- for (int i = 0 ; i < siblingRanksCopy .size (); i ++) {
68- siblingNodes .get (i ).setSiblingRank (siblingRanksCopy .get (i ));
65+ int i = 0 ;
66+ for (GenreHierarchy sibling : siblingNodes ) {
67+ sibling .setSiblingRank (i ++);
6968 }
7069
7170 // Update DB
You can’t perform that action at this time.
0 commit comments