Skip to content

Commit 7a77151

Browse files
committed
feat: make sync for topic area more ux friendly
1 parent 0fd92f6 commit 7a77151

1 file changed

Lines changed: 9 additions & 4 deletions

File tree

web/src/components/topicArea.tsx

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,6 @@ export default function TopicArea({ topic, isReadOnly }: { topic: string, isRead
2020
}
2121
debounceRef.current = setTimeout(() => {
2222
setRoomTopic({ topic: localTopic })
23-
.then(() => {
24-
setLocalTopic(undefined)
25-
})
2623
.catch((error) => {
2724
console.error(error)
2825
})
@@ -37,9 +34,17 @@ export default function TopicArea({ topic, isReadOnly }: { topic: string, isRead
3734
}
3835
}, [localTopic, isReadOnly, setRoomTopic])
3936

37+
useEffect(() => {
38+
// If topic has been updated and it matchs localtopic, reset localtopic to default
39+
// If not matching, the user is still editing
40+
if (topic == localTopic) {
41+
setLocalTopic(undefined)
42+
}
43+
}, [topic])
44+
4045
function handleTopicChange(e: React.ChangeEvent<HTMLTextAreaElement>) {
4146
setLocalTopic(e.target.value)
4247
}
4348

4449
return <TextArea value={localTopic ?? topic} onChange={handleTopicChange} readOnly={isReadOnly} fullWidth={true} className={cn("text-xs sm:text-base !h-full", isReadOnly && "!bg-transparent")} inert={isReadOnly} />
45-
}
50+
}

0 commit comments

Comments
 (0)