From d5e8315e83327c7b8dda71eca5dd1c9d7d0a23dc Mon Sep 17 00:00:00 2001 From: jared Date: Tue, 16 Apr 2019 10:13:26 -0400 Subject: [PATCH] #482 - add subscribe button --- .../subscribe_button/subscribe_button.js | 26 ++ .../subscribe_button/subscribe_button.vue | 22 ++ src/components/user_card/user_card.js | 4 +- src/components/user_card/user_card.vue | 369 ++++++------------ src/modules/users.js | 1 + 5 files changed, 174 insertions(+), 248 deletions(-) create mode 100644 src/components/subscribe_button/subscribe_button.js create mode 100644 src/components/subscribe_button/subscribe_button.vue diff --git a/src/components/subscribe_button/subscribe_button.js b/src/components/subscribe_button/subscribe_button.js new file mode 100644 index 00000000..e3a2842c --- /dev/null +++ b/src/components/subscribe_button/subscribe_button.js @@ -0,0 +1,26 @@ +export default { + props: [ 'user' ], + data () { + return { + inProgress: false + } + }, + methods: { + subscribe () { + this.inProgress = true + this.$store.state.api.backendInteractor.subscribeUser(this.user.id) + .then((updated) => { + console.log(updated) + this.inProgress = false + }) + }, + unsubscribe () { + this.inProgress = true + this.$store.state.api.backendInteractor.unsubscribeUser(this.user.id) + .then((updated) => { + console.log(updated) + this.inProgress = false + }) + } + } +} diff --git a/src/components/subscribe_button/subscribe_button.vue b/src/components/subscribe_button/subscribe_button.vue new file mode 100644 index 00000000..f7dd8c61 --- /dev/null +++ b/src/components/subscribe_button/subscribe_button.vue @@ -0,0 +1,22 @@ + + + diff --git a/src/components/user_card/user_card.js b/src/components/user_card/user_card.js index 92cd0e54..bab1a654 100644 --- a/src/components/user_card/user_card.js +++ b/src/components/user_card/user_card.js @@ -1,5 +1,6 @@ import UserAvatar from '../user_avatar/user_avatar.vue' import RemoteFollow from '../remote_follow/remote_follow.vue' +import SubscribeButton from '../subscribe_button/subscribe_button.vue' import ModerationTools from '../moderation_tools/moderation_tools.vue' import { hex2rgb } from '../../services/color_convert/color_convert.js' import { requestFollow, requestUnfollow } from '../../services/follow_manipulate/follow_manipulate' @@ -104,7 +105,8 @@ export default { components: { UserAvatar, RemoteFollow, - ModerationTools + ModerationTools, + SubscribeButton }, methods: { followUser () { diff --git a/src/components/user_card/user_card.vue b/src/components/user_card/user_card.vue index 5a5a4881..18ec6e94 100644 --- a/src/components/user_card/user_card.vue +++ b/src/components/user_card/user_card.vue @@ -1,260 +1,135 @@ diff --git a/src/modules/users.js b/src/modules/users.js index 453a6899..f9b609b4 100644 --- a/src/modules/users.js +++ b/src/modules/users.js @@ -135,6 +135,7 @@ export const mutations = { user.following = relationship.following user.muted = relationship.muting user.statusnet_blocking = relationship.blocking + user.subscribing = relationship.subscribing } }) },