mirror of
https://github.com/elyby/accounts-frontend.git
synced 2025-02-28 05:02:58 +05:30
Hot fix for broken accounts state after register
This commit is contained in:
parent
e0a1f0c845
commit
5ad7ee4b9d
@ -7,6 +7,7 @@ import { FormattedMessage as Message } from 'react-intl';
|
||||
import loader from 'services/loader';
|
||||
import { skins, SKIN_DARK, COLOR_WHITE } from 'components/ui';
|
||||
import { Button } from 'components/ui/form';
|
||||
import { userShape } from 'components/user/User';
|
||||
|
||||
import styles from './accountSwitcher.scss';
|
||||
import messages from './AccountSwitcher.intl.json';
|
||||
@ -27,6 +28,7 @@ export class AccountSwitcher extends Component {
|
||||
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),
|
||||
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
|
||||
@ -44,7 +46,7 @@ export class AccountSwitcher extends Component {
|
||||
|
||||
render() {
|
||||
const { accounts, skin, allowAdd, allowLogout, highlightActiveAccount } = this.props;
|
||||
const activeAccount = accounts.active;
|
||||
const activeAccount = accounts.active || this.props.user;
|
||||
|
||||
let {available} = accounts;
|
||||
|
||||
@ -161,6 +163,7 @@ import { authenticate, revoke } from 'components/accounts/actions';
|
||||
|
||||
export default connect(({accounts, user}) => ({
|
||||
accounts,
|
||||
user,
|
||||
userLang: user.lang // this is to force re-render on lang change
|
||||
}), {
|
||||
switchAccount: authenticate,
|
||||
|
@ -3,7 +3,6 @@ import ReactDOM from 'react-dom';
|
||||
|
||||
import classNames from 'classnames';
|
||||
|
||||
import buttons from 'components/ui/buttons.scss';
|
||||
import { AccountSwitcher } from 'components/accounts';
|
||||
|
||||
import styles from './loggedInPanel.scss';
|
||||
@ -22,10 +21,12 @@ export default class LoggedInPanel extends Component {
|
||||
|
||||
componentDidMount() {
|
||||
document.addEventListener('click', this.onBodyClick);
|
||||
this._isMounted = true;
|
||||
}
|
||||
|
||||
componentWillUnmount() {
|
||||
document.removeEventListener('click', this.onBodyClick);
|
||||
this._isMounted = false;
|
||||
}
|
||||
|
||||
render() {
|
||||
@ -51,7 +52,7 @@ export default class LoggedInPanel extends Component {
|
||||
);
|
||||
}
|
||||
|
||||
toggleAccountSwitcher = () => this.setState({
|
||||
toggleAccountSwitcher = () => this._isMounted && this.setState({
|
||||
isAccountSwitcherActive: !this.state.isAccountSwitcherActive
|
||||
});
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user