diff options
Diffstat (limited to 'templates/note.php')
| -rw-r--r-- | templates/note.php | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/templates/note.php b/templates/note.php index 83770aa..fdc0dc8 100644 --- a/templates/note.php +++ b/templates/note.php @@ -1,3 +1,14 @@ +<?php +use Digitigrade\Model\InteractionKind; +use Digitigrade\Model\UserAccount; + +$user = UserAccount::findByCurrentSession(); +$interKinds = []; +if ($user != null) { + $interactions = $note->getInteractionsWithAuthor($user->actor); + $interKinds = array_map(fn($inter) => $inter->kind, $interactions); +} +?> <article class="note"> <a href="/@/<?= $note->author->getFullHandle() ?>"> <?php call_template('actor_avatar', ['actor' => $note->author]); ?> @@ -21,7 +32,11 @@ </div> <div class="buttons"> <?php foreach (['like', 'dislike', 'reshare'] as $action) { - render_template('interaction_button', ['action' => $action, 'note' => $note]); + render_template('interaction_button', [ + 'action' => $action, + 'note' => $note, + 'active' => in_array(InteractionKind::from($action), $interKinds) + ]); } ?> </div> </div> |
