refactor: rearrange early return for better readability in CommentInstance

This commit is contained in:
Vishnu 2025-05-22 15:58:09 +05:30
parent 6524d77490
commit ae7f33c485
1 changed files with 5 additions and 4 deletions

View File

@ -10,8 +10,7 @@ function CommentInstance({ comment }: { comment: CommentSchema }) {
const [selectedComment, setSelectedComment] = useState<CommentSchema | null>(null);
const [transformMode, setTransformMode] = useState<"translate" | "rotate" | null>(null);
if (comment.state === 'inactive' || isPlaying) return null;
useEffect(() => {
const handleKeyDown = (e: KeyboardEvent) => {
const keyCombination = detectModifierKeys(e);
@ -23,11 +22,13 @@ function CommentInstance({ comment }: { comment: CommentSchema }) {
setTransformMode((prev) => (prev === "rotate" ? null : "rotate"));
}
};
window.addEventListener("keydown", handleKeyDown);
return () => window.removeEventListener("keydown", handleKeyDown);
}, [selectedComment]);
if (comment.state === 'inactive' || isPlaying) return null;
return (
<>