mirror of
https://github.com/elyby/accounts-frontend.git
synced 2025-05-31 14:11:58 +05:30
Hot fix for broken accounts state after register
This commit is contained in:
@@ -7,6 +7,7 @@ import { FormattedMessage as Message } from 'react-intl';
|
|||||||
import loader from 'services/loader';
|
import loader from 'services/loader';
|
||||||
import { skins, SKIN_DARK, COLOR_WHITE } from 'components/ui';
|
import { skins, SKIN_DARK, COLOR_WHITE } from 'components/ui';
|
||||||
import { Button } from 'components/ui/form';
|
import { Button } from 'components/ui/form';
|
||||||
|
import { userShape } from 'components/user/User';
|
||||||
|
|
||||||
import styles from './accountSwitcher.scss';
|
import styles from './accountSwitcher.scss';
|
||||||
import messages from './AccountSwitcher.intl.json';
|
import messages from './AccountSwitcher.intl.json';
|
||||||
@@ -27,6 +28,7 @@ export class AccountSwitcher extends Component {
|
|||||||
id: PropTypes.number
|
id: PropTypes.number
|
||||||
}))
|
}))
|
||||||
}),
|
}),
|
||||||
|
user: userShape, // TODO: remove me, when we will be sure, that accounts.active is always set for user
|
||||||
skin: PropTypes.oneOf(skins),
|
skin: PropTypes.oneOf(skins),
|
||||||
highlightActiveAccount: PropTypes.bool, // whether active account should be expanded and shown on the top
|
highlightActiveAccount: PropTypes.bool, // whether active account should be expanded and shown on the top
|
||||||
allowLogout: PropTypes.bool, // whether to show logout icon near each account
|
allowLogout: PropTypes.bool, // whether to show logout icon near each account
|
||||||
@@ -44,7 +46,7 @@ export class AccountSwitcher extends Component {
|
|||||||
|
|
||||||
render() {
|
render() {
|
||||||
const { accounts, skin, allowAdd, allowLogout, highlightActiveAccount } = this.props;
|
const { accounts, skin, allowAdd, allowLogout, highlightActiveAccount } = this.props;
|
||||||
const activeAccount = accounts.active;
|
const activeAccount = accounts.active || this.props.user;
|
||||||
|
|
||||||
let {available} = accounts;
|
let {available} = accounts;
|
||||||
|
|
||||||
@@ -161,6 +163,7 @@ import { authenticate, revoke } from 'components/accounts/actions';
|
|||||||
|
|
||||||
export default connect(({accounts, user}) => ({
|
export default connect(({accounts, user}) => ({
|
||||||
accounts,
|
accounts,
|
||||||
|
user,
|
||||||
userLang: user.lang // this is to force re-render on lang change
|
userLang: user.lang // this is to force re-render on lang change
|
||||||
}), {
|
}), {
|
||||||
switchAccount: authenticate,
|
switchAccount: authenticate,
|
||||||
|
@@ -3,7 +3,6 @@ import ReactDOM from 'react-dom';
|
|||||||
|
|
||||||
import classNames from 'classnames';
|
import classNames from 'classnames';
|
||||||
|
|
||||||
import buttons from 'components/ui/buttons.scss';
|
|
||||||
import { AccountSwitcher } from 'components/accounts';
|
import { AccountSwitcher } from 'components/accounts';
|
||||||
|
|
||||||
import styles from './loggedInPanel.scss';
|
import styles from './loggedInPanel.scss';
|
||||||
@@ -22,10 +21,12 @@ export default class LoggedInPanel extends Component {
|
|||||||
|
|
||||||
componentDidMount() {
|
componentDidMount() {
|
||||||
document.addEventListener('click', this.onBodyClick);
|
document.addEventListener('click', this.onBodyClick);
|
||||||
|
this._isMounted = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
componentWillUnmount() {
|
componentWillUnmount() {
|
||||||
document.removeEventListener('click', this.onBodyClick);
|
document.removeEventListener('click', this.onBodyClick);
|
||||||
|
this._isMounted = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
@@ -51,7 +52,7 @@ export default class LoggedInPanel extends Component {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
toggleAccountSwitcher = () => this.setState({
|
toggleAccountSwitcher = () => this._isMounted && this.setState({
|
||||||
isAccountSwitcherActive: !this.state.isAccountSwitcherActive
|
isAccountSwitcherActive: !this.state.isAccountSwitcherActive
|
||||||
});
|
});
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user