From dd6eff290408b6f5cbb0bff46dc8a9729d6fda7e Mon Sep 17 00:00:00 2001
From: isUnknown
Date: Tue, 7 Jan 2025 15:58:52 +0100
Subject: [PATCH 1/2] delete reply working
---
public/site/plugins/comments/routes/delete.php | 4 ++--
public/site/plugins/comments/routes/update.php | 4 ++--
src/components/comments/Comment.vue | 2 +-
src/components/comments/Comments.vue | 2 +-
4 files changed, 6 insertions(+), 6 deletions(-)
diff --git a/public/site/plugins/comments/routes/delete.php b/public/site/plugins/comments/routes/delete.php
index b7b0895..f9dae6e 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->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]);
diff --git a/public/site/plugins/comments/routes/update.php b/public/site/plugins/comments/routes/update.php
index ca875d4..4622ff2 100644
--- a/public/site/plugins/comments/routes/update.php
+++ b/public/site/plugins/comments/routes/update.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->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;
diff --git a/src/components/comments/Comment.vue b/src/components/comments/Comment.vue
index 6b83e23..9e7fc57 100644
--- a/src/components/comments/Comment.vue
+++ b/src/components/comments/Comment.vue
@@ -141,7 +141,7 @@ async function deleteComment(event) {
// If there is an active track,
// it's not the opened file that should be updated
// but the corresponding file in the active track
- if (activeTracks.value.length > 0) {
+ if (activeTracks.value?.length > 0) {
activeTracks.value[0].files = activeTracks.value[0].files.map((file) => {
if (file.uuid !== newFile.uuid) return file;
return newFile;
diff --git a/src/components/comments/Comments.vue b/src/components/comments/Comments.vue
index 4af34b1..ac33402 100644
--- a/src/components/comments/Comments.vue
+++ b/src/components/comments/Comments.vue
@@ -308,7 +308,7 @@ function openComment(comment) {
openedComment.value = comment;
- if (activeTracks?.value.length === 1) {
+ if (activeTracks.value?.length === 1) {
openedFile.value = activeTracks.value[0].files.find(
(file) => file.uuid === openedComment.value.location.file.uuid
);
From 12562ed8da63df4fea8613bbd064936d20623158 Mon Sep 17 00:00:00 2001
From: isUnknown
Date: Tue, 7 Jan 2025 16:05:10 +0100
Subject: [PATCH 2/2] #88 - fix edit comment system
---
src/components/comments/Comment.vue | 12 ++++++------
src/components/comments/Comments.vue | 7 ++++---
src/stores/dialog.js | 2 --
3 files changed, 10 insertions(+), 11 deletions(-)
diff --git a/src/components/comments/Comment.vue b/src/components/comments/Comment.vue
index 9e7fc57..84f189e 100644
--- a/src/components/comments/Comment.vue
+++ b/src/components/comments/Comment.vue
@@ -21,13 +21,13 @@
-
+
{{ comment.text }}
-