From 50d09f73f5d7a6a3a494d65f5b788bc283151140 Mon Sep 17 00:00:00 2001 From: Matthew Hodgson Date: Sun, 28 Aug 2016 00:00:22 +0100 Subject: [PATCH] add leave/forget button to RoomSettings --- src/components/views/rooms/RoomSettings.js | 42 ++++++++++++++++++++++ 1 file changed, 42 insertions(+) diff --git a/src/components/views/rooms/RoomSettings.js b/src/components/views/rooms/RoomSettings.js index 894012d74e..145b8559b7 100644 --- a/src/components/views/rooms/RoomSettings.js +++ b/src/components/views/rooms/RoomSettings.js @@ -426,6 +426,27 @@ module.exports = React.createClass({ }, ""); }, + onLeaveClick() { + dis.dispatch({ + action: 'leave_room', + room_id: this.props.room.roomId, + }); + }, + + onForgetClick() { + // FIXME: duplicated with RoomTagContextualMenu (and dead code in RoomView) + MatrixClientPeg.get().forget(this.props.room.roomId).done(function() { + dis.dispatch({ action: 'view_next_room' }); + }, function(err) { + var errCode = err.errcode || "unknown error code"; + var ErrorDialog = sdk.getComponent("dialogs.ErrorDialog"); + Modal.createDialog(ErrorDialog, { + title: "Error", + description: `Failed to forget room (${errCode})` + }); + }); + }, + _renderEncryptionSection: function() { if (!UserSettingsStore.isFeatureEnabled("e2e_encryption")) { return null; @@ -544,6 +565,25 @@ module.exports = React.createClass({ ); } + var leaveButton = null; + var myMember = this.props.room.getMember(user_id); + if (myMember) { + if (myMember.membership === "join") { + leaveButton = ( +
+ Leave room +
+ ); + } + else if (myMember.membership === "leave") { + leaveButton = ( +
+ Forget room +
+ ); + } + } + // TODO: support editing custom events_levels // TODO: support editing custom user_levels @@ -631,6 +671,8 @@ module.exports = React.createClass({ return (
+ { leaveButton } + { tagsSection }