Remove posts by blocking or unfollowing
This commit is contained in:
parent
24d7f9917b
commit
4e79300232
|
@ -1,5 +1,4 @@
|
|||
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,25 +98,6 @@ export default {
|
|||
requestFollow(this.user, store).then(({sent}) => {
|
||||
this.followRequestInProgress = false
|
||||
this.followRequestSent = sent
|
||||
|
||||
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 () {
|
||||
|
@ -145,37 +125,6 @@ export default {
|
|||
store.state.api.backendInteractor.unblockUser(this.user.id)
|
||||
.then((unblockedUser) => {
|
||||
store.commit('addNewUsers', [unblockedUser])
|
||||
|
||||
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 () {
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { remove, slice, each, find, maxBy, minBy, merge, last, isArray } from 'lodash'
|
||||
import { remove, slice, each, find, maxBy, minBy, merge, first, last, isArray } from 'lodash'
|
||||
import apiService from '../services/api/api.service.js'
|
||||
// import parse from '../services/status_parser/status_parser.js'
|
||||
|
||||
|
@ -312,20 +312,8 @@ const removeStatus = (state, { timeline, userId }) => {
|
|||
if (userId) {
|
||||
remove(timelineObject.statuses, { user: { id: userId } })
|
||||
remove(timelineObject.visibleStatuses, { user: { id: userId } })
|
||||
const statusesObject = timelineObject.statusesObject
|
||||
const visibleStatusesObject = timelineObject.visibleStatusesObject
|
||||
each(statusesObject, (status, key) => {
|
||||
if (status.user.id === userId) {
|
||||
delete statusesObject[key]
|
||||
}
|
||||
})
|
||||
each(visibleStatusesObject, (status, key) => {
|
||||
if (status.user.id === userId) {
|
||||
delete visibleStatusesObject[key]
|
||||
}
|
||||
})
|
||||
timelineObject.minVisibleId = (last(timeline.visibleStatuses) || {}).id
|
||||
timelineObject.maxId = statuses.length > 0 ? maxBy(statuses, 'id').id : 0
|
||||
timelineObject.minVisibleId = timelineObject.visibleStatuses.length > 0 ? last(timelineObject.visibleStatuses).id : 0
|
||||
timelineObject.maxId = timelineObject.statuses.length > 0 ? first(timelineObject.statuses).id : 0
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -329,7 +329,7 @@ const setUserMute = ({id, credentials, muted = true}) => {
|
|||
})
|
||||
}
|
||||
|
||||
const fetchTimeline = ({timeline, credentials, since = false, until = false, between = false, count = 20, userId = false, tag = false}) => {
|
||||
const fetchTimeline = ({timeline, credentials, since = false, until = false, userId = false, tag = false}) => {
|
||||
const timelineUrls = {
|
||||
public: PUBLIC_TIMELINE_URL,
|
||||
friends: FRIENDS_TIMELINE_URL,
|
||||
|
@ -362,9 +362,7 @@ const fetchTimeline = ({timeline, credentials, since = false, until = false, bet
|
|||
if (timeline === 'media') {
|
||||
params.push(['only_media', 1])
|
||||
}
|
||||
if (!between) {
|
||||
params.push(['count', count])
|
||||
}
|
||||
params.push(['count', 20])
|
||||
|
||||
const queryString = map(params, (param) => `${param[0]}=${param[1]}`).join('&')
|
||||
url += `?${queryString}`
|
||||
|
|
Loading…
Reference in New Issue