From f1ff48ffd6a38aca585762c061900fb36affde00 Mon Sep 17 00:00:00 2001 From: dave Date: Fri, 5 Apr 2019 15:33:55 -0400 Subject: [PATCH] #468 - remove unpinned status from timeline --- src/modules/statuses.js | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/src/modules/statuses.js b/src/modules/statuses.js index 94d7f30b..649cb83c 100644 --- a/src/modules/statuses.js +++ b/src/modules/statuses.js @@ -365,11 +365,22 @@ const addNewNotifications = (state, { dispatch, notifications, older, visibleNot }) } -const removeStatus = (state, { timeline, userId }) => { +const removeStatus = (state, { timeline, userId, statusId }) => { const timelineObject = state.timelines[timeline] + let removed = false if (userId) { remove(timelineObject.statuses, { user: { id: userId } }) remove(timelineObject.visibleStatuses, { user: { id: userId } }) + removed = true + } else if (statusId) { + remove(timelineObject.statuses, { id: statusId }) + remove(timelineObject.visibleStatuses, { id: statusId }) + removed = true + delete timelineObject.statusesObject[statusId] + delete timelineObject.visibleStatusesObject[statusId] + } + + if (removed) { timelineObject.minVisibleId = timelineObject.visibleStatuses.length > 0 ? last(timelineObject.visibleStatuses).id : 0 timelineObject.maxId = timelineObject.statuses.length > 0 ? first(timelineObject.statuses).id : 0 } @@ -540,6 +551,9 @@ const statuses = { }, updatePinned ({ rootState, commit }, status) { commit('setPinned', { status }) + if (!status.pinned) { + commit('removeStatus', { timeline: 'pinned', statusId: status.id }) + } }, retweet ({ rootState, commit }, status) { // Optimistic retweeting...