diff --git a/public/site/plugins/classes/location/Location.php b/public/site/plugins/classes/location/Location.php index c9ace9b..8c85bfd 100644 --- a/public/site/plugins/classes/location/Location.php +++ b/public/site/plugins/classes/location/Location.php @@ -46,6 +46,10 @@ class Location $array["file"] = $this->file; } + if ($this->parentCommentId) { + $array["parentId"] = $this->parentCommentId; + } + return $array; } } diff --git a/public/site/plugins/comments/routes/delete.php b/public/site/plugins/comments/routes/delete.php index 4bf55c3..b7b0895 100644 --- a/public/site/plugins/comments/routes/delete.php +++ b/public/site/plugins/comments/routes/delete.php @@ -10,13 +10,13 @@ return [ $page = page($data->location->page->uri); $project = page($data->location->project->uri); $file = $page->file($data->location->file->uuid); - $isReply = $data->parentId ?? false; + $isReply = $data->location->parentId ?? false; $comments = $file->comments()->isEmpty() == true ? [] : Yaml::decode($file->comments()->value()); foreach ($comments as $key => &$comment) { if ($isReply) { - if ($comment['id'] === $data->parentId) { + if ($comment['id'] === $data->location->parentId) { foreach ($comment['replies'] as $replyKey => $reply) { if ($reply['id'] === $data->id) { unset($comment['replies'][$replyKey]); diff --git a/public/site/plugins/comments/routes/reply.php b/public/site/plugins/comments/routes/reply.php index 383b19d..3eb04c2 100644 --- a/public/site/plugins/comments/routes/reply.php +++ b/public/site/plugins/comments/routes/reply.php @@ -22,7 +22,7 @@ return [ $user = kirby()->user($data->userUuid); - $comments = $file->comments()->isEmpty() == true ? [] : Yaml::decode($file->comments()->value()); + $comments = $file->comments()->isEmpty() == true ? [] : Yaml::decode($file->comments()->value()); $replyData = [ "location" => [ diff --git a/src/components/comments/Comment.vue b/src/components/comments/Comment.vue index 1fd5aa8..9f6db40 100644 --- a/src/components/comments/Comment.vue +++ b/src/components/comments/Comment.vue @@ -112,9 +112,10 @@ async function read() { async function deleteComment(event) { event.stopPropagation(); + console.log(comment); const newFile = await api.deleteComment(comment); dialog.updateFile(newFile); - if (comment.parentId) { + if (comment.type === "comment-reply") { emits("close:comment"); } }