dont create functions in render

pull/21833/head
Bruno Windels 2019-04-11 13:22:47 +02:00
parent 49e96dc404
commit 02792132e1
2 changed files with 30 additions and 5 deletions

View File

@ -26,6 +26,8 @@ import RightPanel from '../../structures/RightPanel';
export default class GroupHeaderButtons extends HeaderButtons {
constructor(props) {
super(props, RightPanel.Phase.GroupMemberList);
this._onMembersClicked = this._onMembersClicked.bind(this);
this._onRoomsClicked = this._onRoomsClicked.bind(this);
}
onAction(payload) {
@ -50,6 +52,14 @@ export default class GroupHeaderButtons extends HeaderButtons {
}
}
_onMembersClicked() {
this.togglePhase(RightPanel.Phase.GroupMemberList);
}
_onRoomsClicked() {
this.togglePhase(RightPanel.Phase.GroupRoomList);
}
renderButtons() {
const groupPhases = [
RightPanel.Phase.GroupMemberInfo,
@ -64,13 +74,13 @@ export default class GroupHeaderButtons extends HeaderButtons {
<HeaderButton key="groupMembersButton" name="groupMembersButton"
title={_t('Members')}
isHighlighted={this.isPhase(groupPhases)}
onClick={() => this.togglePhase(RightPanel.Phase.GroupMemberList)}
onClick={this._onMembersClicked}
analytics={['Right Panel', 'Group Member List Button', 'click']}
/>,
<HeaderButton key="roomsButton" name="roomsButton"
title={_t('Rooms')}
isHighlighted={this.isPhase(roomPhases)}
onClick={() => this.togglePhase(RightPanel.Phase.GroupRoomList)}
onClick={this._onRoomsClicked}
analytics={['Right Panel', 'Group Room List Button', 'click']}
/>,
];

View File

@ -26,6 +26,9 @@ import RightPanel from '../../structures/RightPanel';
export default class RoomHeaderButtons extends HeaderButtons {
constructor(props) {
super(props, RightPanel.Phase.RoomMemberList);
this._onMembersClicked = this._onMembersClicked.bind(this);
this._onFilesClicked = this._onFilesClicked.bind(this);
this._onNotificationsClicked = this._onNotificationsClicked.bind(this);
}
onAction(payload) {
@ -47,6 +50,18 @@ export default class RoomHeaderButtons extends HeaderButtons {
}
}
_onMembersClicked() {
this.togglePhase(RightPanel.Phase.RoomMemberList);
}
_onFilesClicked() {
this.togglePhase(RightPanel.Phase.FilePanel);
}
_onNotificationsClicked() {
this.togglePhase(RightPanel.Phase.NotificationPanel);
}
renderButtons() {
const membersPhases = [
RightPanel.Phase.RoomMemberList,
@ -58,19 +73,19 @@ export default class RoomHeaderButtons extends HeaderButtons {
<HeaderButton key="membersButton" name="membersButton"
title={_t('Members')}
isHighlighted={this.isPhase(membersPhases)}
onClick={() => this.togglePhase(RightPanel.Phase.RoomMemberList)}
onClick={this._onMembersClicked}
analytics={['Right Panel', 'Member List Button', 'click']}
/>,
<HeaderButton key="filesButton" name="filesButton"
title={_t('Files')}
isHighlighted={this.isPhase(RightPanel.Phase.FilePanel)}
onClick={() => this.togglePhase(RightPanel.Phase.FilePanel)}
onClick={this._onFilesClicked}
analytics={['Right Panel', 'File List Button', 'click']}
/>,
<HeaderButton key="notifsButton" name="notifsButton"
title={_t('Notifications')}
isHighlighted={this.isPhase(RightPanel.Phase.NotificationPanel)}
onClick={() => this.togglePhase(RightPanel.Phase.NotificationPanel)}
onClick={this._onNotificationsClicked}
analytics={['Right Panel', 'Notification List Button', 'click']}
/>,
];