Merge branch 'master' into akismet

This commit is contained in:
Wyatt Johnson
2018-02-02 15:01:06 -07:00
10 changed files with 45 additions and 8 deletions
@@ -38,8 +38,7 @@ class SignInContainer extends React.Component {
}
componentDidMount() {
window.addEventListener('storage', this.handleAuth);
this.listenToStorageChanges();
const { formData } = this.state;
const errors = Object.keys(formData).reduce((map, prop) => {
map[prop] = t('sign_in.required_field');
@@ -49,6 +48,14 @@ class SignInContainer extends React.Component {
}
componentWillUnmount() {
this.unlisten();
}
listenToStorageChanges() {
window.addEventListener('storage', this.handleAuth);
}
unlisten() {
window.removeEventListener('storage', this.handleAuth);
}
@@ -60,6 +67,8 @@ class SignInContainer extends React.Component {
if (e.key === 'auth') {
const { err, data } = JSON.parse(e.newValue);
authCallback(err, data);
this.unlisten();
localStorage.removeItem('auth');
}
};