From f2c49907a8f685deef2e293ab7ff51bcb088b115 Mon Sep 17 00:00:00 2001 From: Charles Bochet Date: Sun, 9 Jul 2023 23:14:09 -0700 Subject: [PATCH] Fix bug latency on commentThread title edition --- .../components/right-drawer/CommentThread.tsx | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/front/src/modules/comments/components/right-drawer/CommentThread.tsx b/front/src/modules/comments/components/right-drawer/CommentThread.tsx index 328c165c5..500a0e458 100644 --- a/front/src/modules/comments/components/right-drawer/CommentThread.tsx +++ b/front/src/modules/comments/components/right-drawer/CommentThread.tsx @@ -89,9 +89,8 @@ export function CommentThread({ }); const commentThread = data?.findManyCommentThreads[0]; - const [title, setTitle] = useState( - commentThread?.title, - ); + const [title, setTitle] = useState(undefined); + const [isLoading, setIsLoading] = useState(true); const [updateCommentThreadTitleMutation] = useUpdateCommentThreadTitleMutation(); @@ -120,10 +119,13 @@ export function CommentThread({ } useEffect(() => { - if (commentThread?.title) { - setTitle(commentThread.title); + if (commentThread) { + setIsLoading(false); } - }, [commentThread?.title]); + if (isLoading) { + setTitle(commentThread?.title ?? ''); + } + }, [commentThread, isLoading]); if (!commentThread) { return <>;