aboutsummaryrefslogtreecommitdiffhomepage
path: root/templates
diff options
context:
space:
mode:
authorwinter2025-01-13 18:06:05 +0000
committerwinter2025-01-13 18:06:05 +0000
commitfb9efd9f4682f528b1832622d192b9b5544584a9 (patch)
tree5d55870b8bb8910183fc7b35220e9ae3f83999d3 /templates
parent765bf9729cc31b7ff552922c6363373f218c1f24 (diff)
make the interaction buttons actually work
Diffstat (limited to 'templates')
-rw-r--r--templates/note.php17
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>