[COMPONENTS][Conversation] reply_add route nows shows the given Note entire conversation, the Note itself is highlighted in the conversation

This commit is contained in:
Eliseu Amaro 2021-12-30 18:34:07 +00:00
parent 34cc010136
commit 6dd31926ad
Signed by: eliseuamaro
GPG Key ID: 96DA09D4B97BC2D5
5 changed files with 18 additions and 17 deletions

View File

@ -26,10 +26,10 @@ declare(strict_types = 1);
namespace Component\Conversation\Controller; namespace Component\Conversation\Controller;
use function App\Core\I18n\_m;
use Component\Feed\Feed; use Component\Feed\Feed;
use Component\Feed\Util\FeedController; use Component\Feed\Util\FeedController;
use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Request;
use function App\Core\I18n\_m;
class Conversation extends FeedController class Conversation extends FeedController
{ {
@ -40,15 +40,6 @@ class Conversation extends FeedController
*/ */
public function showConversation(Request $request, int $conversation_id) 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); $data = Feed::query(query: "note-conversation:{$conversation_id}", page: $this->int('p') ?? 1);
$notes = $data['notes']; $notes = $data['notes'];
return [ return [

View File

@ -32,8 +32,10 @@ use App\Util\Exception\ClientException;
use App\Util\Exception\NoLoggedInUser; use App\Util\Exception\NoLoggedInUser;
use App\Util\Exception\NoSuchNoteException; use App\Util\Exception\NoSuchNoteException;
use App\Util\Exception\ServerException; use App\Util\Exception\ServerException;
use Component\Feed\Feed;
use Component\Feed\Util\FeedController; use Component\Feed\Util\FeedController;
use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Request;
use function App\Core\I18n\_m;
class Reply extends FeedController class Reply extends FeedController
{ {
@ -56,9 +58,14 @@ class Reply extends FeedController
throw new NoSuchNoteException(); throw new NoSuchNoteException();
} }
$conversation_id = $note->getConversationId();
$data = Feed::query(query: "note-conversation:{$conversation_id}", page: $this->int('p') ?? 1);
$notes = $data['notes'];
return [ return [
'_template' => 'reply/add_reply.html.twig', '_template' => 'feed/feed.html.twig',
'note' => $note, 'notes' => $notes,
'should_format' => false,
'page_title' => _m('Conversation'),
]; ];
} }
} }

View File

@ -26,17 +26,16 @@ namespace Component\Conversation;
use App\Core\Cache; use App\Core\Cache;
use App\Core\DB\DB; use App\Core\DB\DB;
use App\Core\Event; use App\Core\Event;
use function App\Core\I18n\_m;
use App\Core\Modules\Component; use App\Core\Modules\Component;
use App\Core\Router\RouteLoader; use App\Core\Router\RouteLoader;
use App\Core\Router\Router; use App\Core\Router\Router;
use App\Entity\Actor; use App\Entity\Actor;
use App\Entity\Note; use App\Entity\Note;
use App\Util\Common; use App\Util\Common;
use App\Util\Formatting;
use Component\Conversation\Controller\Reply as ReplyController; use Component\Conversation\Controller\Reply as ReplyController;
use Component\Conversation\Entity\Conversation as ConversationEntity; use Component\Conversation\Entity\Conversation as ConversationEntity;
use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Request;
use function App\Core\I18n\_m;
class Conversation extends Component class Conversation extends Component
{ {
@ -92,7 +91,7 @@ class Conversation extends Component
$query_string = $request->getQueryString(); $query_string = $request->getQueryString();
// Concatenating get parameter to redirect the user to where he came from // 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 = [ $reply_action = [
'url' => $reply_action_url, 'url' => $reply_action_url,

View File

@ -14,6 +14,9 @@
.notes hr { .notes hr {
margin-top: var(--s); margin-top: var(--s);
} }
article[id^="note-anchor-"]:target {
border: 2px solid var(--accent) !important;
}
.note-wrapper { .note-wrapper {
width: 100%; width: 100%;
height: inherit; height: inherit;
@ -106,7 +109,7 @@
embed header { embed header {
display: flex; display: flex;
border-bottom: unset; border-bottom: unset;
border-radius: var(--s) var(--s) 0 0; border-radius: 0 var(--s) 0 0;
line-height: initial; line-height: initial;
padding: 8px var(--s) 8px 0; padding: 8px var(--s) 8px 0;
} }

View File

@ -159,7 +159,8 @@
{% set mention = mention(actor) %} {% set mention = mention(actor) %}
{% set note_language = note.getNoteLanguageShortDisplay() %} {% set note_language = note.getNoteLanguageShortDisplay() %}
<article class="h-entry hentry note" lang={{ note.getLanguageLocale() }}> <article id="{{ 'note-anchor-' ~ note.getId() }}"
class="h-entry hentry note" lang={{ note.getLanguageLocale() }}>
{{ block('note_sidebar') }} {{ block('note_sidebar') }}
<div class="note-wrapper"> <div class="note-wrapper">
{{ block('note_info') }} {{ block('note_info') }}