From e04d927fe934a7862c0dffc9ffa2ba68ac8c01e6 Mon Sep 17 00:00:00 2001 From: Diogo Peralta Cordeiro Date: Thu, 23 Dec 2021 16:18:46 +0000 Subject: [PATCH] [COMPONENT][Feed][Conversation] Add note-conversation: --- components/Conversation/Controller/Conversation.php | 12 ++++++++---- components/Feed/Feed.php | 3 +++ 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/components/Conversation/Controller/Conversation.php b/components/Conversation/Controller/Conversation.php index 974a47fae4..a115247785 100644 --- a/components/Conversation/Controller/Conversation.php +++ b/components/Conversation/Controller/Conversation.php @@ -26,8 +26,8 @@ declare(strict_types = 1); namespace Component\Conversation\Controller; -use App\Core\DB\DB; use function App\Core\I18n\_m; +use Component\Feed\Feed; use Component\Feed\Util\FeedController; use Symfony\Component\HttpFoundation\Request; @@ -44,9 +44,13 @@ class Conversation extends FeedController // if note is root -> just link // if note is a reply -> link from above plus anchor - $notes = DB::dql('select n from App\Entity\Note n ' - . 'on n.conversation_id = :id ' - . 'order by n.created DESC', ['id' => $conversation_id], ); + /* $notes = DB::findBy( + table: 'note', + criteria: ['conversation_id' => $conversation_id], + order_by: ['created' => 'DESC', 'id' => 'DESC'] + );*/ + $data = Feed::query(query: "note-conversation:{$conversation_id}", page: $this->int('p') ?? 1); + $notes = $data['notes']; return [ '_template' => 'feed/feed.html.twig', 'notes' => $notes, diff --git a/components/Feed/Feed.php b/components/Feed/Feed.php index 962076b136..ad1c044ab1 100644 --- a/components/Feed/Feed.php +++ b/components/Feed/Feed.php @@ -87,6 +87,9 @@ class Feed extends Component $note_expr[] = $eb->eq('note.content', null); } break; + case 'note-conversation': + $note_expr = $eb->eq('note.conversation_id', (int)trim($term[1])); + break; } } elseif (Formatting::startsWith($term, 'actor-')) { switch ($term[0]) {