refs #167 Update toot when user favourite/reblog a toot in list timeline

This commit is contained in:
AkiraFukushima 2018-04-09 22:05:15 +09:00
parent b7f3e30a23
commit b860ccca86
2 changed files with 20 additions and 1 deletions

View File

@ -1,7 +1,7 @@
<template>
<div id="lists">
<div class="list-timeline" v-for="message in timeline" v-bind:key="message.id">
<toot :message="message"></toot>
<toot :message="message" v-on:update="updateToot"></toot>
</div>
</div>
</template>
@ -46,6 +46,9 @@ export default {
type: 'error'
})
})
},
updateToot (message) {
this.$store.commit('TimelineSpace/Contents/Lists/updateToot', message)
}
}
}

View File

@ -8,6 +8,22 @@ const Lists = {
mutations: {
updateTimeline (state, timeline) {
state.timeline = timeline
},
updateToot (state, message) {
state.timeline = state.timeline.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
}
})
}
},
actions: {