1
0
mirror of https://github.com/BoostIo/Boostnote synced 2025-12-15 10:46:32 +00:00

add delete planet request

This commit is contained in:
Rokt33r
2015-07-25 12:39:09 +09:00
parent 4df489bd10
commit 5dbfb24f1c
5 changed files with 51 additions and 3 deletions

View File

@@ -58,20 +58,38 @@ module.exports = React.createClass({
onListen: function (res) {
if (res == null || res.status == null) return
var currentUser = this.state.currentUser
if (res.status === 'planetCreated') {
var currentUser = this.state.currentUser
currentUser.Planets.push(res.data)
localStorage.setItem('user', JSON.stringify(currentUser))
this.setState({currentUser: currentUser})
return
}
if (res.status === 'planetDeleted') {
currentUser.Planets.some(function (_planet, index) {
if (res.data.id === _planet.id) {
currentUser.Planets.splice(index, 1)
return true
}
return false
})
localStorage.setItem('user', JSON.stringify(currentUser))
this.setState({currentUser: currentUser})
return
}
if (res.status === 'nameChanged') {
this.setState({currentUser: AuthStore.getUser()})
return
}
if (res.status === 'userProfileUpdated') {
this.setState({currentUser: AuthStore.getUser()})
return
}
},
render: function () {