From 302310a653083bc82226cf0743d52fc02c277a8a Mon Sep 17 00:00:00 2001 From: taehoon Date: Fri, 1 Mar 2019 11:37:34 -0500 Subject: [PATCH] Remove old muting logic --- src/components/mute_card/mute_card.js | 2 +- src/components/user_card/user_card.js | 10 ++-------- src/modules/users.js | 12 +++++++++--- src/services/api/api.service.js | 18 ------------------ .../backend_interactor_service.js | 5 ----- 5 files changed, 12 insertions(+), 35 deletions(-) diff --git a/src/components/mute_card/mute_card.js b/src/components/mute_card/mute_card.js index 5ef17b60..65c9cfb5 100644 --- a/src/components/mute_card/mute_card.js +++ b/src/components/mute_card/mute_card.js @@ -12,7 +12,7 @@ const MuteCard = { return this.$store.getters.findUser(this.userId) }, muted () { - return this.user.mastodonMuted + return this.user.muted } }, components: { diff --git a/src/components/user_card/user_card.js b/src/components/user_card/user_card.js index 61b784fe..197c61d5 100644 --- a/src/components/user_card/user_card.js +++ b/src/components/user_card/user_card.js @@ -126,18 +126,12 @@ export default { unblockUser () { this.$store.dispatch('unblockUser', this.user.id) }, - muteUser () { // Mastodon Mute + muteUser () { this.$store.dispatch('muteUser', this.user.id) }, - unmuteUser () { // Mastodon Unmute + unmuteUser () { this.$store.dispatch('unmuteUser', this.user.id) }, - toggleMute () { - // TODO: Pleroma mute/unmute, Need to migrate to the Mastodon API - const store = this.$store - store.commit('setMuted', {user: this.user, muted: !this.user.muted}) - store.state.api.backendInteractor.setUserMute(this.user) - }, setProfileView (v) { if (this.switcher) { const store = this.$store diff --git a/src/modules/users.js b/src/modules/users.js index af40be3d..5e53aafb 100644 --- a/src/modules/users.js +++ b/src/modules/users.js @@ -110,11 +110,11 @@ export const mutations = { }, muteUser (state, id) { const user = state.usersObject[id] - set(user, 'mastodonMuted', true) + set(user, 'muted', true) }, unmuteUser (state, id) { const user = state.usersObject[id] - set(user, 'mastodonMuted', false) + set(user, 'muted', false) }, setUserForStatus (state, status) { status.user = state.usersObject[status.user.id] @@ -206,9 +206,10 @@ const users = { return Promise.all(promises) }) .then((mutedUsers) => { - each(mutedUsers, (user) => { user.mastodonMuted = true }) + each(mutedUsers, (user) => { user.muted = true }) store.commit('addNewUsers', mutedUsers) store.commit('saveMutes', map(mutedUsers, 'id')) + // TODO: Unset muted property of the rest users }) }, muteUser (store, id) { @@ -368,6 +369,11 @@ const users = { // Start getting fresh posts. store.dispatch('startFetching', { timeline: 'friends' }) + // Fetch mutes + // TODO: We should not show timeline until fetchMutes is resolved + // However, we can get rid of this logic totally if we can know user muted state from user object + store.dispatch('fetchMutes') + // Fetch our friends store.rootState.api.backendInteractor.fetchFriends({ id: user.id }) .then((friends) => commit('addNewUsers', friends)) diff --git a/src/services/api/api.service.js b/src/services/api/api.service.js index 92abf94b..7da2758a 100644 --- a/src/services/api/api.service.js +++ b/src/services/api/api.service.js @@ -26,7 +26,6 @@ const MUTING_URL = '/api/v1/accounts/:id/mute' const UNMUTING_URL = '/api/v1/accounts/:id/unmute' const FOLLOWING_URL = '/api/friendships/create.json' const UNFOLLOWING_URL = '/api/friendships/destroy.json' -const QVITTER_USER_PREF_URL = '/api/qvitter/set_profile_pref.json' const REGISTRATION_URL = '/api/account/register.json' const AVATAR_UPDATE_URL = '/api/qvitter/update_avatar.json' const BG_UPDATE_URL = '/api/qvitter/update_background_image.json' @@ -343,22 +342,6 @@ const fetchStatus = ({id, credentials}) => { .then((data) => parseStatus(data)) } -const setUserMute = ({id, credentials, muted = true}) => { - const form = new FormData() - - const muteInteger = muted ? 1 : 0 - - form.append('namespace', 'qvitter') - form.append('data', muteInteger) - form.append('topic', `mute:${id}`) - - return fetch(QVITTER_USER_PREF_URL, { - method: 'POST', - headers: authHeaders(credentials), - body: form - }) -} - const fetchTimeline = ({timeline, credentials, since = false, until = false, userId = false, tag = false}) => { const timelineUrls = { public: PUBLIC_TIMELINE_URL, @@ -652,7 +635,6 @@ const apiService = { deleteStatus, uploadMedia, fetchAllFollowing, - setUserMute, fetchMutes, muteUser, unmuteUser, diff --git a/src/services/backend_interactor_service/backend_interactor_service.js b/src/services/backend_interactor_service/backend_interactor_service.js index 674fb4a4..0f0bcddc 100644 --- a/src/services/backend_interactor_service/backend_interactor_service.js +++ b/src/services/backend_interactor_service/backend_interactor_service.js @@ -62,10 +62,6 @@ const backendInteractorService = (credentials) => { return timelineFetcherService.startFetching({timeline, store, credentials, userId, tag}) } - const setUserMute = ({id, muted = true}) => { - return apiService.setUserMute({id, muted, credentials}) - } - const fetchMutes = () => apiService.fetchMutes({credentials}) const muteUser = (id) => apiService.muteUser({credentials, id}) const unmuteUser = (id) => apiService.unmuteUser({credentials, id}) @@ -102,7 +98,6 @@ const backendInteractorService = (credentials) => { fetchAllFollowing, verifyCredentials: apiService.verifyCredentials, startFetching, - setUserMute, fetchMutes, muteUser, unmuteUser,