From 12d8d1711bb41b14c35914cb82a6d5f41943e198 Mon Sep 17 00:00:00 2001
From: Sean King <seanking2919@protonmail.com>
Date: Thu, 15 Sep 2022 22:02:58 -0600
Subject: Added support for removing users from followers

---
 src/components/account_actions/account_actions.vue | 7 +++++++
 1 file changed, 7 insertions(+)

(limited to 'src/components/account_actions/account_actions.vue')

diff --git a/src/components/account_actions/account_actions.vue b/src/components/account_actions/account_actions.vue
index 770740e0..9bcde9fe 100644
--- a/src/components/account_actions/account_actions.vue
+++ b/src/components/account_actions/account_actions.vue
@@ -29,6 +29,13 @@
             />
           </template>
           <UserListMenu :user="user" />
+          <button
+            v-if="relationship.followed_by"
+            class="btn button-default btn-block dropdown-item"
+            @click="removeUserFromFollowers"
+          >
+            {{ $t('user_card.remove_this_follower') }}
+          </button>
           <button
             v-if="relationship.blocking"
             class="btn button-default btn-block dropdown-item"
-- 
cgit v1.2.3-70-g09d2


From 3c707608ce828a2221e496df48bd2b3f9aecd5d4 Mon Sep 17 00:00:00 2001
From: Sean King <seanking2919@protonmail.com>
Date: Sat, 17 Sep 2022 11:36:34 -0600
Subject: Change "Remove this follower" to "Remove Follower" and add a button
 to remove a follower in the followers tab for the logged in user

---
 src/components/account_actions/account_actions.vue |  2 +-
 src/components/follow_card/follow_card.js          |  4 +++-
 src/components/follow_card/follow_card.vue         | 11 ++++++++++
 .../remove_follower_button.js                      | 25 ++++++++++++++++++++++
 .../remove_follower_button.vue                     | 13 +++++++++++
 src/i18n/en.json                                   |  2 +-
 6 files changed, 54 insertions(+), 3 deletions(-)
 create mode 100644 src/components/remove_follower_button/remove_follower_button.js
 create mode 100644 src/components/remove_follower_button/remove_follower_button.vue

(limited to 'src/components/account_actions/account_actions.vue')

diff --git a/src/components/account_actions/account_actions.vue b/src/components/account_actions/account_actions.vue
index 9bcde9fe..218aa6b3 100644
--- a/src/components/account_actions/account_actions.vue
+++ b/src/components/account_actions/account_actions.vue
@@ -34,7 +34,7 @@
             class="btn button-default btn-block dropdown-item"
             @click="removeUserFromFollowers"
           >
-            {{ $t('user_card.remove_this_follower') }}
+            {{ $t('user_card.remove_follower') }}
           </button>
           <button
             v-if="relationship.blocking"
diff --git a/src/components/follow_card/follow_card.js b/src/components/follow_card/follow_card.js
index 6dcb6d47..b26b27a7 100644
--- a/src/components/follow_card/follow_card.js
+++ b/src/components/follow_card/follow_card.js
@@ -1,6 +1,7 @@
 import BasicUserCard from '../basic_user_card/basic_user_card.vue'
 import RemoteFollow from '../remote_follow/remote_follow.vue'
 import FollowButton from '../follow_button/follow_button.vue'
+import RemoveFollowerButton from '../remove_follower_button/remove_follower_button.vue'
 
 const FollowCard = {
   props: [
@@ -10,7 +11,8 @@ const FollowCard = {
   components: {
     BasicUserCard,
     RemoteFollow,
-    FollowButton
+    FollowButton,
+    RemoveFollowerButton
   },
   computed: {
     isMe () {
diff --git a/src/components/follow_card/follow_card.vue b/src/components/follow_card/follow_card.vue
index 895a8fa3..c919b11a 100644
--- a/src/components/follow_card/follow_card.vue
+++ b/src/components/follow_card/follow_card.vue
@@ -22,6 +22,11 @@
           class="follow-card-follow-button"
           :user="user"
         />
+        <RemoveFollowerButton
+          v-if="noFollowsYou && relationship.followed_by"
+          :relationship="relationship"
+          class="follow-card-button"
+        />
       </template>
     </div>
   </basic-user-card>
@@ -40,6 +45,12 @@
     line-height: 1.5em;
   }
 
+  &-button {
+    margin-top: 0.5em;
+    padding: 0 1.5em;
+    margin-left: 1em;
+  }
+
   &-follow-button {
     margin-top: 0.5em;
     margin-left: auto;
diff --git a/src/components/remove_follower_button/remove_follower_button.js b/src/components/remove_follower_button/remove_follower_button.js
new file mode 100644
index 00000000..e1a7531b
--- /dev/null
+++ b/src/components/remove_follower_button/remove_follower_button.js
@@ -0,0 +1,25 @@
+export default {
+  props: ['relationship'],
+  data () {
+    return {
+      inProgress: false
+    }
+  },
+  computed: {
+    label () {
+      if (this.inProgress) {
+        return this.$t('user_card.follow_progress')
+      } else {
+        return this.$t('user_card.remove_follower')
+      }
+    }
+  },
+  methods: {
+    onClick () {
+      this.inProgress = true
+      this.$store.dispatch('removeUserFromFollowers', this.relationship.id).then(() => {
+        this.inProgress = false
+      })
+    }
+  }
+}
diff --git a/src/components/remove_follower_button/remove_follower_button.vue b/src/components/remove_follower_button/remove_follower_button.vue
new file mode 100644
index 00000000..a3a4c242
--- /dev/null
+++ b/src/components/remove_follower_button/remove_follower_button.vue
@@ -0,0 +1,13 @@
+<template>
+  <button
+    class="btn button-default follow-button"
+    :class="{ toggled: inProgress }"
+    :disabled="inProgress"
+    :title="$t('user_card.remove_follower')"
+    @click="onClick"
+  >
+    {{ label }}
+  </button>
+</template>
+
+<script src="./remove_follower_button.js"></script>
diff --git a/src/i18n/en.json b/src/i18n/en.json
index ae63f6e6..22ec42a9 100644
--- a/src/i18n/en.json
+++ b/src/i18n/en.json
@@ -878,7 +878,7 @@
     "muted": "Muted",
     "per_day": "per day",
     "remote_follow": "Remote follow",
-    "remove_this_follower": "Remove this follower",
+    "remove_follower": "Remove follower",
     "report": "Report",
     "statuses": "Statuses",
     "subscribe": "Subscribe",
-- 
cgit v1.2.3-70-g09d2

