content notification read working

This commit is contained in:
isUnknown 2024-12-19 10:32:48 +01:00
parent ffb8252808
commit 94c5737245
21 changed files with 317 additions and 163 deletions

View file

@ -24,28 +24,27 @@ return [
$comments = $file->comments()->isEmpty() == true ? [] : Yaml::decode($file->comments()->value());
$replyData = [
"location" => [
"page" => $page,
"project" => $project,
"dialogUri" => $data->dialogUri,
"file" => $file,
],
"parentId" => $data->parentId,
"position" => [
"pageIndex" => $data->position->pageIndex,
],
"date" => (string) $data->date,
"text" => $data->text,
"author" => kirby()->user(),
"id" => Str::uuid(),
"type" => "comment",
];
$newReply = new Reply($replyData);
foreach ($comments as &$comment) {
if ($comment['id'] === $newReply->parentId()) {
$isParentComment = $comment['id'] === $data->parentId;
if ($isParentComment) {
$replyData = [
"location" => [
"page" => $page,
"project" => $project,
"dialogUri" => $data->dialogUri,
"file" => $file,
"parent" => $comment
],
"position" => [
"pageIndex" => $data->position->pageIndex,
],
"date" => (string) $data->date,
"text" => $data->text,
"author" => kirby()->user(),
"id" => Str::uuid(),
"type" => "comment-reply",
];
$newReply = new Reply($replyData);
$comment['replies'][] = $newReply->toArray();
}
}