Fix init hack
This commit is contained in:
parent
c3f8631a57
commit
0e47716cc7
|
@ -16,13 +16,7 @@ import Nav from './ui/navigation';
|
||||||
import Main from './ui/main';
|
import Main from './ui/main';
|
||||||
import Connection from './ui/connection';
|
import Connection from './ui/connection';
|
||||||
|
|
||||||
let skip_init = false;
|
|
||||||
|
|
||||||
export function initialize(uri) {
|
export function initialize(uri) {
|
||||||
if (skip_init) {
|
|
||||||
skip_init = false;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
store.dispatch(socket_uri(uri));
|
store.dispatch(socket_uri(uri));
|
||||||
store.dispatch(socket_update(SOCKET_STATE.CONNECTING));
|
store.dispatch(socket_update(SOCKET_STATE.CONNECTING));
|
||||||
ws_init(uri, () => {
|
ws_init(uri, () => {
|
||||||
|
@ -53,7 +47,6 @@ render(<Main />);
|
||||||
if (module.hot) {
|
if (module.hot) {
|
||||||
module.hot.accept('./ui/main.js', () => {
|
module.hot.accept('./ui/main.js', () => {
|
||||||
const NextMain = require('./ui/main.js').default;
|
const NextMain = require('./ui/main.js').default;
|
||||||
skip_init = true;
|
|
||||||
render(<NextMain />);
|
render(<NextMain />);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,6 +19,12 @@ class ConnectionOverlay extends Component {
|
||||||
constructor() {
|
constructor() {
|
||||||
super();
|
super();
|
||||||
this.connect = this.connect.bind(this);
|
this.connect = this.connect.bind(this);
|
||||||
|
this.componentDidMount = this.componentDidMount.bind(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
componentDidMount() {
|
||||||
|
const { socket } = this.props;
|
||||||
|
if (socket.state === SOCKET_STATE.DISCONNECTED) {
|
||||||
const uri = localStorage.getItem("autoconnect");
|
const uri = localStorage.getItem("autoconnect");
|
||||||
const password = localStorage.getItem("password");
|
const password = localStorage.getItem("password");
|
||||||
this.state = {
|
this.state = {
|
||||||
|
@ -30,6 +36,7 @@ class ConnectionOverlay extends Component {
|
||||||
initialize(getURI(this.state.uri, this.state.password));
|
initialize(getURI(this.state.uri, this.state.password));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
connect() {
|
connect() {
|
||||||
if (this.state.autoconnect) {
|
if (this.state.autoconnect) {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user