refs #286 Update toot status in AccountProfile's timeline
This commit is contained in:
parent
5e61265fa2
commit
604f1a2723
|
@ -1,7 +1,7 @@
|
|||
<template>
|
||||
<div id="account_timeline">
|
||||
<template v-for="message in timeline">
|
||||
<toot :message="message" v-bind:key="message.id"></toot>
|
||||
<toot :message="message" :key="message.id" v-on:update="updateToot" v-on:delete="deleteToot"></toot>
|
||||
</template>
|
||||
</div>
|
||||
</template>
|
||||
|
@ -36,6 +36,12 @@ export default {
|
|||
type: 'error'
|
||||
})
|
||||
})
|
||||
},
|
||||
updateToot (message) {
|
||||
this.$store.commit('TimelineSpace/Contents/SideBar/AccountProfile/Timeline/updateToot', message)
|
||||
},
|
||||
deleteToot (message) {
|
||||
this.$store.commit('TimelineSpace/Contents/SideBar/AccountProfile/Timeline/deleteToot', message)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -8,6 +8,32 @@ const Timeline = {
|
|||
mutations: {
|
||||
updateTimeline (state, timeline) {
|
||||
state.timeline = timeline
|
||||
},
|
||||
updateToot (state, message) {
|
||||
// Replace target message in homeTimeline and notifications
|
||||
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
|
||||
}
|
||||
})
|
||||
},
|
||||
deleteToot (state, message) {
|
||||
state.timeline = state.timeline.filter((toot) => {
|
||||
if (toot.reblog !== null && toot.reblog.id === message.id) {
|
||||
return false
|
||||
} else {
|
||||
return toot.id !== message.id
|
||||
}
|
||||
})
|
||||
}
|
||||
},
|
||||
actions: {
|
||||
|
|
Loading…
Reference in New Issue