From cd10f94269d7dcdd93df9fcda142a1e5a4441ae9 Mon Sep 17 00:00:00 2001
From: winter
Date: Sun, 30 Mar 2025 19:00:19 +0100
Subject: implement basic interaction controls
---
templates/interaction_button.php | 22 ----------------------
templates/note/interaction_button.php | 23 +++++++++++++++++++++++
templates/note/note.php | 7 +++----
templates/note/reply_button.php | 5 +++--
templates/note/write_form.php | 30 +++++++++++++++++++++---------
5 files changed, 50 insertions(+), 37 deletions(-)
delete mode 100644 templates/interaction_button.php
create mode 100644 templates/note/interaction_button.php
(limited to 'templates')
diff --git a/templates/interaction_button.php b/templates/interaction_button.php
deleted file mode 100644
index 2b4fb82..0000000
--- a/templates/interaction_button.php
+++ /dev/null
@@ -1,22 +0,0 @@
- __('note.action.like'),
- 'dislike' => __('note.action.dislike'),
- 'reshare' => __('note.action.reshare')
-};
-$icon = match ($action) {
- 'like' => $active ? 'favorite' : 'favorite-outline',
- 'dislike' => $active ? 'heart-broken' : 'heart-broken-outline',
- 'reshare' => $active ? 'repeat-on' : 'repeat'
-};
-$id = "interactButton-$action-$note->id";
-?>
-
- id/$action" ?>" hx-swap="outerHTML"
- hx-target="closest .interactButtonContainer" hx-disabled-elt="this" id="= $id ?>"
- _="on htmx:afterOnLoad trigger update on #liveTimelineUpdater" = ($disabled ?? false) ? 'disabled' : '' ?>>
-
- = $count ?? '' ?>
-
\ No newline at end of file
diff --git a/templates/note/interaction_button.php b/templates/note/interaction_button.php
new file mode 100644
index 0000000..bfcbd85
--- /dev/null
+++ b/templates/note/interaction_button.php
@@ -0,0 +1,23 @@
+ __("note.action.like$forbidden"),
+ 'dislike' => __("note.action.dislike$forbidden"),
+ 'reshare' => __("note.action.reshare$forbidden")
+};
+$icon = match ($action) {
+ 'like' => $active ? 'favorite' : 'favorite-outline',
+ 'dislike' => $active ? 'heart-broken' : 'heart-broken-outline',
+ 'reshare' => $active ? 'repeat-on' : 'repeat'
+};
+$id = "interactButton-$action-$note->id";
+?>
+
+ id/$action" ?>" hx-swap="outerHTML"
+ hx-target="closest .interactButtonContainer" hx-disabled-elt="this" id="= $id ?>"
+ _="on htmx:afterOnLoad trigger update on #liveTimelineUpdater" = ($disabled ?? false) ? 'disabled' : '' ?>>
+
+ = $count ?? '' ?>
+
\ No newline at end of file
diff --git a/templates/note/note.php b/templates/note/note.php
index 94f4895..ddc2bac 100644
--- a/templates/note/note.php
+++ b/templates/note/note.php
@@ -11,7 +11,6 @@ $MAX_PREVIEW_CARDS = 1;
$user = UserAccount::findByCurrentSession();
$prefs = $user ? new UserSettings($user) : null;
$interKinds = [];
-$actionsDisabled = $user == null;
if ($user != null) {
$interactions = $note->getInteractionsWithAuthor($user->actor);
$interKinds = array_map(fn($inter) => $inter->kind, $interactions);
@@ -98,18 +97,18 @@ if ($user != null) {