forked from GNUsocial/gnu-social
[UI][NOTE] Add reply to in UI
This commit is contained in:
parent
3affbc3c78
commit
7a68ba4f05
@ -215,7 +215,21 @@ class Note extends Entity
|
||||
|
||||
public function getReplies(): array
|
||||
{
|
||||
return Cache::getList('note-replies-' . $this->id, function () { return DB::dql('select n from App\Entity\Note n where n.reply_to = :id', ['id' => $this->id]); });
|
||||
return Cache::getList('note-replies-' . $this->id, function () {
|
||||
return DB::dql('select n from App\Entity\Note n where n.reply_to = :id', ['id' => $this->id]);
|
||||
});
|
||||
}
|
||||
|
||||
public function getReplyToNickname(): ?string
|
||||
{
|
||||
if (!empty($this->reply_to)) {
|
||||
return Cache::get('note-reply-to-' . $this->id, function () {
|
||||
return DB::dql('select g from App\Entity\Note n join ' .
|
||||
'App\Entity\GSActor g with n.gsactor_id = g.id where n.reply_to = :reply',
|
||||
['reply' => $this->reply_to])[0]->getNickname();
|
||||
});
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static function schemaDef(): array
|
||||
|
@ -1,9 +1,14 @@
|
||||
<div class="note">
|
||||
<div class="note-info">
|
||||
{% set nickname = note.getActorNickname() %}
|
||||
<a href="{{ path('settings_avatar') }}">
|
||||
<img src="{{ note.getAvatarUrl() }}" alt="{{ note.getActorNickname() }}'s avatar">
|
||||
<img src="{{ note.getAvatarUrl() }}" alt="{{ nickname }}'s avatar">
|
||||
</a>
|
||||
<b>{{ note.getActorNickname() }}</b>
|
||||
<b>{{ nickname }}</b>
|
||||
{% set reply_to = note.getReplyToNickname() %}
|
||||
{% if reply_to is not null and not skip_reply_to is defined %}
|
||||
{% trans with {'%name%': reply_to}%} in reply to %name% {% endtrans %}
|
||||
{% endif %}
|
||||
</div>
|
||||
<div class="note-content">
|
||||
{{ note.getContent() }}
|
||||
@ -41,7 +46,7 @@
|
||||
</div>
|
||||
<div class="replies">
|
||||
{% for reply in note.getReplies() %}
|
||||
{% include '/note/view.html.twig' with {'note': reply} only %}
|
||||
{% include '/note/view.html.twig' with {'note': reply, 'skip_reply_to': true} only %}
|
||||
{% endfor %}
|
||||
</div>
|
||||
</div>
|
||||
|
Loading…
Reference in New Issue
Block a user