Merge branch '652' into 'develop'

Fix "TypeError: Cannot set property 'pinned' of undefined"

Closes #652

See merge request pleroma/pleroma-fe!936
This commit is contained in:
Shpuld Shpludson 2019-09-03 04:48:24 +00:00
commit 6238fe3633
2 changed files with 7 additions and 11 deletions

View file

@ -426,10 +426,6 @@ export const mutations = {
newStatus.favoritedBy.push(user) newStatus.favoritedBy.push(user)
} }
}, },
setPinned (state, status) {
const newStatus = state.allStatusesObject[status.id]
newStatus.pinned = status.pinned
},
setMuted (state, status) { setMuted (state, status) {
const newStatus = state.allStatusesObject[status.id] const newStatus = state.allStatusesObject[status.id]
newStatus.muted = status.muted newStatus.muted = status.muted
@ -560,13 +556,13 @@ const statuses = {
rootState.api.backendInteractor.fetchPinnedStatuses(userId) rootState.api.backendInteractor.fetchPinnedStatuses(userId)
.then(statuses => dispatch('addNewStatuses', { statuses, timeline: 'user', userId, showImmediately: true, noIdUpdate: true })) .then(statuses => dispatch('addNewStatuses', { statuses, timeline: 'user', userId, showImmediately: true, noIdUpdate: true }))
}, },
pinStatus ({ rootState, commit }, statusId) { pinStatus ({ rootState, dispatch }, statusId) {
return rootState.api.backendInteractor.pinOwnStatus(statusId) return rootState.api.backendInteractor.pinOwnStatus(statusId)
.then((status) => commit('setPinned', status)) .then((status) => dispatch('addNewStatuses', { statuses: [status] }))
}, },
unpinStatus ({ rootState, commit }, statusId) { unpinStatus ({ rootState, dispatch }, statusId) {
rootState.api.backendInteractor.unpinOwnStatus(statusId) rootState.api.backendInteractor.unpinOwnStatus(statusId)
.then((status) => commit('setPinned', status)) .then((status) => dispatch('addNewStatuses', { statuses: [status] }))
}, },
muteConversation ({ rootState, commit }, statusId) { muteConversation ({ rootState, commit }, statusId) {
return rootState.api.backendInteractor.muteConversation(statusId) return rootState.api.backendInteractor.muteConversation(statusId)

View file

@ -164,7 +164,7 @@ export const mutations = {
state.currentUser.muteIds.push(muteId) state.currentUser.muteIds.push(muteId)
} }
}, },
setPinned (state, status) { setPinnedToUser (state, status) {
const user = state.usersObject[status.user.id] const user = state.usersObject[status.user.id]
const index = user.pinnedStatusIds.indexOf(status.id) const index = user.pinnedStatusIds.indexOf(status.id)
if (status.pinned && index === -1) { if (status.pinned && index === -1) {
@ -338,13 +338,13 @@ const users = {
// Reconnect users to statuses // Reconnect users to statuses
store.commit('setUserForStatus', status) store.commit('setUserForStatus', status)
// Set pinned statuses to user // Set pinned statuses to user
store.commit('setPinned', status) store.commit('setPinnedToUser', status)
}) })
each(compact(map(statuses, 'retweeted_status')), (status) => { each(compact(map(statuses, 'retweeted_status')), (status) => {
// Reconnect users to retweets // Reconnect users to retweets
store.commit('setUserForStatus', status) store.commit('setUserForStatus', status)
// Set pinned retweets to user // Set pinned retweets to user
store.commit('setPinned', status) store.commit('setPinnedToUser', status)
}) })
}, },
addNewNotifications (store, { notifications }) { addNewNotifications (store, { notifications }) {