From e8abe1273b5c860b78b219973c2a2926014c0ca5 Mon Sep 17 00:00:00 2001
From: taehoon
Date: Wed, 24 Apr 2019 14:34:55 -0400
Subject: [PATCH] filter pinned statuses based on pinned entity instead of a
separate user entity
---
src/components/user_profile/user_profile.js | 8 +++++---
src/modules/statuses.js | 9 +++------
src/modules/users.js | 3 ---
.../entity_normalizer/entity_normalizer.service.js | 1 -
4 files changed, 8 insertions(+), 13 deletions(-)
diff --git a/src/components/user_profile/user_profile.js b/src/components/user_profile/user_profile.js
index 0071fa89e2..176ec2283f 100644
--- a/src/components/user_profile/user_profile.js
+++ b/src/components/user_profile/user_profile.js
@@ -1,4 +1,5 @@
import get from 'lodash/get'
+import filter from 'lodash/filter'
import UserCard from '../user_card/user_card.vue'
import FollowCard from '../follow_card/follow_card.vue'
import Timeline from '../timeline/timeline.vue'
@@ -41,6 +42,9 @@ const UserProfile = {
timeline () {
return this.$store.state.statuses.timelines.user
},
+ pinnedStatuses () {
+ return filter(this.timeline.statuses, { pinned: true })
+ },
favorites () {
return this.$store.state.statuses.timelines.favorites
},
@@ -54,9 +58,6 @@ const UserProfile = {
user () {
return this.$store.getters.findUser(this.userId)
},
- pinnedStatuses () {
- return this.user.pinnedStatusIds.map(id => this.$store.state.statuses.allStatusesObject[id])
- },
isExternal () {
return this.$route.name === 'external-user-profile'
},
@@ -99,6 +100,7 @@ const UserProfile = {
if (this.isUs) {
this.$store.dispatch('startFetchingTimeline', { timeline: 'favorites', userId })
}
+ // Fetch all pinned statuses immediately
this.$store.dispatch('fetchPinnedStatuses', userId)
},
cleanUp () {
diff --git a/src/modules/statuses.js b/src/modules/statuses.js
index 3b3ae9e3d4..8edd2e115e 100644
--- a/src/modules/statuses.js
+++ b/src/modules/statuses.js
@@ -1,4 +1,4 @@
-import { remove, slice, each, findIndex, find, maxBy, minBy, merge, first, last, isArray, omitBy, map } from 'lodash'
+import { remove, slice, each, findIndex, find, maxBy, minBy, merge, first, last, isArray, omitBy } from 'lodash'
import { set } from 'vue'
import apiService from '../services/api/api.service.js'
// import parse from '../services/status_parser/status_parser.js'
@@ -541,12 +541,9 @@ const statuses = {
rootState.api.backendInteractor.unfavorite(status.id)
.then(status => commit('setFavoritedConfirm', { status, user: rootState.users.currentUser }))
},
- fetchPinnedStatuses ({ rootState, dispatch, commit }, userId) {
+ fetchPinnedStatuses ({ rootState, dispatch }, userId) {
rootState.api.backendInteractor.fetchPinnedStatuses(userId)
- .then(statuses => {
- dispatch('addNewStatuses', { statuses })
- commit('savePinnedStatusIds', { userId, statusIds: map(statuses, 'id') })
- })
+ .then(statuses => dispatch('addNewStatuses', { statuses, timeline: 'user', userId }))
},
updatePinned ({ rootState, commit }, status) {
commit('setPinned', { status })
diff --git a/src/modules/users.js b/src/modules/users.js
index def2b38c9d..adcab2334a 100644
--- a/src/modules/users.js
+++ b/src/modules/users.js
@@ -160,9 +160,6 @@ export const mutations = {
saveMuteIds (state, muteIds) {
state.currentUser.muteIds = muteIds
},
- savePinnedStatusIds (state, { userId, statusIds }) {
- state.usersObject[userId].pinnedStatusIds = statusIds
- },
addMuteId (state, muteId) {
if (state.currentUser.muteIds.indexOf(muteId) === -1) {
state.currentUser.muteIds.push(muteId)
diff --git a/src/services/entity_normalizer/entity_normalizer.service.js b/src/services/entity_normalizer/entity_normalizer.service.js
index 3636c05b7d..7f03ae2a20 100644
--- a/src/services/entity_normalizer/entity_normalizer.service.js
+++ b/src/services/entity_normalizer/entity_normalizer.service.js
@@ -131,7 +131,6 @@ export const parseUser = (data) => {
output.statuses_count = data.statuses_count
output.friendIds = []
output.followerIds = []
- output.pinnedStatusIds = []
if (data.pleroma) {
output.follow_request_count = data.pleroma.follow_request_count