Skip to content

Commit ac28401

Browse files
committed
disconnect server bug fixed + showLogin added to reducer
1 parent 3088be6 commit ac28401

File tree

4 files changed

+37
-15
lines changed

4 files changed

+37
-15
lines changed

src/js/views/components/ChoosingPage.js

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ const React = require('react');
33
const Input = require('./Input');
44
const Spinner = require('./Spinner');
55

6+
const {connect} = require('react-redux');
7+
68
class ChoosingPage extends React.Component{
79

810
constructor(props){
@@ -74,6 +76,9 @@ class ChoosingPage extends React.Component{
7476
this.setState({
7577
choosingPageNone: true
7678
})
79+
this.props.dispatch({
80+
type: 'HIDE_LOGIN'
81+
})
7782
}, 500)
7883

7984
}, 500)
@@ -146,6 +151,10 @@ class ChoosingPage extends React.Component{
146151
choosingPageNone: true
147152
})
148153

154+
this.props.dispatch({
155+
type: 'HIDE_LOGIN'
156+
})
157+
149158
}, 500)
150159

151160
}, 500)
@@ -174,6 +183,17 @@ class ChoosingPage extends React.Component{
174183

175184
}
176185

186+
componentDidUpdate(prevProps){
187+
if(prevProps.showLogin != this.props.showLogin){
188+
if(this.props.showLogin){
189+
this.setState({
190+
choosingPageNone: false
191+
})
192+
setTimeout(this.resetState.bind(this),100)
193+
}
194+
}
195+
}
196+
177197
resetState(){
178198
this.setState({
179199
loadingShow: false,
@@ -261,4 +281,6 @@ class ChoosingPage extends React.Component{
261281

262282
}
263283

264-
module.exports = ChoosingPage;
284+
module.exports = connect((state)=>{
285+
return {showLogin:state.general.showLogin}
286+
})(ChoosingPage);

src/js/views/components/Header.js

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ class Header extends React.Component{
1313
<header className="header">
1414
<div className="header__left-side">
1515
<div className="header__side-icon">
16-
<Icon onClick={this.disconnect} clickable={true} color='red' icon='power_settings_new' />
16+
<Icon onClick={this.disconnect.bind(this)} clickable={true} color='red' icon='power_settings_new' />
1717
</div>
1818
</div>
1919
<div className="header__ip-address">
@@ -43,16 +43,9 @@ class Header extends React.Component{
4343

4444
// Let's show the choosingPage
4545

46-
$('.choosingPage').classList.remove('none');
47-
setTimeout(() => {
48-
49-
$('.choosingPage').classList.remove('choosingPage--fadeOut');
50-
$('.choosingPage__address-wrapper').classList.remove('choosingPage__address-wrapper--show');
51-
$('.choosingPage__loading').classList.remove('choosingPage__loading--show');
52-
$('.choosingPage .choosingPage__item--selected').classList.remove('choosingPage__item--selected');
53-
$('.choosingPage .choosingPage__item--not-selected').classList.remove('choosingPage__item--not-selected');
54-
55-
}, 100)
46+
this.props.dispatch({
47+
type: 'SHOW_LOGIN'
48+
})
5649
}
5750

5851
sync(){

src/js/views/controllers/Server.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,9 +91,9 @@ class Server {
9191

9292
}
9393

94-
disconnect() {
94+
disConnect() {
9595

96-
this.server.close(()=>{console.log("Server Closed!")});
96+
this.io.close(()=>{console.log("Server Closed!")});
9797

9898
}
9999

src/js/views/reducers/generalReducer.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
module.exports = (state = {
22
isServer: false,
3-
port: '2020'
3+
port: '2020',
4+
showLogin: true
45
}, action) => {
56

67
switch (action.type) {
@@ -19,6 +20,12 @@ module.exports = (state = {
1920
port: action.port
2021
})
2122
break;
23+
case 'SHOW_LOGIN':
24+
return Object.assign({}, state, {showLogin: true})
25+
break;
26+
case 'HIDE_LOGIN':
27+
return Object.assign({}, state, {showLogin: false})
28+
break;
2229
default:
2330
return state;
2431
break;

0 commit comments

Comments
 (0)