mirror of
https://github.com/BoostIo/Boostnote
synced 2025-12-13 17:56:25 +00:00
fix planet switching bugs
This commit is contained in:
@@ -20,7 +20,7 @@ var PlanetHeader = React.createClass({
|
|||||||
},
|
},
|
||||||
render: function () {
|
render: function () {
|
||||||
var currentPlanetName = this.props.currentPlanet.name
|
var currentPlanetName = this.props.currentPlanet.name
|
||||||
var currentUserName = this.props.currentUser.name
|
var currentUserName = this.props.currentPlanet.userName
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div onClick={this.interceptClick} className='PlanetHeader'>
|
<div onClick={this.interceptClick} className='PlanetHeader'>
|
||||||
|
|||||||
@@ -62,14 +62,14 @@ module.exports = React.createClass({
|
|||||||
componentDidMount: function () {
|
componentDidMount: function () {
|
||||||
this.unsubscribe = PlanetStore.listen(this.onFetched)
|
this.unsubscribe = PlanetStore.listen(this.onFetched)
|
||||||
|
|
||||||
PlanetActions.fetchPlanet(this.props.params.userName + '/' + this.props.params.planetName)
|
PlanetActions.fetchPlanet(this.props.params.userName, this.props.params.planetName)
|
||||||
},
|
},
|
||||||
componentWillUnmount: function () {
|
componentWillUnmount: function () {
|
||||||
this.unsubscribe()
|
this.unsubscribe()
|
||||||
},
|
},
|
||||||
componentDidUpdate: function () {
|
componentDidUpdate: function () {
|
||||||
if (this.state.currentPlanet.planetName !== this.props.params.planetName) {
|
if (this.state.currentPlanet.name !== this.props.params.planetName || this.state.currentPlanet.userName !== this.props.params.userName) {
|
||||||
PlanetActions.fetchPlanet(this.props.params.userName + '/' + this.props.params.planetName)
|
PlanetActions.fetchPlanet(this.props.params.userName, this.props.params.planetName)
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
getFilteredIndexOfCurrentArticle: function () {
|
getFilteredIndexOfCurrentArticle: function () {
|
||||||
@@ -287,7 +287,6 @@ module.exports = React.createClass({
|
|||||||
var searchInput = React.findDOMNode(this).querySelector('.PlanetHeader .searchInput input')
|
var searchInput = React.findDOMNode(this).querySelector('.PlanetHeader .searchInput input')
|
||||||
|
|
||||||
if (document.activeElement === searchInput) {
|
if (document.activeElement === searchInput) {
|
||||||
console.log('fff', e.keyCode)
|
|
||||||
switch (e.keyCode) {
|
switch (e.keyCode) {
|
||||||
case 38:
|
case 38:
|
||||||
this.focus()
|
this.focus()
|
||||||
|
|||||||
@@ -42,9 +42,9 @@ var PlanetStore = Reflux.createStore({
|
|||||||
})
|
})
|
||||||
}.bind(this))
|
}.bind(this))
|
||||||
},
|
},
|
||||||
fetchPlanet: function (planetName) {
|
fetchPlanet: function (userName, planetName) {
|
||||||
request
|
request
|
||||||
.get(apiUrl + planetName)
|
.get(apiUrl + userName + '/' + planetName)
|
||||||
.send()
|
.send()
|
||||||
.end(function (err, res) {
|
.end(function (err, res) {
|
||||||
if (err) {
|
if (err) {
|
||||||
@@ -54,6 +54,8 @@ var PlanetStore = Reflux.createStore({
|
|||||||
}
|
}
|
||||||
|
|
||||||
var planet = res.body
|
var planet = res.body
|
||||||
|
planet.userName = userName
|
||||||
|
|
||||||
planet.Snippets = planet.Snippets.map(function (snippet) {
|
planet.Snippets = planet.Snippets.map(function (snippet) {
|
||||||
snippet.type = 'snippet'
|
snippet.type = 'snippet'
|
||||||
return snippet
|
return snippet
|
||||||
|
|||||||
Reference in New Issue
Block a user