fix replies sorting

This commit is contained in:
isUnknown 2024-10-30 13:29:26 +01:00
parent 20824983a6
commit 78e2f8f956
3 changed files with 66 additions and 41 deletions

View file

@ -22,7 +22,7 @@ return [
'file' => $file,
'filePageIndex' => $data->filePageIndex,
'text' => $data->text,
'user' => $user,
'author' => $user,
'date' => (string) $data->date,
'id' => $data->id,
'type' => 'comment'
@ -30,13 +30,17 @@ return [
$newReply = new Reply($data);
$comments[$newReply->parentId()]['replies'][$newReply->id()] = $newReply->toArray();
foreach ($comments as &$comment) {
if ($comment['id'] === $newReply->parentId()) {
$comment['replies'][] = $newReply->toArray();
}
}
$newFile = $file->update([
'comments' => $comments
]);
$user->sendNotification('comments', $newReply->toArray());
$user->sendNotification($newReply);
return getFileData($newFile);
}