Skip to content

Commit

Permalink
fixed potentially unbound login component class member functions
Browse files Browse the repository at this point in the history
The member functions are now lexically bound to the component class
which will ensure they're context aware (correctly bound "this")

fixes #16600
  • Loading branch information
IDCs committed Oct 22, 2024
1 parent 7c6808a commit 886f726
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions src/extensions/nexus_integration/views/LoginIcon.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -87,24 +87,24 @@ class LoginIcon extends ComponentEx<IProps, {}> {
return 'Free';
}

private renderMembershipStatus() {
private renderMembershipStatus = () => {
const { t, userInfo } = this.props;

const membership = this.getMembershipText(userInfo);
const classes = `membership-status ${membership.toLocaleLowerCase()}`

if (this.isLoggedIn()) {
return (
<div id='membership-status' className={classes}>
<div className='membership-status-text'>{membership}</div>
</div>
<div id='membership-status' className={classes}>
<div className='membership-status-text'>{membership}</div>
</div>
);
} else {
return null;
}
}

private renderLoginName() {
private renderLoginName = () => {
const { t, userInfo } = this.props;

if (this.isLoggedIn()) {
Expand All @@ -123,7 +123,7 @@ class LoginIcon extends ComponentEx<IProps, {}> {
}
}

private renderAvatar() {
private renderAvatar = () => {
const { t, userInfo } = this.props;

const loggedIn = this.isLoggedIn();
Expand Down Expand Up @@ -176,7 +176,7 @@ class LoginIcon extends ComponentEx<IProps, {}> {
});
}

private isLoggedIn() {
private isLoggedIn = () => {
const { isLoggedIn, userInfo } = this.props;
//return isLoggedIn;
return isLoggedIn && (userInfo !== undefined) && (userInfo !== null);
Expand All @@ -186,7 +186,7 @@ class LoginIcon extends ComponentEx<IProps, {}> {
this.setDialogVisible(false);
}

private setDialogVisible(visible: boolean): void {
private setDialogVisible = (visible: boolean): void => {
this.props.onShowDialog();
}
}
Expand Down

0 comments on commit 886f726

Please sign in to comment.