mirror of
https://github.com/scratchfoundation/scratch-www.git
synced 2025-02-17 00:21:20 -05:00
Refresh session, close popup after registration
This commit is contained in:
parent
6b1ce8549e
commit
fcec859cbe
2 changed files with 18 additions and 2 deletions
|
@ -96,6 +96,10 @@ var Navigation = React.createClass({
|
||||||
closeRegistration: function () {
|
closeRegistration: function () {
|
||||||
this.setState({'registrationOpen': false});
|
this.setState({'registrationOpen': false});
|
||||||
},
|
},
|
||||||
|
completeRegistration: function () {
|
||||||
|
window.refreshSession();
|
||||||
|
this.closeRegistration();
|
||||||
|
},
|
||||||
render: function () {
|
render: function () {
|
||||||
var classes = classNames({
|
var classes = classNames({
|
||||||
'inner': true,
|
'inner': true,
|
||||||
|
@ -151,7 +155,8 @@ var Navigation = React.createClass({
|
||||||
<Registration
|
<Registration
|
||||||
key="registration"
|
key="registration"
|
||||||
isOpen={this.state.registrationOpen}
|
isOpen={this.state.registrationOpen}
|
||||||
onRequestClose={this.closeRegistration} />,
|
onRequestClose={this.closeRegistration}
|
||||||
|
onRegistrationDone={this.completeRegistration} />,
|
||||||
<li className="link right login-item" key="login">
|
<li className="link right login-item" key="login">
|
||||||
<a
|
<a
|
||||||
href="#"
|
href="#"
|
||||||
|
|
|
@ -7,9 +7,20 @@ Modal.setAppElement(document.getElementById('view'));
|
||||||
|
|
||||||
module.exports = React.createClass({
|
module.exports = React.createClass({
|
||||||
propTypes: {
|
propTypes: {
|
||||||
isOpen: React.PropTypes.func,
|
isOpen: React.PropTypes.bool,
|
||||||
|
onRegistrationDone: React.PropTypes.func,
|
||||||
onRequestClose: React.PropTypes.func
|
onRequestClose: React.PropTypes.func
|
||||||
},
|
},
|
||||||
|
onMessage: function (e) {
|
||||||
|
if (e.origin != window.location.origin) return;
|
||||||
|
if (e.data == 'registration-done') this.props.onRegistrationDone();
|
||||||
|
},
|
||||||
|
componentDidMount: function () {
|
||||||
|
window.addEventListener('message', this.onMessage);
|
||||||
|
},
|
||||||
|
componentWillUnmount: function () {
|
||||||
|
window.removeEventListener('message', this.onMessage);
|
||||||
|
},
|
||||||
render: function () {
|
render: function () {
|
||||||
return (
|
return (
|
||||||
<Modal
|
<Modal
|
||||||
|
|
Loading…
Reference in a new issue