[PLUGIN][TreeNotes] Correct cache issues and iterate functionality
- Replies ordering now correct - Replies count added - Posting adds new replies to cache (when concerning replies cache is not empty) and increments replies count - Configuration to specify number of in-tree replies shown added - TreeNotes templates was moved from core to plugin - Button to read more replies was added
This commit is contained in:
@@ -39,7 +39,10 @@
|
||||
{% for conversation in notes %}
|
||||
{% block current_note %}
|
||||
{% if conversation is instanceof('array') %}
|
||||
{% set args = { 'type': 'vanilla_full', 'note': conversation['note'], 'replies': conversation['replies'] | default, 'extra': { 'depth': 0 } } %}
|
||||
{% set args = {
|
||||
'type': 'vanilla_full',
|
||||
'conversation': conversation
|
||||
} %}
|
||||
{{ NoteFactory.constructor(args) }}
|
||||
{# {% else %}
|
||||
{% set args = { 'type': 'vanilla_full', 'note': conversation, 'extra': { 'depth': 0 } } %}
|
||||
|
@@ -24,6 +24,7 @@ declare(strict_types = 1);
|
||||
namespace Component\Posting;
|
||||
|
||||
use App\Core\ActorLocalRoles;
|
||||
use App\Core\Cache;
|
||||
use App\Core\DB\DB;
|
||||
use App\Core\Event;
|
||||
use App\Core\Form;
|
||||
@@ -332,6 +333,14 @@ class Posting extends Component
|
||||
DB::persist($note);
|
||||
Conversation::assignLocalConversation($note, $reply_to_id);
|
||||
|
||||
// Update replies cache
|
||||
if (!\is_null($reply_to_id)) {
|
||||
Cache::incr(Note::cacheKeys($reply_to_id)['replies-count']);
|
||||
if (Cache::exists(Note::cacheKeys($reply_to_id)['replies'])) {
|
||||
Cache::listPushRight(Note::cacheKeys($reply_to_id)['replies'], $note);
|
||||
}
|
||||
}
|
||||
|
||||
// Need file and note ids for the next step
|
||||
$note->setUrl(Router::url('note_view', ['id' => $note->getId()], Router::ABSOLUTE_URL));
|
||||
if (!empty($content)) {
|
||||
@@ -373,7 +382,7 @@ class Posting extends Component
|
||||
$activity,
|
||||
[
|
||||
'note-attention' => $attention_ids,
|
||||
'object' => F\unique(F\flat_map($mentions, fn (array $m) => F\map($m['mentioned'] ?? [], fn (Actor $a) => $a->getId()))),
|
||||
'object' => F\unique(F\flat_map($mentions, fn (array $m) => F\map($m['mentioned'] ?? [], fn (Actor $a) => $a->getId()))),
|
||||
],
|
||||
_m('{nickname} created a note {note_id}.', [
|
||||
'{nickname}' => $actor->getNickname(),
|
||||
|
Reference in New Issue
Block a user