remove pinned timeline, instead, use simple entity of user object

This commit is contained in:
taehoon 2019-04-24 13:56:53 -04:00
parent 9e22d6212a
commit cd0a7afa06
8 changed files with 36 additions and 23 deletions

View file

@ -11,8 +11,7 @@ const Timeline = {
'userId', 'userId',
'tag', 'tag',
'embedded', 'embedded',
'count', 'count'
'noLoadMore'
], ],
data () { data () {
return { return {

View file

@ -21,12 +21,11 @@
class="status-fadein" class="status-fadein"
:key="status.id" :key="status.id"
:statusoid="status" :statusoid="status"
:pinned="timelineName === 'pinned'"
:collapsable="true" :collapsable="true"
/> />
</div> </div>
</div> </div>
<div :class="classes.footer" v-if="!noLoadMore"> <div :class="classes.footer">
<div v-if="count===0" class="new-status-notification text-center panel-footer faint"> <div v-if="count===0" class="new-status-notification text-center panel-footer faint">
{{$t('timeline.no_statuses')}} {{$t('timeline.no_statuses')}}
</div> </div>

View file

@ -2,6 +2,7 @@ import get from 'lodash/get'
import UserCard from '../user_card/user_card.vue' import UserCard from '../user_card/user_card.vue'
import FollowCard from '../follow_card/follow_card.vue' import FollowCard from '../follow_card/follow_card.vue'
import Timeline from '../timeline/timeline.vue' import Timeline from '../timeline/timeline.vue'
import Conversation from '../conversation/conversation.vue'
import ModerationTools from '../moderation_tools/moderation_tools.vue' import ModerationTools from '../moderation_tools/moderation_tools.vue'
import List from '../list/list.vue' import List from '../list/list.vue'
import withLoadMore from '../../hocs/with_load_more/with_load_more' import withLoadMore from '../../hocs/with_load_more/with_load_more'
@ -40,9 +41,6 @@ const UserProfile = {
timeline () { timeline () {
return this.$store.state.statuses.timelines.user return this.$store.state.statuses.timelines.user
}, },
pinned () {
return this.$store.state.statuses.timelines.pinned
},
favorites () { favorites () {
return this.$store.state.statuses.timelines.favorites return this.$store.state.statuses.timelines.favorites
}, },
@ -56,6 +54,9 @@ const UserProfile = {
user () { user () {
return this.$store.getters.findUser(this.userId) return this.$store.getters.findUser(this.userId)
}, },
pinnedStatuses () {
return this.user.pinnedStatusIds.map(id => this.$store.state.statuses.allStatusesObject[id])
},
isExternal () { isExternal () {
return this.$route.name === 'external-user-profile' return this.$route.name === 'external-user-profile'
}, },
@ -94,15 +95,14 @@ const UserProfile = {
fetchTimelines () { fetchTimelines () {
const userId = this.userId const userId = this.userId
this.$store.dispatch('startFetchingTimeline', { timeline: 'user', userId }) this.$store.dispatch('startFetchingTimeline', { timeline: 'user', userId })
this.$store.dispatch('startFetchingTimeline', { timeline: 'pinned', userId })
this.$store.dispatch('startFetchingTimeline', { timeline: 'media', userId }) this.$store.dispatch('startFetchingTimeline', { timeline: 'media', userId })
if (this.isUs) { if (this.isUs) {
this.$store.dispatch('startFetchingTimeline', { timeline: 'favorites', userId }) this.$store.dispatch('startFetchingTimeline', { timeline: 'favorites', userId })
} }
this.$store.dispatch('fetchPinnedStatuses', userId)
}, },
cleanUp () { cleanUp () {
this.$store.dispatch('stopFetching', 'user') this.$store.dispatch('stopFetching', 'user')
this.$store.dispatch('stopFetching', 'pinned')
this.$store.dispatch('stopFetching', 'favorites') this.$store.dispatch('stopFetching', 'favorites')
this.$store.dispatch('stopFetching', 'media') this.$store.dispatch('stopFetching', 'media')
this.$store.commit('clearTimeline', { timeline: 'user' }) this.$store.commit('clearTimeline', { timeline: 'user' })
@ -133,7 +133,8 @@ const UserProfile = {
FollowerList, FollowerList,
FriendList, FriendList,
ModerationTools, ModerationTools,
FollowCard FollowCard,
Conversation
} }
} }

View file

@ -4,15 +4,16 @@
<UserCard :user="user" :switcher="true" :selected="timeline.viewing" rounded="top"/> <UserCard :user="user" :switcher="true" :selected="timeline.viewing" rounded="top"/>
<tab-switcher :renderOnlyFocused="true" ref="tabSwitcher"> <tab-switcher :renderOnlyFocused="true" ref="tabSwitcher">
<div :label="$t('user_card.statuses')" :disabled="!user.statuses_count"> <div :label="$t('user_card.statuses')" :disabled="!user.statuses_count">
<Timeline <div class="timeline">
:count="user.statuses_count" <Conversation
:embedded="true" v-for="status in pinnedStatuses"
:title="$t('user_profile.timeline_title')" class="status-fadein"
:timeline="pinned" :key="status.id"
:timeline-name="'pinned'" :statusoid="status"
:user-id="userId" :pinned="true"
:no-load-more="true" :collapsable="true"
/> />
</div>
<Timeline <Timeline
:count="user.statuses_count" :count="user.statuses_count"
:embedded="true" :embedded="true"

View file

@ -1,4 +1,4 @@
import { remove, slice, each, findIndex, find, maxBy, minBy, merge, first, last, isArray, omitBy } from 'lodash' import { remove, slice, each, findIndex, find, maxBy, minBy, merge, first, last, isArray, omitBy, map } from 'lodash'
import { set } from 'vue' import { set } from 'vue'
import apiService from '../services/api/api.service.js' import apiService from '../services/api/api.service.js'
// import parse from '../services/status_parser/status_parser.js' // import parse from '../services/status_parser/status_parser.js'
@ -47,8 +47,7 @@ export const defaultState = () => ({
publicAndExternal: emptyTl(), publicAndExternal: emptyTl(),
friends: emptyTl(), friends: emptyTl(),
tag: emptyTl(), tag: emptyTl(),
dms: emptyTl(), dms: emptyTl()
pinned: emptyTl()
} }
}) })
@ -171,7 +170,7 @@ const addNewStatuses = (state, { statuses, showImmediately = false, timeline, us
// This makes sure that user timeline won't get data meant for other // This makes sure that user timeline won't get data meant for other
// user. I.e. opening different user profiles makes request which could // user. I.e. opening different user profiles makes request which could
// return data late after user already viewing different user profile // return data late after user already viewing different user profile
if ((timeline === 'user' || timeline === 'media' || timeline === 'pinned') && timelineObject.userId !== userId) { if ((timeline === 'user' || timeline === 'media') && timelineObject.userId !== userId) {
return return
} }
@ -542,6 +541,13 @@ const statuses = {
rootState.api.backendInteractor.unfavorite(status.id) rootState.api.backendInteractor.unfavorite(status.id)
.then(status => commit('setFavoritedConfirm', { status, user: rootState.users.currentUser })) .then(status => commit('setFavoritedConfirm', { status, user: rootState.users.currentUser }))
}, },
fetchPinnedStatuses ({ rootState, dispatch, commit }, userId) {
rootState.api.backendInteractor.fetchPinnedStatuses(userId)
.then(statuses => {
dispatch('addNewStatuses', { statuses })
commit('savePinnedStatusIds', { userId, statusIds: map(statuses, 'id') })
})
},
updatePinned ({ rootState, commit }, status) { updatePinned ({ rootState, commit }, status) {
commit('setPinned', { status }) commit('setPinned', { status })
if (status.pinned) { if (status.pinned) {

View file

@ -160,6 +160,9 @@ export const mutations = {
saveMuteIds (state, muteIds) { saveMuteIds (state, muteIds) {
state.currentUser.muteIds = muteIds state.currentUser.muteIds = muteIds
}, },
savePinnedStatusIds (state, { userId, statusIds }) {
state.usersObject[userId].pinnedStatusIds = statusIds
},
addMuteId (state, muteId) { addMuteId (state, muteId) {
if (state.currentUser.muteIds.indexOf(muteId) === -1) { if (state.currentUser.muteIds.indexOf(muteId) === -1) {
state.currentUser.muteIds.push(muteId) state.currentUser.muteIds.push(muteId)

View file

@ -106,6 +106,7 @@ const backendInteractorService = (credentials) => {
const fetchFollowRequests = () => apiService.fetchFollowRequests({credentials}) const fetchFollowRequests = () => apiService.fetchFollowRequests({credentials})
const fetchOAuthTokens = () => apiService.fetchOAuthTokens({credentials}) const fetchOAuthTokens = () => apiService.fetchOAuthTokens({credentials})
const revokeOAuthToken = (id) => apiService.revokeOAuthToken({id, credentials}) const revokeOAuthToken = (id) => apiService.revokeOAuthToken({id, credentials})
const fetchPinnedStatuses = (id) => apiService.fetchPinnedStatuses({ id, credentials })
const getCaptcha = () => apiService.getCaptcha() const getCaptcha = () => apiService.getCaptcha()
const register = (params) => apiService.register(params) const register = (params) => apiService.register(params)
@ -154,6 +155,7 @@ const backendInteractorService = (credentials) => {
fetchBlocks, fetchBlocks,
fetchOAuthTokens, fetchOAuthTokens,
revokeOAuthToken, revokeOAuthToken,
fetchPinnedStatuses,
tagUser, tagUser,
untagUser, untagUser,
addRight, addRight,

View file

@ -131,6 +131,8 @@ export const parseUser = (data) => {
output.statuses_count = data.statuses_count output.statuses_count = data.statuses_count
output.friendIds = [] output.friendIds = []
output.followerIds = [] output.followerIds = []
output.pinnedStatusIds = []
if (data.pleroma) { if (data.pleroma) {
output.follow_request_count = data.pleroma.follow_request_count output.follow_request_count = data.pleroma.follow_request_count
} }