From 02792132e1a8abc73ad5a319c20fff8e9a00f132 Mon Sep 17 00:00:00 2001 From: Bruno Windels Date: Thu, 11 Apr 2019 13:22:47 +0200 Subject: [PATCH] dont create functions in render --- .../views/right_panel/GroupHeaderButtons.js | 14 +++++++++++-- .../views/right_panel/RoomHeaderButtons.js | 21 ++++++++++++++++--- 2 files changed, 30 insertions(+), 5 deletions(-) diff --git a/src/components/views/right_panel/GroupHeaderButtons.js b/src/components/views/right_panel/GroupHeaderButtons.js index e01474f523..1b8e6a4a46 100644 --- a/src/components/views/right_panel/GroupHeaderButtons.js +++ b/src/components/views/right_panel/GroupHeaderButtons.js @@ -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 { this.togglePhase(RightPanel.Phase.GroupMemberList)} + onClick={this._onMembersClicked} analytics={['Right Panel', 'Group Member List Button', 'click']} />, this.togglePhase(RightPanel.Phase.GroupRoomList)} + onClick={this._onRoomsClicked} analytics={['Right Panel', 'Group Room List Button', 'click']} />, ]; diff --git a/src/components/views/right_panel/RoomHeaderButtons.js b/src/components/views/right_panel/RoomHeaderButtons.js index f3bc0967a4..65d74c7a0b 100644 --- a/src/components/views/right_panel/RoomHeaderButtons.js +++ b/src/components/views/right_panel/RoomHeaderButtons.js @@ -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 { this.togglePhase(RightPanel.Phase.RoomMemberList)} + onClick={this._onMembersClicked} analytics={['Right Panel', 'Member List Button', 'click']} />, this.togglePhase(RightPanel.Phase.FilePanel)} + onClick={this._onFilesClicked} analytics={['Right Panel', 'File List Button', 'click']} />, this.togglePhase(RightPanel.Phase.NotificationPanel)} + onClick={this._onNotificationsClicked} analytics={['Right Panel', 'Notification List Button', 'click']} />, ];