diff --git a/src/components/editor/BasketCourt.tsx b/src/components/editor/BasketCourt.tsx
index 25b53b5..4f4c216 100644
--- a/src/components/editor/BasketCourt.tsx
+++ b/src/components/editor/BasketCourt.tsx
@@ -1,10 +1,4 @@
-import {
- ReactElement,
- ReactNode,
- RefObject,
- useLayoutEffect,
- useState,
-} from "react"
+import { ReactElement, ReactNode, RefObject } from "react"
import { Action } from "../../model/tactic/Action"
import { CourtAction } from "./CourtAction.tsx"
@@ -36,14 +30,6 @@ export function BasketCourt({
courtImage,
courtRef,
}: BasketCourtProps) {
- const [forceEmptyComponents, setForceEmptyComponents] = useState(true)
-
- useLayoutEffect(() => {
- setForceEmptyComponents(false)
- }, [setForceEmptyComponents])
-
- const usedComponents = forceEmptyComponents ? [] : components
-
return (
{courtImage}
- {usedComponents.map(renderComponent)}
- {usedComponents.flatMap(renderActions)}
+ {courtRef.current && components.map(renderComponent)}
+ {courtRef.current && components.flatMap(renderActions)}
{previewAction && (
(pathItems[targetIdx - 1], components)
- return result
+ return targetIdx == 0
+ ? playerOrigin
+ : getComponent(pathItems[targetIdx - 1], components)
}
//FIXME this function can be a bottleneck if the phantom's position is
@@ -219,22 +217,20 @@ export function removePlayer(
-1,
content.components,
)!
- const actionIdx = playerBefore.actions.findIndex(
+ const actions = playerBefore.actions.filter(
(a) => a.target === pos.attach,
)
content = updateComponent(
{
...playerBefore,
- actions: playerBefore.actions.toSpliced(actionIdx, 1),
+ actions,
},
content,
)
}
const origin = getOrigin(player, content.components)
- content = truncatePlayerPath(origin, player, content)
- console.log(content)
- return content
+ return truncatePlayerPath(origin, player, content)
}
content = clearPlayerPath(player, content)