refs #62 Update favourited status in homeTimeline and notifications
This commit is contained in:
parent
6c90e40a06
commit
d313f93dfe
|
@ -47,6 +47,27 @@ const TimelineSpace = {
|
||||||
},
|
},
|
||||||
changeNewTootModal (state, modal) {
|
changeNewTootModal (state, modal) {
|
||||||
state.newTootModal = 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: {
|
actions: {
|
||||||
|
|
|
@ -15,7 +15,7 @@ const Toot = {
|
||||||
)
|
)
|
||||||
client.post(`/statuses/${message.id}/favourite`, {}, (err, data, res) => {
|
client.post(`/statuses/${message.id}/favourite`, {}, (err, data, res) => {
|
||||||
if (err) return reject(err)
|
if (err) return reject(err)
|
||||||
// TODO: update toot data
|
commit('TimelineSpace/updateToot', data, { root: true })
|
||||||
resolve(res)
|
resolve(res)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
@ -30,7 +30,7 @@ const Toot = {
|
||||||
)
|
)
|
||||||
client.post(`/statuses/${message.id}/unfavourite`, {}, (err, data, res) => {
|
client.post(`/statuses/${message.id}/unfavourite`, {}, (err, data, res) => {
|
||||||
if (err) return reject(err)
|
if (err) return reject(err)
|
||||||
// TODO: update toot data
|
commit('TimelineSpace/updateToot', data, { root: true })
|
||||||
resolve(res)
|
resolve(res)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
Loading…
Reference in New Issue