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();
}
}

View file

@ -6,7 +6,6 @@ use adrienpayet\D2P\data\Author;
use adrienpayet\D2P\data\Position;
class BaseComment {
protected string $type;
protected Location $location;
protected Author $author;
protected string $text;

View file

@ -7,11 +7,6 @@ class Reply extends BaseComment {
public function __construct($data) {
parent::__construct($data);
$this->location->setParentCommentId($data["parentId"]);
}
public function parentId() {
return $this->location->parentId();
}
public function toArray() {