Add Pinned toot update handler

This commit is contained in:
L. E. Segovia 2018-12-11 23:50:46 +00:00
parent 07725445f9
commit 5fd2fdb6b0
No known key found for this signature in database
GPG Key ID: D5D1DC48B52B7AD5
2 changed files with 20 additions and 1 deletions

View File

@ -7,7 +7,7 @@
:focused="message.uri + message.id === focusedId" :focused="message.uri + message.id === focusedId"
:pinned="true" :pinned="true"
:overlaid="modalOpened" :overlaid="modalOpened"
v-on:update="updateToot" v-on:update="updatePinnedToot"
v-on:delete="deleteToot" v-on:delete="deleteToot"
@focusNext="focusNext" @focusNext="focusNext"
@focusPrev="focusPrev" @focusPrev="focusPrev"
@ -118,6 +118,9 @@ export default {
}) })
} }
}, },
updatePinnedToot (message) {
this.$store.commit('TimelineSpace/Contents/SideBar/AccountProfile/Timeline/updatePinnedToot', message)
},
updateToot (message) { updateToot (message) {
this.$store.commit('TimelineSpace/Contents/SideBar/AccountProfile/Timeline/updateToot', message) this.$store.commit('TimelineSpace/Contents/SideBar/AccountProfile/Timeline/updateToot', message)
}, },

View File

@ -20,6 +20,22 @@ const Timeline = {
changeLazyLoading (state, value) { changeLazyLoading (state, value) {
state.lazyLoading = value state.lazyLoading = value
}, },
updatePinnedToot (state, message) {
state.pinnedToots = state.pinnedToots.map((toot) => {
if (toot.id === message.id) {
return message
} else if (toot.reblog !== null && toot.reblog.id === message.id) {
// When user reblog/favourite a reblogged toot, target message is a original toot.
// So, a message which is received now is original toot.
const reblog = {
reblog: message
}
return Object.assign(toot, reblog)
} else {
return toot
}
})
},
updateToot (state, message) { updateToot (state, message) {
// Replace target message in timeline // Replace target message in timeline
state.timeline = state.timeline.map((toot) => { state.timeline = state.timeline.map((toot) => {