delete reply working

This commit is contained in:
isUnknown 2025-01-07 15:58:52 +01:00
parent 6cc8325d2b
commit dd6eff2904
4 changed files with 6 additions and 6 deletions

View file

@ -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->location->parentId ?? false;
$isReply = $data->location->parent->id ?? false;
$comments = $file->comments()->isEmpty() == true ? [] : Yaml::decode($file->comments()->value());
foreach ($comments as $key => &$comment) {
if ($isReply) {
if ($comment['id'] === $data->location->parentId) {
if ($comment['id'] === $data->location->parent->id) {
foreach ($comment['replies'] as $replyKey => $reply) {
if ($reply['id'] === $data->id) {
unset($comment['replies'][$replyKey]);

View file

@ -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->location->parentId ?? false;
$isReply = $data->location->parent->id ?? false;
$comments = $file->comments()->isEmpty() == true ? [] : Yaml::decode($file->comments()->value());
foreach ($comments as $key => &$comment) {
if ($isReply) {
if ($comment['id'] === $data->location->parentId) {
if ($comment['id'] === $data->location->parent->id) {
foreach ($comment['replies'] as $replyKey => $reply) {
if ($reply['id'] === $data->id) {
$comment['replies'][$replyKey]["text"] = $data->text;