From df207593e9ff4826adf0cf25d01b1471b2e0834c Mon Sep 17 00:00:00 2001 From: dave Date: Sun, 7 Apr 2019 11:30:14 -0400 Subject: [PATCH] #468 - update pinned status after actions(remove, add) --- src/components/status/status.vue | 2 +- src/modules/statuses.js | 15 +++++++++++++-- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/src/components/status/status.vue b/src/components/status/status.vue index a5614f59..ca5e4a1c 100644 --- a/src/components/status/status.vue +++ b/src/components/status/status.vue @@ -105,7 +105,7 @@ v-if="preview" :isPreview="true" :statusoid="preview" - :compact=true + :compact="true" />
diff --git a/src/modules/statuses.js b/src/modules/statuses.js index 649cb83c..bbc1a45b 100644 --- a/src/modules/statuses.js +++ b/src/modules/statuses.js @@ -171,7 +171,7 @@ const addNewStatuses = (state, { statuses, showImmediately = false, timeline, us // This makes sure that user timeline won't get data meant for other // user. I.e. opening different user profiles makes request which could // return data late after user already viewing different user profile - if ((timeline === 'user' || timeline === 'media') && timelineObject.userId !== userId) { + if ((timeline === 'user' || timeline === 'media' || timeline === 'pinned') && timelineObject.userId !== userId) { return } @@ -378,6 +378,7 @@ const removeStatus = (state, { timeline, userId, statusId }) => { removed = true delete timelineObject.statusesObject[statusId] delete timelineObject.visibleStatusesObject[statusId] + sortTimeline(timelineObject) } if (removed) { @@ -551,7 +552,17 @@ const statuses = { }, updatePinned ({ rootState, commit }, status) { commit('setPinned', { status }) - if (!status.pinned) { + if (status.pinned) { + const statusObj = rootState.statuses.allStatusesObject[status.id] + const user = rootState.users.currentUser + commit('addNewStatuses', { + statuses: [statusObj], + showImmediately: true, + timeline: 'pinned', + user, + userId: user.id + }) + } else { commit('removeStatus', { timeline: 'pinned', statusId: status.id }) } },