diff --git a/packages/app/src/app/overmind/effects/fakeGql/comments/mutations.ts b/packages/app/src/app/overmind/effects/fakeGql/comments/mutations.ts index 45cc81b4032..bce979a3081 100644 --- a/packages/app/src/app/overmind/effects/fakeGql/comments/mutations.ts +++ b/packages/app/src/app/overmind/effects/fakeGql/comments/mutations.ts @@ -137,7 +137,11 @@ export const updateReply: Query< UpdateReplyResponse, UpdateReplyVariables > = gql` - mutation updateReply($replyId: String!, $commentId: String!) { + mutation updateReply( + $replyId: String! + $commentId: String! + $comment: String! + ) { updateReply(replyId: $replyId, commentId: $commentId, comment: $comment) { id replies { diff --git a/packages/app/src/app/overmind/namespaces/editor/actions.ts b/packages/app/src/app/overmind/namespaces/editor/actions.ts index 354a777f909..5626e129b53 100755 --- a/packages/app/src/app/overmind/namespaces/editor/actions.ts +++ b/packages/app/src/app/overmind/namespaces/editor/actions.ts @@ -1479,7 +1479,7 @@ export const updateComment: AsyncAction<{ id: string; data: { comment?: string; - isResolved: boolean; + isResolved?: boolean; }; }> = async ({ effects, state }, { id, data }) => { if (!state.editor.currentSandbox) { @@ -1493,7 +1493,7 @@ export const updateComment: AsyncAction<{ currentComment && state.editor.comments[sandboxId][id].id === currentComment.id; - if ('isResolved' in data) { + if ('isResolved' in data && data.isResolved) { state.editor.comments[sandboxId][id].isResolved = data.isResolved; if (updateIsCurrent && currentComment) { currentComment.isResolved = data.isResolved; @@ -1587,9 +1587,12 @@ export const updateReply: AsyncAction<{ }); } catch (error) { effects.notificationToast.error( - 'Unable to update your comment, please try again' + 'Unable to update your reply, please try again' ); - state.editor.comments[sandboxId][commentId] = old; + state.editor.comments[sandboxId][commentId] = { + ...old, + replies: old.replies, + }; } }; diff --git a/packages/app/src/app/pages/Sandbox/Editor/Workspace/screens/Comments/Dialog/Comment.tsx b/packages/app/src/app/pages/Sandbox/Editor/Workspace/screens/Comments/Dialog/Markdown.tsx similarity index 98% rename from packages/app/src/app/pages/Sandbox/Editor/Workspace/screens/Comments/Dialog/Comment.tsx rename to packages/app/src/app/pages/Sandbox/Editor/Workspace/screens/Comments/Dialog/Markdown.tsx index 56f256a499b..a867c01fab3 100644 --- a/packages/app/src/app/pages/Sandbox/Editor/Workspace/screens/Comments/Dialog/Comment.tsx +++ b/packages/app/src/app/pages/Sandbox/Editor/Workspace/screens/Comments/Dialog/Markdown.tsx @@ -5,7 +5,7 @@ import { Text, Element, Link } from '@codesandbox/components'; import css from '@styled-system/css'; import { Code } from './Code'; -export const Comment = ({ source }) => { +export const Markdown = ({ source }) => { const { state } = useOvermind(); const privateSandbox = state.editor.currentSandbox.privacy === 1 || diff --git a/packages/app/src/app/pages/Sandbox/Editor/Workspace/screens/Comments/Dialog/Reply.tsx b/packages/app/src/app/pages/Sandbox/Editor/Workspace/screens/Comments/Dialog/Reply.tsx index e34be7fb94d..cabd11fa96b 100644 --- a/packages/app/src/app/pages/Sandbox/Editor/Workspace/screens/Comments/Dialog/Reply.tsx +++ b/packages/app/src/app/pages/Sandbox/Editor/Workspace/screens/Comments/Dialog/Reply.tsx @@ -1,16 +1,18 @@ -import React from 'react'; +import React, { useState } from 'react'; import { formatDistance } from 'date-fns'; import css from '@styled-system/css'; import { Element, + Button, Stack, Avatar, Text, Link, Menu, + Textarea, } from '@codesandbox/components'; import { useOvermind } from 'app/overmind'; -import { Comment } from './Comment'; +import { Markdown } from './Markdown'; type ReplyProps = { id: string; @@ -28,6 +30,8 @@ export const Reply = ({ content, }: ReplyProps) => { const { state, actions } = useOvermind(); + const [edit, setEdit] = useState(false); + const [value, setValue] = useState(content); return ( <> @@ -65,7 +69,9 @@ export const Reply = ({ > Delete - Edit + setEdit(true)}> + Edit Reply + @@ -73,7 +79,7 @@ export const Reply = ({ - + {!edit ? ( + + ) : ( + <> + +