Skip to content

Commit

Permalink
bug(ToggleComposites): Fix server delete composite handling
Browse files Browse the repository at this point in the history
  • Loading branch information
Kruptein authored Jan 19, 2025
2 parents e15c2d5 + 174ab01 commit 2b45459
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 9 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,8 @@ tech changes will usually be stripped from release notes for the public
- Input changes could not persist or save on the wrong shape if selection focus was changed while editing (see selection changes)
- Modals
- Dragging modals (e.g. notes) now also brings them to the foreground as if clicked
- Composites:
- Moving composites to a different location could sometimes lead to errors on the client even though the moves were succesful serverside

## [2024.3.1] - 2024-11-12

Expand Down
25 changes: 16 additions & 9 deletions server/src/api/socket/shape/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -150,13 +150,9 @@ async def send_remove_shapes(
def _get_shapes_from_uuids(
uuids: list[str], filter_layer: bool
) -> SelectSequence[Shape]:
query = Shape.select().where(
(Shape.uuid << uuids) # pyright: ignore[reportGeneralTypeIssues]
)
query = Shape.select().where((Shape.uuid << uuids)) # type: ignore
if filter_layer:
query = query.where(
~(Shape.layer >> None) # pyright: ignore[reportGeneralTypeIssues]
)
query = query.where(~(Shape.layer >> None)) # type: ignore
return query


Expand Down Expand Up @@ -407,14 +403,19 @@ async def move_shapes(sid: str, raw_data: Any):
if data.target.layer:
target_layer = floor.layers.where(Layer.name == data.target.layer)[0]

shape_uuids = set()
shapes = []
old_floor = None
for shape in _get_shapes_from_uuids(data.shapes, False):
if shape.uuid in shape_uuids:
continue

# toggle composite patch
parent = None
if shape.composite_parent:
parent = shape.composite_parent[0].parent
shape = Shape.get_by_id(parent.subtype.active_variant)
print(f"Parent found for {shape.uuid}")

layer = target_layer
if shape.layer:
Expand All @@ -425,13 +426,19 @@ async def move_shapes(sid: str, raw_data: Any):
logger.warn("Attempt to move a shape without layer info")
continue

shapes.append((shape, layer))
# Shape can be different from the one checked at the start of the loop
if shape.uuid not in shape_uuids:
shape_uuids.add(shape.uuid)
shapes.append((shape, layer))

if parent:
shapes.append((parent, layer))
if parent.uuid not in shape_uuids:
shape_uuids.add(parent.uuid)
shapes.append((parent, layer))
for csa in parent.shape_variants:
variant = csa.variant
if variant != shape:
if variant != shape and variant.uuid not in shape_uuids:
shape_uuids.add(variant.uuid)
shapes.append((variant, layer))

if old_floor:
Expand Down

0 comments on commit 2b45459

Please sign in to comment.