refs #167 Update toot when user favourite/reblog a toot in list timeline
This commit is contained in:
parent
b7f3e30a23
commit
b860ccca86
|
@ -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)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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: {
|
||||
|
|
Loading…
Reference in New Issue