diff --git a/src/client/app/desktop/views/components/follow-button.vue b/src/client/app/desktop/views/components/follow-button.vue
index dae760495..c7549c374 100644
--- a/src/client/app/desktop/views/components/follow-button.vue
+++ b/src/client/app/desktop/views/components/follow-button.vue
@@ -1,19 +1,16 @@
@@ -34,6 +31,7 @@ export default Vue.extend({
data() {
return {
+ u: this.user,
wait: false,
connection: null,
connectionId: null
@@ -56,39 +54,44 @@ export default Vue.extend({
methods: {
onFollow(user) {
- if (user.id == this.user.id) {
+ if (user.id == this.u.id) {
this.user.isFollowing = user.isFollowing;
}
},
onUnfollow(user) {
- if (user.id == this.user.id) {
+ if (user.id == this.u.id) {
this.user.isFollowing = user.isFollowing;
}
},
- onClick() {
+ async onClick() {
this.wait = true;
- if (this.user.isFollowing) {
- (this as any).api('following/delete', {
- userId: this.user.id
- }).then(() => {
- this.user.isFollowing = false;
- }).catch(err => {
- console.error(err);
- }).then(() => {
- this.wait = false;
- });
- } else {
- (this as any).api('following/create', {
- userId: this.user.id
- }).then(() => {
- this.user.isFollowing = true;
- }).catch(err => {
- console.error(err);
- }).then(() => {
- this.wait = false;
- });
+
+ try {
+ if (this.u.isFollowing) {
+ this.u = await (this as any).api('following/delete', {
+ userId: this.u.id
+ });
+ } else {
+ if (this.u.isLocked && this.u.hasPendingFollowRequestFromYou) {
+ this.u = await (this as any).api('following/requests/cancel', {
+ userId: this.u.id
+ });
+ } else if (this.u.isLocked) {
+ this.u = await (this as any).api('following/create', {
+ userId: this.u.id
+ });
+ } else {
+ this.u = await (this as any).api('following/create', {
+ userId: this.user.id
+ });
+ }
+ }
+ } catch (e) {
+ console.error(e);
+ } finally {
+ this.wait = false;
}
}
}
@@ -124,7 +127,7 @@ root(isDark)
border 2px solid rgba($theme-color, 0.3)
border-radius 8px
- &.follow
+ &:not(.active)
color isDark ? #fff : #888
background isDark ? linear-gradient(to bottom, #313543 0%, #282c37 100%) : linear-gradient(to bottom, #ffffff 0%, #f5f5f5 100%)
border solid 1px isDark ? #1c2023 : #e2e2e2
@@ -137,7 +140,7 @@ root(isDark)
background isDark ? #22262f : #ececec
border-color isDark ? #151a1d : #dcdcdc
- &.unfollow
+ &.active
color $theme-color-foreground
background linear-gradient(to bottom, lighten($theme-color, 25%) 0%, lighten($theme-color, 10%) 100%)
border solid 1px lighten($theme-color, 15%)
@@ -162,9 +165,6 @@ root(isDark)
height 38px
line-height 38px
- i
- margin-right 8px
-
.mk-follow-button[data-darkmode]
root(true)
diff --git a/src/client/app/mobile/views/components/follow-button.vue b/src/client/app/mobile/views/components/follow-button.vue
index a247db95f..d8441a20b 100644
--- a/src/client/app/mobile/views/components/follow-button.vue
+++ b/src/client/app/mobile/views/components/follow-button.vue
@@ -1,6 +1,6 @@