diff --git a/assets/styles/03-components/article.css b/assets/styles/03-components/article.css index 0691f43..70b0c61 100644 --- a/assets/styles/03-components/article.css +++ b/assets/styles/03-components/article.css @@ -165,5 +165,5 @@ article .card { .comments { display: flex; flex-direction: column; - gap: var(--spacing-1); + gap: var(--spacing-2); } diff --git a/src/Twig/Components/Organisms/Comments.php b/src/Twig/Components/Organisms/Comments.php index 48ecec1..67f5c4a 100644 --- a/src/Twig/Components/Organisms/Comments.php +++ b/src/Twig/Components/Organisms/Comments.php @@ -4,6 +4,7 @@ namespace App\Twig\Components\Organisms; use App\Service\NostrClient; use App\Service\NostrLinkParser; +use App\Service\RedisCacheService; use Symfony\UX\TwigComponent\Attribute\AsTwigComponent; #[AsTwigComponent] @@ -14,10 +15,12 @@ final class Comments public array $processedContent = []; public array $zapAmounts = []; public array $zappers = []; + public array $authorsMetadata = []; public function __construct( private readonly NostrClient $nostrClient, - private readonly NostrLinkParser $nostrLinkParser + private readonly NostrLinkParser $nostrLinkParser, + private readonly RedisCacheService $redisCacheService ) { } @@ -35,6 +38,17 @@ final class Comments $this->parseNostrLinks(); // Parse Zaps to get amounts and zappers from receipts $this->parseZaps(); + // Collect all unique pubkeys for batch metadata fetching + $pubkeys = []; + foreach ($this->list as $comment) { + if ($comment->kind != 9735) { + $pubkeys[] = $comment->pubkey; + } elseif (isset($this->zappers[$comment->id])) { + $pubkeys[] = $this->zappers[$comment->id]; + } + } + $pubkeys = array_unique($pubkeys); + $this->authorsMetadata = $this->redisCacheService->getMultipleMetadata($pubkeys); } /** diff --git a/templates/components/Organisms/Comments.html.twig b/templates/components/Organisms/Comments.html.twig index ccf7741..46aadb8 100644 --- a/templates/components/Organisms/Comments.html.twig +++ b/templates/components/Organisms/Comments.html.twig @@ -2,15 +2,13 @@ {% for item in list %}
{% if item.kind != '9735' %} -
+
{% elseif zappers[item.id] %}
-
+
{% else %}
- Unknown
+
Unknown
{% endif %} - {{ item.created_at|date('F j Y') }}