delete reply working
This commit is contained in:
parent
231bb21a4f
commit
ffb8252808
4 changed files with 9 additions and 4 deletions
|
|
@ -46,6 +46,10 @@ class Location
|
||||||
$array["file"] = $this->file;
|
$array["file"] = $this->file;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ($this->parentCommentId) {
|
||||||
|
$array["parentId"] = $this->parentCommentId;
|
||||||
|
}
|
||||||
|
|
||||||
return $array;
|
return $array;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -10,13 +10,13 @@ return [
|
||||||
$page = page($data->location->page->uri);
|
$page = page($data->location->page->uri);
|
||||||
$project = page($data->location->project->uri);
|
$project = page($data->location->project->uri);
|
||||||
$file = $page->file($data->location->file->uuid);
|
$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());
|
$comments = $file->comments()->isEmpty() == true ? [] : Yaml::decode($file->comments()->value());
|
||||||
|
|
||||||
foreach ($comments as $key => &$comment) {
|
foreach ($comments as $key => &$comment) {
|
||||||
if ($isReply) {
|
if ($isReply) {
|
||||||
if ($comment['id'] === $data->parentId) {
|
if ($comment['id'] === $data->location->parentId) {
|
||||||
foreach ($comment['replies'] as $replyKey => $reply) {
|
foreach ($comment['replies'] as $replyKey => $reply) {
|
||||||
if ($reply['id'] === $data->id) {
|
if ($reply['id'] === $data->id) {
|
||||||
unset($comment['replies'][$replyKey]);
|
unset($comment['replies'][$replyKey]);
|
||||||
|
|
|
||||||
|
|
@ -112,9 +112,10 @@ async function read() {
|
||||||
|
|
||||||
async function deleteComment(event) {
|
async function deleteComment(event) {
|
||||||
event.stopPropagation();
|
event.stopPropagation();
|
||||||
|
console.log(comment);
|
||||||
const newFile = await api.deleteComment(comment);
|
const newFile = await api.deleteComment(comment);
|
||||||
dialog.updateFile(newFile);
|
dialog.updateFile(newFile);
|
||||||
if (comment.parentId) {
|
if (comment.type === "comment-reply") {
|
||||||
emits("close:comment");
|
emits("close:comment");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue