From 62287fffae456164f52c3ebcaf2062445e549745 Mon Sep 17 00:00:00 2001 From: FloatingGhost Date: Sun, 1 Jan 2023 21:05:25 +0000 Subject: [PATCH] add follow/unfollow to followed tags list --- .../followed_tag_card/FollowedTagCard.vue | 64 +++++++++++++++++-- src/components/user_profile/user_profile.js | 4 ++ src/components/user_profile/user_profile.vue | 7 +- src/hocs/with_load_more/with_load_more.jsx | 2 +- src/i18n/en.json | 4 ++ src/modules/tags.js | 21 ++++-- src/modules/users.js | 14 +--- 7 files changed, 86 insertions(+), 30 deletions(-) diff --git a/src/components/followed_tag_card/FollowedTagCard.vue b/src/components/followed_tag_card/FollowedTagCard.vue index 3ce5d8e9..d9394ddc 100644 --- a/src/components/followed_tag_card/FollowedTagCard.vue +++ b/src/components/followed_tag_card/FollowedTagCard.vue @@ -1,10 +1,28 @@ @@ -15,13 +33,45 @@ export default { tag: { type: Object, required: true - } + }, }, + // this is a hack to update the state of the button + // for some reason, List does not update on changes to the tag object + data: () => ({ + isFollowing: true + }), + mounted () { + this.isFollowing = this.tag.following + }, + methods: { + unfollowTag (tag) { + this.$store.dispatch('unfollowTag', tag) + this.isFollowing = false + }, + followTag (tag) { + this.$store.dispatch('followTag', tag) + this.isFollowing = true + } + } } diff --git a/src/components/user_profile/user_profile.js b/src/components/user_profile/user_profile.js index 702148c1..1cadddda 100644 --- a/src/components/user_profile/user_profile.js +++ b/src/components/user_profile/user_profile.js @@ -52,6 +52,7 @@ const UserProfile = { error: false, userId: null, tab: 'statuses', + followsTab: 'users', footerRef: null, note: null, noteLoading: false @@ -176,6 +177,9 @@ const UserProfile = { this.tab = tab this.$router.replace({ hash: `#${tab}` }) }, + onFollowsTabSwitch (tab) { + this.followsTab = tab + }, linkClicked ({ target }) { if (target.tagName === 'SPAN') { target = target.parentNode diff --git a/src/components/user_profile/user_profile.vue b/src/components/user_profile/user_profile.vue index e657b8a4..5465778a 100644 --- a/src/components/user_profile/user_profile.vue +++ b/src/components/user_profile/user_profile.vue @@ -106,8 +106,9 @@ :label="$t('user_card.followees')" >
+
diff --git a/src/hocs/with_load_more/with_load_more.jsx b/src/hocs/with_load_more/with_load_more.jsx index 7960663b..c55eccf5 100644 --- a/src/hocs/with_load_more/with_load_more.jsx +++ b/src/hocs/with_load_more/with_load_more.jsx @@ -89,7 +89,7 @@ const withLoadMore = ({ const children = this.$slots return (
- + {children}