Add "new-comment-threads" event handler for new review panel (#23298)

GitOrigin-RevId: 00628e6421a563f5157415d235ee5e7c2818e690
This commit is contained in:
Domagoj Kriskovic
2025-02-04 14:41:02 +01:00
committed by Copybot
parent 6ee3ff63e4
commit 6d45fea773

View File

@@ -211,6 +211,34 @@ export const ThreadsProvider: FC = ({ children }) => {
}, [])
)
useSocketListener(
socket,
'new-comment-threads',
useCallback(threads => {
setData(prevState => {
const newThreads = { ...prevState }
for (const threadId of Object.keys(threads)) {
const thread = threads[threadId]
const newThreadData: ReviewPanelCommentThread = {
messages: [],
resolved: thread.resolved,
resolved_at: thread.resolved_at,
resolved_by_user_id: thread.resolved_by_user_id,
resolved_by_user: thread.resolved_by_user,
}
for (const message of thread.messages) {
newThreadData.messages.push({
...message,
timestamp: new Date(message.timestamp),
})
}
newThreads[threadId as ThreadId] = newThreadData
}
return newThreads
})
}, [])
)
const actions = useMemo(
() => ({
async addComment(pos: number, text: string, content: string) {