From 613e83edb4b89368e54f2ecca559337130f0c351 Mon Sep 17 00:00:00 2001 From: Michael Telatynski <7t3chguy@gmail.com> Date: Wed, 27 Jun 2018 09:49:58 +0100 Subject: [PATCH] on roomsublist invite badge click goto first room/group Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> --- src/components/structures/RoomSubList.js | 25 +++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/src/components/structures/RoomSubList.js b/src/components/structures/RoomSubList.js index db23466f9a..e5a08d62ea 100644 --- a/src/components/structures/RoomSubList.js +++ b/src/components/structures/RoomSubList.js @@ -26,6 +26,7 @@ import Unread from '../../Unread'; import * as RoomNotifs from '../../RoomNotifs'; import * as FormattingUtils from '../../utils/FormattingUtils'; import { KeyCode } from '../../Keyboard'; +import { Group } from 'matrix-js-sdk'; // turn this on for drop & drag console debugging galore @@ -260,6 +261,28 @@ const RoomSubList = React.createClass({ } }, + _onInviteBadgeClick: function(e) { + // prevent the roomsublist collapsing + e.preventDefault(); + e.stopPropagation(); + // switch to first room in sortedList as that'll be the top of the list for the user + if (this.state.sortedList && this.state.sortedList.length > 0) { + dis.dispatch({ + action: 'view_room', + room_id: this.state.sortedList[0].roomId, + }); + } else if (this.props.extraTiles && this.props.extraTiles.length > 0) { + // Group Invites are different in that they are all extra tiles and not rooms + // XXX: this is a horrible special case because Group Invite sublist is a hack + if (this.props.extraTiles[0].props && this.props.extraTiles[0].props.group instanceof Group) { + dis.dispatch({ + action: 'view_group', + group_id: this.props.extraTiles[0].props.group.groupId, + }); + } + } + }, + _getHeaderJsx: function() { const subListNotifications = this.roomNotificationCount(); const subListNotifCount = subListNotifications[0]; @@ -286,7 +309,7 @@ const RoomSubList = React.createClass({ ; } else if (this.props.isInvite) { // no notifications but highlight anyway because this is an invite badge - badge =
!
; + badge =
!
; } // When collapsed, allow a long hover on the header to show user