1
0
mirror of https://github.com/BoostIo/Boostnote synced 2025-12-22 14:11:42 +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

@@ -224,8 +224,9 @@ module.exports = React.createClass({
var articles = this.state.currentPlanet == null ? null : this.state.currentPlanet.Articles
var planet
if (res.status === 'planetFetched') {
var planet = res.data
planet = res.data
this.setState({isFetched: true, currentPlanet: planet, filteredArticles: planet.Articles}, function () {
if (this.refs.detail.props.article == null) {
var params = this.props.params
@@ -248,6 +249,14 @@ module.exports = React.createClass({
return
}
if (res.status === 'planetDeleted') {
planet = res.data
this.transitionTo('user', {
userName: this.props.params.userName
})
return
}
var user
if (res.status === 'userAdded') {
user = res.data

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 () {