aboutsummaryrefslogtreecommitdiff
path: root/src/components/user_card_content/user_card_content.js
diff options
context:
space:
mode:
authorjasper <jasper92341@hotmail.com>2019-02-18 11:39:35 -0800
committerjasper <jasper92341@hotmail.com>2019-02-18 11:39:35 -0800
commit24d7f9917b1a4a147b92bd31ec65511c1d528c6f (patch)
tree579aa89b0ba62b40a34ccf4679200582dc61a23e /src/components/user_card_content/user_card_content.js
parent6c8ccf2733c780543a9afc5ffbe7942064ad2596 (diff)
Remove posts by blocking or following
Diffstat (limited to 'src/components/user_card_content/user_card_content.js')
-rw-r--r--src/components/user_card_content/user_card_content.js71
1 files changed, 53 insertions, 18 deletions
diff --git a/src/components/user_card_content/user_card_content.js b/src/components/user_card_content/user_card_content.js
index 41e4e817..8bc01941 100644
--- a/src/components/user_card_content/user_card_content.js
+++ b/src/components/user_card_content/user_card_content.js
@@ -1,4 +1,5 @@
import UserAvatar from '../user_avatar/user_avatar.vue'
+import apiService from '../../services/api/api.service.js'
import { hex2rgb } from '../../services/color_convert/color_convert.js'
import { requestFollow, requestUnfollow } from '../../services/follow_manipulate/follow_manipulate'
import generateProfileLink from 'src/services/user_profile_link_generator/user_profile_link_generator'
@@ -99,9 +100,24 @@ export default {
this.followRequestInProgress = false
this.followRequestSent = sent
- store.dispatch('stopFetching', 'friends')
- store.commit('clearTimeline', { timeline: 'friends' })
- store.dispatch('startFetching', { timeline: 'friends' })
+ const rootState = store.rootState || store.state
+ const credentials = store.state.users.currentUser.credentials
+ const timelineData = rootState.statuses.timelines['friends']
+ apiService.fetchTimeline({
+ store,
+ credentials,
+ userId: this.user.id,
+ timeline: 'user',
+ between: true,
+ until: timelineData.maxId,
+ since: timelineData.minVisibleId
+ }).then((statuses) => {
+ store.dispatch('addNewStatuses', {
+ timeline: 'friends',
+ statuses,
+ showImmediately: true
+ })
+ }, () => store.dispatch('setError', { value: true }))
})
},
unfollowUser () {
@@ -110,9 +126,7 @@ export default {
requestUnfollow(this.user, store).then(() => {
this.followRequestInProgress = false
- store.dispatch('stopFetching', 'friends')
- store.commit('clearTimeline', { timeline: 'friends' })
- store.dispatch('startFetching', { timeline: 'friends' })
+ store.commit('removeStatus', { timeline: 'friends', userId: this.user.id })
})
},
blockUser () {
@@ -121,12 +135,9 @@ export default {
.then((blockedUser) => {
store.commit('addNewUsers', [blockedUser])
- store.dispatch('stopFetching', 'friends')
- store.commit('clearTimeline', { timeline: 'friends' })
- store.dispatch('startFetching', { timeline: 'friends' })
-
- store.commit('clearTimeline', { timeline: 'public' })
- store.commit('clearTimeline', { timeline: 'publicAndExternal' })
+ store.commit('removeStatus', { timeline: 'friends', userId: this.user.id })
+ store.commit('removeStatus', { timeline: 'public', userId: this.user.id })
+ store.commit('removeStatus', { timeline: 'publicAndExternal', userId: this.user.id })
})
},
unblockUser () {
@@ -135,12 +146,36 @@ export default {
.then((unblockedUser) => {
store.commit('addNewUsers', [unblockedUser])
- store.dispatch('stopFetching', 'friends')
- store.commit('clearTimeline', { timeline: 'friends' })
- store.dispatch('startFetching', { timeline: 'friends' })
-
- store.commit('clearTimeline', { timeline: 'public' })
- store.commit('clearTimeline', { timeline: 'publicAndExternal' })
+ const rootState = store.rootState || store.state
+ const credentials = store.state.users.currentUser.credentials
+ const timelineData = rootState.statuses.timelines['friends']
+ apiService.fetchTimeline({
+ store,
+ credentials,
+ userId: this.user.id,
+ timeline: 'user',
+ between: true,
+ until: timelineData.maxId,
+ since: timelineData.minVisibleId
+ }).then((statuses) => {
+ store.dispatch('addNewStatuses', {
+ timeline: 'public',
+ statuses,
+ showImmediately: true
+ })
+ store.dispatch('addNewStatuses', {
+ timeline: 'publicAndExternal',
+ statuses,
+ showImmediately: true
+ })
+ if (this.user.follows_you) {
+ store.dispatch('addNewStatuses', {
+ timeline: 'friends',
+ statuses,
+ showImmediately: true
+ })
+ }
+ }, () => store.dispatch('setError', { value: true }))
})
},
toggleMute () {