From 6dd31926adc27e3a941c67d97c41f94f77695b4c Mon Sep 17 00:00:00 2001 From: Eliseu Amaro Date: Thu, 30 Dec 2021 18:34:07 +0000 Subject: [PATCH] [COMPONENTS][Conversation] reply_add route nows shows the given Note entire conversation, the Note itself is highlighted in the conversation --- components/Conversation/Controller/Conversation.php | 11 +---------- components/Conversation/Controller/Reply.php | 11 +++++++++-- components/Conversation/Conversation.php | 5 ++--- public/assets/default_theme/css/pages/feeds.css | 5 ++++- templates/cards/note/view.html.twig | 3 ++- 5 files changed, 18 insertions(+), 17 deletions(-) diff --git a/components/Conversation/Controller/Conversation.php b/components/Conversation/Controller/Conversation.php index a115247785..51936e15bc 100644 --- a/components/Conversation/Controller/Conversation.php +++ b/components/Conversation/Controller/Conversation.php @@ -26,10 +26,10 @@ declare(strict_types = 1); namespace Component\Conversation\Controller; -use function App\Core\I18n\_m; use Component\Feed\Feed; use Component\Feed\Util\FeedController; use Symfony\Component\HttpFoundation\Request; +use function App\Core\I18n\_m; class Conversation extends FeedController { @@ -40,15 +40,6 @@ class Conversation extends FeedController */ public function showConversation(Request $request, int $conversation_id) { - // TODO: - // if note is root -> just link - // if note is a reply -> link from above plus anchor - - /* $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 [ diff --git a/components/Conversation/Controller/Reply.php b/components/Conversation/Controller/Reply.php index 7d322e5759..63a4a7049a 100644 --- a/components/Conversation/Controller/Reply.php +++ b/components/Conversation/Controller/Reply.php @@ -32,8 +32,10 @@ use App\Util\Exception\ClientException; use App\Util\Exception\NoLoggedInUser; use App\Util\Exception\NoSuchNoteException; use App\Util\Exception\ServerException; +use Component\Feed\Feed; use Component\Feed\Util\FeedController; use Symfony\Component\HttpFoundation\Request; +use function App\Core\I18n\_m; class Reply extends FeedController { @@ -56,9 +58,14 @@ class Reply extends FeedController throw new NoSuchNoteException(); } + $conversation_id = $note->getConversationId(); + $data = Feed::query(query: "note-conversation:{$conversation_id}", page: $this->int('p') ?? 1); + $notes = $data['notes']; return [ - '_template' => 'reply/add_reply.html.twig', - 'note' => $note, + '_template' => 'feed/feed.html.twig', + 'notes' => $notes, + 'should_format' => false, + 'page_title' => _m('Conversation'), ]; } } diff --git a/components/Conversation/Conversation.php b/components/Conversation/Conversation.php index 86c7502209..c6beb0fb79 100644 --- a/components/Conversation/Conversation.php +++ b/components/Conversation/Conversation.php @@ -26,17 +26,16 @@ namespace Component\Conversation; use App\Core\Cache; use App\Core\DB\DB; use App\Core\Event; -use function App\Core\I18n\_m; use App\Core\Modules\Component; use App\Core\Router\RouteLoader; use App\Core\Router\Router; use App\Entity\Actor; use App\Entity\Note; use App\Util\Common; -use App\Util\Formatting; use Component\Conversation\Controller\Reply as ReplyController; use Component\Conversation\Entity\Conversation as ConversationEntity; use Symfony\Component\HttpFoundation\Request; +use function App\Core\I18n\_m; class Conversation extends Component { @@ -92,7 +91,7 @@ class Conversation extends Component $query_string = $request->getQueryString(); // Concatenating get parameter to redirect the user to where he came from - $reply_action_url .= '?from=' . urlencode($request->getRequestUri()); + $reply_action_url .= '?from=' . urlencode($request->getRequestUri()) . '#note-anchor-' . $note->getId(); $reply_action = [ 'url' => $reply_action_url, diff --git a/public/assets/default_theme/css/pages/feeds.css b/public/assets/default_theme/css/pages/feeds.css index 994654c5b0..3e3701a346 100644 --- a/public/assets/default_theme/css/pages/feeds.css +++ b/public/assets/default_theme/css/pages/feeds.css @@ -14,6 +14,9 @@ .notes hr { margin-top: var(--s); } +article[id^="note-anchor-"]:target { + border: 2px solid var(--accent) !important; +} .note-wrapper { width: 100%; height: inherit; @@ -106,7 +109,7 @@ embed header { display: flex; border-bottom: unset; - border-radius: var(--s) var(--s) 0 0; + border-radius: 0 var(--s) 0 0; line-height: initial; padding: 8px var(--s) 8px 0; } diff --git a/templates/cards/note/view.html.twig b/templates/cards/note/view.html.twig index ab81d93c0a..551284e541 100644 --- a/templates/cards/note/view.html.twig +++ b/templates/cards/note/view.html.twig @@ -159,7 +159,8 @@ {% set mention = mention(actor) %} {% set note_language = note.getNoteLanguageShortDisplay() %} -
+
{{ block('note_sidebar') }}
{{ block('note_info') }}