refs #62 Update favourited status in public

This commit is contained in:
AkiraFukushima 2018-03-14 18:15:19 +09:00
parent 77f5749311
commit c7eb0f5f35
2 changed files with 15 additions and 1 deletions

View File

@ -1,7 +1,7 @@
<template> <template>
<div id="public"> <div id="public">
<div class="public-timeline" v-for="message in timeline" v-bind:key="message.id"> <div class="public-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>
</div> </div>
</template> </template>
@ -24,6 +24,11 @@ export default {
}, },
beforeDestroy () { beforeDestroy () {
this.$store.dispatch('TimelineSpace/Public/stopPublicStreaming') this.$store.dispatch('TimelineSpace/Public/stopPublicStreaming')
},
methods: {
updateToot (message) {
this.$store.commit('TimelineSpace/Public/updateToot', message)
}
} }
} }
</script> </script>

View File

@ -8,6 +8,15 @@ const Public = {
mutations: { mutations: {
appendTimeline (state, update) { appendTimeline (state, update) {
state.timeline = [update].concat(state.timeline) state.timeline = [update].concat(state.timeline)
},
updateToot (state, message) {
state.timeline = state.timeline.map((toot) => {
if (toot.id === message.id) {
return message
} else {
return toot
}
})
} }
}, },
actions: { actions: {