aboutsummaryrefslogtreecommitdiffhomepage
path: root/templates/actor_profile_follow_button.php
diff options
context:
space:
mode:
authorwinter2025-01-14 20:44:49 +0000
committerwinter2025-01-14 20:44:49 +0000
commit4d7f8450d9a842e2f69754ccaa4202710328dcb7 (patch)
tree60e90ff7ebbf069e04faf665d68861970eaee000 /templates/actor_profile_follow_button.php
parent0f427b4b6f75134b2c25b7e5f8a515be2cec97f5 (diff)
add (un)follow button to profile
also other stuff i forgot what exactly
Diffstat (limited to 'templates/actor_profile_follow_button.php')
-rw-r--r--templates/actor_profile_follow_button.php20
1 files changed, 20 insertions, 0 deletions
diff --git a/templates/actor_profile_follow_button.php b/templates/actor_profile_follow_button.php
new file mode 100644
index 0000000..e2b314d
--- /dev/null
+++ b/templates/actor_profile_follow_button.php
@@ -0,0 +1,20 @@
+<?php
+use Digitigrade\Model\FollowRelation;
+use Digitigrade\Model\FollowRelationStatus;
+
+$relation = FollowRelation::findByActors($user->actor, $actor);
+$state = match ($relation?->status) {
+ null => $actor->requestToFollow ? 'request' : 'normal',
+ FollowRelationStatus::PENDING => 'pending',
+ FollowRelationStatus::ACTIVE => 'active'
+};
+?>
+<button class="<?= $state == 'active' ? 'secondary' : 'primary' ?>"
+ hx-post="/fragment/actor/<?= $actor->id ?>/followButton" hx-swap="outerHTML" <?= $state == 'pending' ? 'disabled' : '' ?> hx-disabled-elt="this">
+ <?= __(match ($state) {
+ 'active' => 'user.profile.unfollow.action',
+ 'pending' => 'user.profile.follow.pending',
+ 'request' => 'user.profile.requestToFollow.action',
+ 'normal' => 'user.profile.follow.action'
+ }) ?>
+</button> \ No newline at end of file