Skip to content

The open alternative to Salesforce, designed for AI.

Fix bug latency on commentThread title edition

Charles Bochetf2c49907a8f6
diff --git a/front/src/modules/comments/components/right-drawer/CommentThread.tsx b/front/src/modules/comments/components/right-drawer/CommentThread.tsx
index 328c165c54e..500a0e458e9 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<string | null | undefined>(
- commentThread?.title,
- );
+ const [title, setTitle] = useState<string | null | undefined>(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);
+ }
+ if (isLoading) {
+ setTitle(commentThread?.title ?? '');
}
- }, [commentThread?.title]);
+ }, [commentThread, isLoading]);
if (!commentThread) {
return <></>;