fix replies sorting
This commit is contained in:
parent
20824983a6
commit
78e2f8f956
3 changed files with 66 additions and 41 deletions
|
|
@ -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);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue