From f2c95f9d0bcb9fd6640d8c5d38ce6fff111b70df Mon Sep 17 00:00:00 2001 From: jared Date: Mon, 15 Apr 2019 11:42:56 -0400 Subject: [PATCH 01/26] #482 - add new endpoints to subscribe to the user --- src/services/api/api.service.js | 12 ++++++++++++ .../backend_interactor_service.js | 4 ++++ 2 files changed, 16 insertions(+) diff --git a/src/services/api/api.service.js b/src/services/api/api.service.js index 304fc869..e417cf29 100644 --- a/src/services/api/api.service.js +++ b/src/services/api/api.service.js @@ -55,6 +55,8 @@ const MASTODON_BLOCK_USER_URL = id => `/api/v1/accounts/${id}/block` const MASTODON_UNBLOCK_USER_URL = id => `/api/v1/accounts/${id}/unblock` const MASTODON_MUTE_USER_URL = id => `/api/v1/accounts/${id}/mute` const MASTODON_UNMUTE_USER_URL = id => `/api/v1/accounts/${id}/unmute` +const MASTODON_SUBSCRIBE_USER = id => `/api/v1/pleroma/accounts/${id}/subscribe` +const MASTODON_UNSUBSCRIBE_USER = id => `/api/v1/pleroma/accounts/${id}/unsubscribe` const MASTODON_POST_STATUS_URL = '/api/v1/statuses' const MASTODON_MEDIA_UPLOAD_URL = '/api/v1/media' const MASTODON_VOTE_URL = id => `/api/v1/polls/${id}/votes` @@ -752,6 +754,14 @@ const unmuteUser = ({ id, credentials }) => { return promisedRequest({ url: MASTODON_UNMUTE_USER_URL(id), credentials, method: 'POST' }) } +const subscribeUser = ({ id, credentials }) => { + return promisedRequest({ url: MASTODON_SUBSCRIBE_USER(id), credentials, method: 'POST' }) +} + +const unsubscribeUser = ({ id, credentials }) => { + return promisedRequest({ url: MASTODON_UNSUBSCRIBE_USER(id), credentials, method: 'POST' }) +} + const fetchBlocks = ({ credentials }) => { return promisedRequest({ url: MASTODON_USER_BLOCKS_URL, credentials }) .then((users) => users.map(parseUser)) @@ -882,6 +892,8 @@ const apiService = { fetchMutes, muteUser, unmuteUser, + subscribeUser, + unsubscribeUser, fetchBlocks, fetchOAuthTokens, revokeOAuthToken, diff --git a/src/services/backend_interactor_service/backend_interactor_service.js b/src/services/backend_interactor_service/backend_interactor_service.js index 5162d38f..4e1675c2 100644 --- a/src/services/backend_interactor_service/backend_interactor_service.js +++ b/src/services/backend_interactor_service/backend_interactor_service.js @@ -108,6 +108,8 @@ const backendInteractorService = credentials => { const fetchMutes = () => apiService.fetchMutes({ credentials }) const muteUser = (id) => apiService.muteUser({ credentials, id }) const unmuteUser = (id) => apiService.unmuteUser({ credentials, id }) + const subscribeUser = (id) => apiService.subscribeUser({ credentials, id }) + const unsubscribeUser = (id) => apiService.unsubscribeUser({ credentials, id }) const fetchBlocks = () => apiService.fetchBlocks({ credentials }) const fetchFollowRequests = () => apiService.fetchFollowRequests({ credentials }) const fetchOAuthTokens = () => apiService.fetchOAuthTokens({ credentials }) @@ -167,6 +169,8 @@ const backendInteractorService = credentials => { fetchMutes, muteUser, unmuteUser, + subscribeUser, + unsubscribeUser, fetchBlocks, fetchOAuthTokens, revokeOAuthToken, From d5e8315e83327c7b8dda71eca5dd1c9d7d0a23dc Mon Sep 17 00:00:00 2001 From: jared Date: Tue, 16 Apr 2019 10:13:26 -0400 Subject: [PATCH 02/26] #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 } }) }, From 4cf402ff21c26fa9b82d2ea956ceb7ce8533146a Mon Sep 17 00:00:00 2001 From: taehoon Date: Thu, 25 Apr 2019 04:19:22 -0400 Subject: [PATCH 03/26] migrate SubscribeButton to the existing common component --- .../subscribe_button/subscribe_button.js | 26 ------------------- .../subscribe_button/subscribe_button.vue | 22 ---------------- src/components/user_card/user_card.js | 10 +++++-- src/components/user_card/user_card.vue | 9 ++++++- 4 files changed, 16 insertions(+), 51 deletions(-) delete mode 100644 src/components/subscribe_button/subscribe_button.js delete 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 deleted file mode 100644 index e3a2842c..00000000 --- a/src/components/subscribe_button/subscribe_button.js +++ /dev/null @@ -1,26 +0,0 @@ -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 deleted file mode 100644 index f7dd8c61..00000000 --- a/src/components/subscribe_button/subscribe_button.vue +++ /dev/null @@ -1,22 +0,0 @@ - - - diff --git a/src/components/user_card/user_card.js b/src/components/user_card/user_card.js index bab1a654..d7fe71d0 100644 --- a/src/components/user_card/user_card.js +++ b/src/components/user_card/user_card.js @@ -1,6 +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 ProgressButton from '../progress_button/progress_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' @@ -106,7 +106,7 @@ export default { UserAvatar, RemoteFollow, ModerationTools, - SubscribeButton + ProgressButton }, methods: { followUser () { @@ -137,6 +137,12 @@ export default { unmuteUser () { this.$store.dispatch('unmuteUser', this.user.id) }, + subscribeUser () { + return this.$store.state.api.backendInteractor.subscribeUser(this.user.id) + }, + unsubscribeUser () { + return this.$store.state.api.backendInteractor.unsubscribeUser(this.user.id) + }, setProfileView (v) { if (this.switcher) { const store = this.$store diff --git a/src/components/user_card/user_card.vue b/src/components/user_card/user_card.vue index 18ec6e94..e1d3f48f 100644 --- a/src/components/user_card/user_card.vue +++ b/src/components/user_card/user_card.vue @@ -72,7 +72,14 @@ - +
+ + Subscribe + + + Subscribing! + +