aboutsummaryrefslogtreecommitdiff
path: root/src/modules
diff options
context:
space:
mode:
Diffstat (limited to 'src/modules')
-rw-r--r--src/modules/statuses.js6
-rw-r--r--src/modules/users.js17
2 files changed, 18 insertions, 5 deletions
diff --git a/src/modules/statuses.js b/src/modules/statuses.js
index 0650a86b..e6ee5447 100644
--- a/src/modules/statuses.js
+++ b/src/modules/statuses.js
@@ -424,7 +424,7 @@ export const mutations = {
newStatus.favoritedBy.push(user)
}
},
- setPinned (state, { status }) {
+ setPinned (state, status) {
const newStatus = state.allStatusesObject[status.id]
newStatus.pinned = status.pinned
},
@@ -543,11 +543,11 @@ const statuses = {
},
pinStatus ({ rootState, commit }, statusId) {
return rootState.api.backendInteractor.pinOwnStatus(statusId)
- .then((status) => commit('setPinned', { status }))
+ .then((status) => commit('setPinned', status))
},
unpinStatus ({ rootState, commit }, statusId) {
rootState.api.backendInteractor.unpinOwnStatus(statusId)
- .then((status) => commit('setPinned', { status }))
+ .then((status) => commit('setPinned', status))
},
retweet ({ rootState, commit }, status) {
// Optimistic retweeting...
diff --git a/src/modules/users.js b/src/modules/users.js
index adcab233..e72a657c 100644
--- a/src/modules/users.js
+++ b/src/modules/users.js
@@ -165,6 +165,15 @@ export const mutations = {
state.currentUser.muteIds.push(muteId)
}
},
+ setPinned (state, status) {
+ const user = state.usersObject[status.user.id]
+ const index = user.pinnedStatuseIds.indexOf(status.id)
+ if (status.pinned && index === -1) {
+ user.pinnedStatuseIds.push(status.id)
+ } else if (!status.pinned && index !== -1) {
+ user.pinnedStatuseIds.splice(index, 1)
+ }
+ },
setUserForStatus (state, status) {
status.user = state.usersObject[status.user.id]
},
@@ -318,13 +327,17 @@ const users = {
store.commit('addNewUsers', users)
store.commit('addNewUsers', retweetedUsers)
- // Reconnect users to statuses
each(statuses, (status) => {
+ // Reconnect users to statuses
store.commit('setUserForStatus', status)
+ // Set pinned statuses to user
+ store.commit('setPinned', status)
})
- // Reconnect users to retweets
each(compact(map(statuses, 'retweeted_status')), (status) => {
+ // Reconnect users to retweets
store.commit('setUserForStatus', status)
+ // Set pinned retweets to user
+ store.commit('setPinned', status)
})
},
addNewNotifications (store, { notifications }) {