[COMPONENTS][Conversation] Refactored Reply plugin into Conversation component

[PLUGIN][TreeNotes] TODO: think it is broken, perhaps a problem of the conversation arguments passed in note card template
This commit is contained in:
2021-12-08 22:44:04 +00:00
parent e9dfa0f08c
commit df92b0d225
5 changed files with 42 additions and 162 deletions

View File

@@ -23,7 +23,7 @@ namespace Plugin\TreeNotes;
use App\Core\Modules\Plugin;
use App\Entity\Note;
use Plugin\Reply\Entity\NoteReply;
use Component\Reply\Entity\NoteReply;
class TreeNotes extends Plugin
{
@@ -32,7 +32,7 @@ class TreeNotes extends Plugin
*/
public function onFormatNoteList(array $notes_in, ?array &$notes_out)
{
$roots = array_filter($notes_in, fn (Note $note) => \is_null(NoteReply::getReplyToNote($note)));
$roots = array_filter($notes_in, fn (Note $note) => \is_null($note->getReplyTo()));
$notes_out = $this->build_tree($roots, $notes_in);
}
@@ -47,7 +47,7 @@ class TreeNotes extends Plugin
private function build_subtree(Note $parent, array $notes)
{
$children = array_filter($notes, fn (Note $note) => $parent->getId() === NoteReply::getReplyToNote($note));
$children = array_filter($notes, fn (Note $note) => $parent->getId() === $note->getReplyTo());
return ['note' => $parent, 'replies' => $this->build_tree($children, $notes)];
}
}