Skip to content

Commit f0b2e91

Browse files
committed
fix planet switching bugs
1 parent 72a08e8 commit f0b2e91

3 files changed

Lines changed: 8 additions & 7 deletions

File tree

browser/main/Components/PlanetHeader.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ var PlanetHeader = React.createClass({
2020
},
2121
render: function () {
2222
var currentPlanetName = this.props.currentPlanet.name
23-
var currentUserName = this.props.currentUser.name
23+
var currentUserName = this.props.currentPlanet.userName
2424

2525
return (
2626
<div onClick={this.interceptClick} className='PlanetHeader'>

browser/main/Containers/PlanetContainer.jsx

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -62,14 +62,14 @@ module.exports = React.createClass({
6262
componentDidMount: function () {
6363
this.unsubscribe = PlanetStore.listen(this.onFetched)
6464

65-
PlanetActions.fetchPlanet(this.props.params.userName + '/' + this.props.params.planetName)
65+
PlanetActions.fetchPlanet(this.props.params.userName, this.props.params.planetName)
6666
},
6767
componentWillUnmount: function () {
6868
this.unsubscribe()
6969
},
7070
componentDidUpdate: function () {
71-
if (this.state.currentPlanet.planetName !== this.props.params.planetName) {
72-
PlanetActions.fetchPlanet(this.props.params.userName + '/' + this.props.params.planetName)
71+
if (this.state.currentPlanet.name !== this.props.params.planetName || this.state.currentPlanet.userName !== this.props.params.userName) {
72+
PlanetActions.fetchPlanet(this.props.params.userName, this.props.params.planetName)
7373
}
7474
},
7575
getFilteredIndexOfCurrentArticle: function () {
@@ -287,7 +287,6 @@ module.exports = React.createClass({
287287
var searchInput = React.findDOMNode(this).querySelector('.PlanetHeader .searchInput input')
288288

289289
if (document.activeElement === searchInput) {
290-
console.log('fff', e.keyCode)
291290
switch (e.keyCode) {
292291
case 38:
293292
this.focus()

browser/main/Stores/PlanetStore.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,9 @@ var PlanetStore = Reflux.createStore({
4242
})
4343
}.bind(this))
4444
},
45-
fetchPlanet: function (planetName) {
45+
fetchPlanet: function (userName, planetName) {
4646
request
47-
.get(apiUrl + planetName)
47+
.get(apiUrl + userName + '/' + planetName)
4848
.send()
4949
.end(function (err, res) {
5050
if (err) {
@@ -54,6 +54,8 @@ var PlanetStore = Reflux.createStore({
5454
}
5555

5656
var planet = res.body
57+
planet.userName = userName
58+
5759
planet.Snippets = planet.Snippets.map(function (snippet) {
5860
snippet.type = 'snippet'
5961
return snippet

0 commit comments

Comments
 (0)