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/note/interaction_button.php | 23 +++++++++++++++++++++++ templates/note/note.php | 7 +++---- templates/note/reply_button.php | 5 +++-- templates/note/write_form.php | 30 +++++++++++++++++++++--------- 4 files changed, 50 insertions(+), 15 deletions(-) create mode 100644 templates/note/interaction_button.php (limited to 'templates/note') 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"; +?> +
+ + +
\ 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) {
$action, 'note' => $note, 'active' => in_array($kind, $interKinds), 'count' => $note->countInteractionsOfKind($kind), - 'disabled' => $actionsDisabled + 'disabled' => !$note->isInteractibleBy($action, $user) ]); } call_template('note/reply_button', [ 'note' => $note, 'count' => $note->countReplies(), - 'disabled' => $actionsDisabled + 'disabled' => !$note->isInteractibleBy('reply', $user) ]); ?>
diff --git a/templates/note/reply_button.php b/templates/note/reply_button.php index de4cb1b..79267b6 100644 --- a/templates/note/reply_button.php +++ b/templates/note/reply_button.php @@ -7,10 +7,11 @@ $icon = $note->inReplyTo == null ? 'reply' : 'reply-all'; $id = "interactButton-reply-$note->id"; ?>
-
+ +
+
+ + 'lock', 'mutuals' => 'group', 'followers' => 'groups', 'public' => 'public'] as $scope => $icon): ?> + autocomplete="off"> + + +
+
+ + 'person-off', 'mutuals' => 'group', 'followers' => 'groups', 'all' => 'select-all'] as $group => $icon): ?> + autocomplete="off"> + + +
+
+
@@ -37,15 +58,6 @@
-
- - -
-- cgit v1.3