Browse Source

render reply button after login

imwald
Silberengel 5 days ago
parent
commit
8decbdf899
  1. 9
      src/Controller/ArticleController.php
  2. 5
      templates/components/Organisms/Comments.html.twig

9
src/Controller/ArticleController.php

@ -137,7 +137,7 @@ class ArticleController extends AbstractController @@ -137,7 +137,7 @@ class ArticleController extends AbstractController
): array {
$coordparts = explode(':', $coordinate, 3);
$articleKind = isset($coordparts[0]) && ctype_digit($coordparts[0]) ? (int) $coordparts[0] : 30023;
$articleAuthorPubkey = $coordparts[1] ?? '';
$articleAuthorPubkey = strtolower(trim((string) ($coordparts[1] ?? '')));
$articleReplyTags = null;
if ($articleAuthorPubkey !== '' && 64 === \strlen($articleAuthorPubkey) && ctype_xdigit($articleAuthorPubkey)) {
@ -162,6 +162,9 @@ class ArticleController extends AbstractController @@ -162,6 +162,9 @@ class ArticleController extends AbstractController
'authorPubkey' => $articleAuthorPubkey,
'expectedTags' => $articleReplyTags,
];
}
if ($userMayReply) {
/** @var array<int, object> $list */
$list = $data['list'] ?? [];
foreach ($list as $row) {
@ -172,8 +175,8 @@ class ArticleController extends AbstractController @@ -172,8 +175,8 @@ class ArticleController extends AbstractController
if ($k !== KindsEnum::COMMENTS->value) {
continue;
}
$cid = (string) ($row->id ?? '');
$cpk = (string) ($row->pubkey ?? '');
$cid = strtolower(trim((string) ($row->id ?? '')));
$cpk = strtolower(trim((string) ($row->pubkey ?? '')));
if ($cid === '' || 64 !== \strlen($cid) || !ctype_xdigit($cid)) {
continue;
}

5
templates/components/Organisms/Comments.html.twig

@ -1,5 +1,6 @@ @@ -1,5 +1,6 @@
{% set ctx = comment_reply_context|default(null) %}
{% if ctx and ctx.can_publish|default(false) and ctx.rows|default([])|length > 0 %}
{# `rows` can be non-empty for nested replies when the article-level NIP-22 row is missing; do not require length > 0. #}
{% if ctx and ctx.can_publish|default(false) %}
{% for row in ctx.rows %}
{% if row.mode|default('') == 'article' %}
<div
@ -59,7 +60,7 @@ @@ -59,7 +60,7 @@
<div class="comments">
{% for item in list %}
{% set cid = item.id|default('') %}
{% set cid = item.id|default('')|lower %}
{% set cpk = item.pubkey|default('') %}
{% set cts = item.created_at|default(null) %}
{% set cdepth = item.unfold_depth|default(0) %}

Loading…
Cancel
Save