Merge pull request #15965 from overleaf/ii-ide-page-prototype-review-panel-delete-comment

[web] React ide page delete comment

GitOrigin-RevId: e9ab2afeb7e0053481ccaf3655f8f700707a24f1
This commit is contained in:
ilkin-overleaf 2023-11-29 15:42:58 +02:00 committed by Copybot
parent 75df01683b
commit 8ec2b2b42d
2 changed files with 23 additions and 3 deletions

View file

@ -820,8 +820,6 @@ function useReviewPanelState(): ReviewPanelStateReactIde {
const [submitNewComment] =
useScopeValue<ReviewPanel.UpdaterFn<'submitNewComment'>>('submitNewComment')
const [deleteComment] =
useScopeValue<ReviewPanel.UpdaterFn<'deleteComment'>>('deleteComment')
const [gotoEntry] =
useScopeValue<ReviewPanel.UpdaterFn<'gotoEntry'>>('gotoEntry')
const [submitReplyAngular] =
@ -959,6 +957,28 @@ function useReviewPanelState(): ReviewPanelStateReactIde {
[projectId]
)
const onCommentDeleted = useCallback(
(threadId: ThreadId, commentId: CommentId) => {
setCommentThreads(prevState => {
const thread = { ...getThread(threadId) }
thread.messages = thread.messages.filter(m => m.id !== commentId)
return { ...prevState, [threadId]: thread }
})
},
[getThread]
)
const deleteComment = useCallback(
(threadId: ThreadId, commentId: CommentId) => {
onCommentDeleted(threadId, commentId)
deleteJSON(
`/project/${projectId}/thread/${threadId}/messages/${commentId}`
).catch(debugConsole.error)
handleLayoutChange({ async: true })
},
[onCommentDeleted, projectId]
)
const refreshRanges = useCallback(() => {
type Doc = {
id: DocId
@ -1091,6 +1111,7 @@ function useReviewPanelState(): ReviewPanelStateReactIde {
useSocketListener(socket, 'delete-thread', onThreadDeleted)
useSocketListener(socket, 'resolve-thread', onCommentResolved)
useSocketListener(socket, 'edit-message', onCommentEdited)
useSocketListener(socket, 'delete-message', onCommentDeleted)
const values = useMemo<ReviewPanelStateReactIde['values']>(
() => ({

View file

@ -7,7 +7,6 @@ export default function populateReviewPanelScope(store: ReactScopeValueStore) {
store.set('reviewPanel.layoutToLeft', false)
store.set('reviewPanel.rendererData.lineHeight', 0)
store.set('submitNewComment', async () => {})
store.set('deleteComment', () => {})
store.set('gotoEntry', () => {})
store.set('acceptChanges', () => {})
store.set('rejectChanges', () => {})