refs #62 Update favourited status in local

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

View File

@ -1,7 +1,7 @@
<template> <template>
<div id="local"> <div id="local">
<div class="local-timeline" v-for="message in timeline" v-bind:key="message.id"> <div class="local-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/Local/stopLocalStreaming') this.$store.dispatch('TimelineSpace/Local/stopLocalStreaming')
},
methods: {
updateToot (message) {
this.$store.commit('TimelineSpace/Local/updateToot', message)
}
} }
} }
</script> </script>

View File

@ -8,6 +8,15 @@ const Local = {
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: {