1
0
mirror of https://github.com/BoostIo/Boostnote synced 2025-12-16 03:06:27 +00:00

refactor modal & setup ordering for snippet

This commit is contained in:
Rokt33r
2015-07-16 01:34:40 +09:00
parent 8b10eb130a
commit f56dd10106
6 changed files with 252 additions and 99 deletions

View File

@@ -208,15 +208,34 @@ module.exports = React.createClass({
componentWillUnmount: function () {
this.unsubscribe()
},
onFetched: function (planet) {
this.setState({currentPlanet: planet}, function () {
if (planet.Snippets.length > 0) {
this.transitionTo('snippets', {
userName: this.props.params.userName,
planetName: this.props.params.planetName,
localId: planet.Snippets[0].localId})
}
})
onFetched: function (res) {
switch (res.status) {
case 'planetFetched':
var planet = res.data
this.setState({currentPlanet: planet}, function () {
if (planet.Snippets.length > 0) {
this.transitionTo('snippets', {
userName: this.props.params.userName,
planetName: this.props.params.planetName,
localId: planet.Snippets[0].localId})
}
})
break
case 'snippetCreated':
var snippet = res.data
if (snippet.PlanetId === this.state.currentPlanet.id) {
var snippets = this.state.currentPlanet.Snippets
snippets.unshift(snippet)
this.setState({planet: this.state.currentPlanet}, function () {
var params = this.getParams()
params.localId = snippet.localId
this.transitionTo('snippets', params)
})
}
}
},
render: function () {
var user = AuthStore.getUser()