Skip to content

Commit d757207

Browse files
committed
small HomeCommunication changes
1 parent d659068 commit d757207

1 file changed

Lines changed: 11 additions & 10 deletions

File tree

‎src/containers/home-communication.jsx‎

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -45,30 +45,31 @@ class HomeCommunication extends React.Component {
4545
}
4646

4747
async wrapperEventHandler(e) {
48+
if (!this.state.canSetUsername) return;
49+
if (!this.state.frame) return;
50+
51+
if (e.origin !== origin) return;
52+
4853
const data = e.data;
49-
// Don't recursively try to run this event.
50-
if (e.origin === window.origin) {
51-
return;
52-
}
53-
if (!data.type) return;
54-
if (!data.packet) return;
54+
if (typeof data.type !== "string") return;
55+
if (!data.packet || typeof data.packet !== "object") return;
5556

5657
switch (data.type) {
5758
case 'login': {
5859
if (data.packet.loggedIn !== true) return;
59-
if (!data.packet.username) return;
60-
if (!this.state.canSetUsername) return;
61-
this.props.onSetUsername(data.packet.username);
60+
if (typeof data.packet.username !== "string") return;
6261
this.setState({
6362
canSetUsername: false
63+
}, () => {
64+
this.props.onSetUsername(data.packet.username);
6465
});
6566
}
6667
}
6768
}
6869

6970
render () {
7071
return (
71-
<div></div>
72+
<div style={{ display: "none" }}></div>
7273
);
7374
}
7475
}

0 commit comments

Comments
 (0)