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); $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->location->parentId ?? false; $isReply = $data->location->parent->id ?? 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->location->parentId) { if ($comment['id'] === $data->location->parent->id) {
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]);

View file

@ -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->location->parentId ?? false; $isReply = $data->location->parent->id ?? 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->location->parentId) { if ($comment['id'] === $data->location->parent->id) {
foreach ($comment['replies'] as $replyKey => $reply) { foreach ($comment['replies'] as $replyKey => $reply) {
if ($reply['id'] === $data->id) { if ($reply['id'] === $data->id) {
$comment['replies'][$replyKey]["text"] = $data->text; $comment['replies'][$replyKey]["text"] = $data->text;

View file

@ -141,7 +141,7 @@ async function deleteComment(event) {
// If there is an active track, // If there is an active track,
// it's not the opened file that should be updated // it's not the opened file that should be updated
// but the corresponding file in the active track // 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) => { activeTracks.value[0].files = activeTracks.value[0].files.map((file) => {
if (file.uuid !== newFile.uuid) return file; if (file.uuid !== newFile.uuid) return file;
return newFile; return newFile;

View file

@ -308,7 +308,7 @@ function openComment(comment) {
openedComment.value = comment; openedComment.value = comment;
if (activeTracks?.value.length === 1) { if (activeTracks.value?.length === 1) {
openedFile.value = activeTracks.value[0].files.find( openedFile.value = activeTracks.value[0].files.find(
(file) => file.uuid === openedComment.value.location.file.uuid (file) => file.uuid === openedComment.value.location.file.uuid
); );