From 25b748f04911262826d0a0bc9609e03ee47c3232 Mon Sep 17 00:00:00 2001 From: winter Date: Tue, 14 Jan 2025 18:13:57 +0000 Subject: add interaction counters --- routes/note_fragment.php | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'routes') diff --git a/routes/note_fragment.php b/routes/note_fragment.php index 53fd7af..a992a61 100644 --- a/routes/note_fragment.php +++ b/routes/note_fragment.php @@ -20,8 +20,8 @@ Router::getInstance()->mount('/fragment/note/:id/:action', function (array $args if ($interaction == null) { // we are adding a new interaction - $newint = Interaction::create($user->actor, InteractionKind::from($action), $note); - $newint->publish(); + $interaction = Interaction::create($user->actor, InteractionKind::from($action), $note); + $interaction->publish(); $active = true; } else { // we are removing the existing one @@ -29,7 +29,12 @@ Router::getInstance()->mount('/fragment/note/:id/:action', function (array $args $active = false; } - render_template('interaction_button', ['action' => $args['action'], 'active' => $active, 'note' => $note]); + render_template('interaction_button', [ + 'action' => $args['action'], + 'active' => $active, + 'note' => $note, + 'count' => $note->countInteractionsOfKind($interaction->kind) + ]); }); Router::getInstance()->mount('/fragment/note/:id/reply', function (array $args) { -- cgit v1.3