1
0
mirror of https://github.com/h3poteto/whalebird-desktop synced 2025-01-27 07:46:15 +01:00

Merge pull request #64 from h3poteto/iss-62

refs #62 Update favourited status in homeTimeline and notifications
This commit is contained in:
AkiraFukushima 2018-03-14 17:56:05 +09:00 committed by GitHub
commit aac92ab4ef
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 23 additions and 2 deletions

View File

@ -47,6 +47,27 @@ const TimelineSpace = {
},
changeNewTootModal (state, modal) {
state.newTootModal = modal
},
updateToot (state, message) {
// Replace target message in homeTimeline and notifications
state.homeTimeline = state.homeTimeline.map((toot) => {
if (toot.id === message.id) {
return message
} else {
return toot
}
})
state.notifications = state.notifications.map((notification) => {
if (notification.type === 'mention' && notification.status.id === message.id) {
const status = {
status: message
}
return Object.assign(notification, status)
} else {
return notification
}
})
}
},
actions: {

View File

@ -15,7 +15,7 @@ const Toot = {
)
client.post(`/statuses/${message.id}/favourite`, {}, (err, data, res) => {
if (err) return reject(err)
// TODO: update toot data
commit('TimelineSpace/updateToot', data, { root: true })
resolve(res)
})
})
@ -30,7 +30,7 @@ const Toot = {
)
client.post(`/statuses/${message.id}/unfavourite`, {}, (err, data, res) => {
if (err) return reject(err)
// TODO: update toot data
commit('TimelineSpace/updateToot', data, { root: true })
resolve(res)
})
})