forked from AkkomaGang/akkoma-fe
#468 - remove unpinned status from timeline
This commit is contained in:
parent
2c89d49a3d
commit
f1ff48ffd6
1 changed files with 15 additions and 1 deletions
|
@ -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]
|
const timelineObject = state.timelines[timeline]
|
||||||
|
let removed = false
|
||||||
if (userId) {
|
if (userId) {
|
||||||
remove(timelineObject.statuses, { user: { id: userId } })
|
remove(timelineObject.statuses, { user: { id: userId } })
|
||||||
remove(timelineObject.visibleStatuses, { 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.minVisibleId = timelineObject.visibleStatuses.length > 0 ? last(timelineObject.visibleStatuses).id : 0
|
||||||
timelineObject.maxId = timelineObject.statuses.length > 0 ? first(timelineObject.statuses).id : 0
|
timelineObject.maxId = timelineObject.statuses.length > 0 ? first(timelineObject.statuses).id : 0
|
||||||
}
|
}
|
||||||
|
@ -540,6 +551,9 @@ const statuses = {
|
||||||
},
|
},
|
||||||
updatePinned ({ rootState, commit }, status) {
|
updatePinned ({ rootState, commit }, status) {
|
||||||
commit('setPinned', { status })
|
commit('setPinned', { status })
|
||||||
|
if (!status.pinned) {
|
||||||
|
commit('removeStatus', { timeline: 'pinned', statusId: status.id })
|
||||||
|
}
|
||||||
},
|
},
|
||||||
retweet ({ rootState, commit }, status) {
|
retweet ({ rootState, commit }, status) {
|
||||||
// Optimistic retweeting...
|
// Optimistic retweeting...
|
||||||
|
|
Loading…
Reference in a new issue