Skip to content

Commit a3847ce

Browse files
committed
リアルタイム(SocketIO)実装 / Markdown style改善
1 parent 51bd12c commit a3847ce

24 files changed

Lines changed: 176 additions & 110 deletions

browser/main/Components/AddMemberModal.jsx

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,6 @@ var Hq = require('../Services/Hq')
77

88
var KeyCaster = require('../Mixins/KeyCaster')
99

10-
var UserStore = require('../Stores/UserStore')
11-
1210
var getOptions = function (input, callback) {
1311
Hq.searchUser(input)
1412
.then(function (res) {
@@ -58,7 +56,6 @@ module.exports = React.createClass({
5856
})
5957
.then(function (res) {
6058
console.log(res.body)
61-
UserStore.Actions.addMember(res.body)
6259
this.props.close()
6360
}.bind(this))
6461
.catch(function (err) {

browser/main/Components/CodeDeleteModal.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ module.exports = React.createClass({
2525
},
2626
submit: function () {
2727
var planet = this.props.planet
28-
Hq.destroyCode(planet.userName, planet.name, this.props.code.localId)
28+
Hq.destroyCode(planet.Owner.name, planet.name, this.props.code.localId)
2929
.then(function (res) {
3030
PlanetStore.Actions.destroyCode(res.body)
3131
this.props.close()

browser/main/Components/CodeForm.jsx

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,14 @@ var getOptions = function (input, callback) {
1515
Hq.searchTag(input)
1616
.then(function (res) {
1717
callback(null, {
18-
options: res.body.map(function (tag) {
19-
return {
20-
label: tag.name,
21-
value: tag.name
22-
}
23-
}),
24-
complete: false
25-
})
18+
options: res.body.map(function (tag) {
19+
return {
20+
label: tag.name,
21+
value: tag.name
22+
}
23+
}),
24+
complete: false
25+
})
2626
})
2727
.catch(function (err) {
2828
console.log(err)
@@ -88,18 +88,18 @@ module.exports = React.createClass({
8888
return tag.value
8989
})
9090
if (this.props.code == null) {
91-
Hq.createCode(planet.userName, planet.name, this.state.code)
91+
Hq.createCode(planet.Owner.name, planet.name, this.state.code)
9292
.then(function (res) {
9393
var code = res.body
9494
PlanetStore.Actions.updateCode(code)
9595
this.props.close()
96-
this.props.transitionTo('codes', {userName: planet.userName, planetName: planet.name, localId: code.localId})
96+
this.props.transitionTo('codes', {userName: planet.Owner.name, planetName: planet.name, localId: code.localId})
9797
}.bind(this))
9898
.catch(function (err) {
9999
console.error(err)
100100
})
101101
} else {
102-
Hq.updateCode(planet.userName, planet.name, this.props.code.localId, this.state.code)
102+
Hq.updateCode(planet.Owner.name, planet.name, this.props.code.localId, this.state.code)
103103
.then(function (res) {
104104
var code = res.body
105105
PlanetStore.Actions.updateCode(code)

browser/main/Components/HomeNavigator.jsx

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -94,15 +94,18 @@ module.exports = React.createClass({
9494
var params = this.getParams()
9595

9696
if (this.state.currentUser == null) {
97-
return (
98-
<div className='HomeNavigator'>
99-
</div>
100-
)
97+
return null
10198
}
10299

103-
var planets = (this.state.currentUser.Planets.concat(this.state.currentUser.Teams.reduce(function (planets, team) {
104-
return team.Planets == null ? planets : planets.concat(team.Planets)
105-
}, []))).map(function (planet, index) {
100+
var planets = this.state.currentUser.Planets.map(function (planet) {
101+
planet.userName = this.state.currentUser.name
102+
return planet
103+
}.bind(this)).concat(this.state.currentUser.Teams.reduce(function (_planets, team) {
104+
return _planets.concat(team.Planets == null ? [] : team.Planets.map(function (planet) {
105+
planet.userName = team.name
106+
return planet
107+
}))
108+
}, [])).map(function (planet, index) {
106109
return (
107110
<li userName={planet.userName} planetName={planet.name} key={planet.id} className={params.userName === planet.userName && params.planetName === planet.name ? 'active' : ''}>
108111
<Link to='planet' params={{userName: planet.userName, planetName: planet.name}}>

browser/main/Components/LogoutModal.jsx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
var React = require('react')
44

5+
var socket = require('../Services/socket')
6+
57
var KeyCaster = require('../Mixins/KeyCaster')
68

79
module.exports = React.createClass({
@@ -23,6 +25,8 @@ module.exports = React.createClass({
2325
logout: function () {
2426
localStorage.removeItem('currentUser')
2527
localStorage.removeItem('token')
28+
socket.reconnect()
29+
2630
this.props.transitionTo('login')
2731
this.props.close()
2832
},

browser/main/Components/NoteDeleteModal.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ module.exports = React.createClass({
2525
},
2626
submit: function () {
2727
var planet = this.props.planet
28-
Hq.destroyNote(planet.userName, planet.name, this.props.note.localId)
28+
Hq.destroyNote(planet.Owner.name, planet.name, this.props.note.localId)
2929
.then(function (res) {
3030
PlanetStore.Actions.destroyNote(res.body)
3131
this.props.close()

browser/main/Components/NoteForm.jsx

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,14 @@ var getOptions = function (input, callback) {
1616
Hq.searchTag(input)
1717
.then(function (res) {
1818
callback(null, {
19-
options: res.body.map(function (tag) {
20-
return {
21-
label: tag.name,
22-
value: tag.name
23-
}
24-
}),
25-
complete: false
26-
})
19+
options: res.body.map(function (tag) {
20+
return {
21+
label: tag.name,
22+
value: tag.name
23+
}
24+
}),
25+
complete: false
26+
})
2727
})
2828
.catch(function (err) {
2929
console.log(err)
@@ -89,18 +89,18 @@ module.exports = React.createClass({
8989
})
9090

9191
if (this.props.note == null) {
92-
Hq.createNote(planet.userName, planet.name, this.state.note)
92+
Hq.createNote(planet.Owner.name, planet.name, this.state.note)
9393
.then(function (res) {
9494
var note = res.body
9595
PlanetStore.Actions.updateNote(note)
9696
this.props.close()
97-
this.props.transitionTo('notes', {userName: planet.userName, planetName: planet.name, localId: note.localId})
97+
this.props.transitionTo('notes', {userName: planet.Owner.name, planetName: planet.name, localId: note.localId})
9898
}.bind(this))
9999
.catch(function (err) {
100100
console.error(err)
101101
})
102102
} else {
103-
Hq.updateNote(planet.userName, planet.name, this.props.note.localId, this.state.note)
103+
Hq.updateNote(planet.Owner.name, planet.name, this.props.note.localId, this.state.note)
104104
.then(function (res) {
105105
var note = res.body
106106
PlanetStore.Actions.updateNote(note)

browser/main/Components/PlanetArticleList.jsx

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ module.exports = React.createClass({
1818
return function (e) {
1919
var params = this.getParams()
2020

21-
document.getElementById('articleEditButton').focus()
2221
this.transitionTo('codes', {
2322
userName: params.userName,
2423
planetName: params.planetName,
@@ -31,7 +30,6 @@ module.exports = React.createClass({
3130
return function (e) {
3231
var params = this.getParams()
3332

34-
document.getElementById('articleEditButton').focus()
3533
this.transitionTo('notes', {
3634
userName: params.userName,
3735
planetName: params.planetName,

browser/main/Components/PlanetCreateModal.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ module.exports = React.createClass({
5151
PlanetStore.Actions.update(planet)
5252

5353
if (this.props.transitionTo != null) {
54-
this.props.transitionTo('planetHome', {userName: planet.userName, planetName: planet.name})
54+
this.props.transitionTo('planetHome', {userName: planet.Owner.name, planetName: planet.name})
5555
}
5656

5757
this.props.close()

browser/main/Components/PlanetHeader.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ module.exports = React.createClass({
4646
},
4747
render: function () {
4848
var currentPlanetName = this.props.currentPlanet.name
49-
var currentUserName = this.props.currentPlanet.userName
49+
var currentUserName = this.props.currentPlanet.Owner.name
5050

5151
return (
5252
<div className='PlanetHeader'>

0 commit comments

Comments
 (0)