mirror of
https://github.com/yu-i-i/overleaf-cep.git
synced 2026-05-23 17:19:37 +02:00
Add "new-comment-threads" event handler for new review panel (#23298)
GitOrigin-RevId: 00628e6421a563f5157415d235ee5e7c2818e690
This commit is contained in:
committed by
Copybot
parent
6ee3ff63e4
commit
6d45fea773
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user