From 6c3ac2d0c4585798ba82b913b6ac42b87129c42c Mon Sep 17 00:00:00 2001 From: Michael Telatynski <7t3chguy@gmail.com> Date: Thu, 23 Jan 2020 11:50:59 +0000 Subject: [PATCH] Add Reject & Ignore user button to invites view --- src/components/structures/RoomView.js | 39 +++++++++++++++++++- src/components/views/rooms/RoomPreviewBar.js | 14 ++++++- src/i18n/strings/en_EN.json | 1 + 3 files changed, 51 insertions(+), 3 deletions(-) diff --git a/src/components/structures/RoomView.js b/src/components/structures/RoomView.js index 9b02f6d503..b3dafc4acd 100644 --- a/src/components/structures/RoomView.js +++ b/src/components/structures/RoomView.js @@ -1367,6 +1367,41 @@ export default createReactClass({ }); }, + onRejectAndIgnoreClick: async function() { + this.setState({ + rejecting: true, + }); + + const cli = MatrixClientPeg.get(); + try { + const myMember = this.state.room.getMember(cli.getUserId()); + const inviteEvent = myMember.events.member; + const ignoredUsers = MatrixClientPeg.get().getIgnoredUsers(); + ignoredUsers.push(inviteEvent.getSender()); // de-duped internally in the js-sdk + cli.setIgnoredUsers(ignoredUsers); + + cli.leave(this.state.roomId); + dis.dispatch({ action: 'view_next_room' }); + this.setState({ + rejecting: false, + }); + } catch (error) { + console.error("Failed to reject invite: %s", error); + + const msg = error.message ? error.message : JSON.stringify(error); + const ErrorDialog = sdk.getComponent("dialogs.ErrorDialog"); + Modal.createTrackedDialog('Failed to reject invite', '', ErrorDialog, { + title: _t("Failed to reject invite"), + description: msg, + }); + + self.setState({ + rejecting: false, + rejectError: error, + }); + } + }, + onRejectThreepidInviteButtonClicked: function(ev) { // We can reject 3pid invites in the same way that we accept them, // using /leave rather than /join. In the short term though, we @@ -1671,9 +1706,11 @@ export default createReactClass({ return (