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 1/4] 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 (
-
+ { _t("Reject & Ignore user") }
+
+ );
+ }
break;
}
case MessageCase.ViewingRoom: {
@@ -505,8 +516,6 @@ export default createReactClass({
}
}
- const AccessibleButton = sdk.getComponent('elements.AccessibleButton');
-
let subTitleElements;
if (subTitle) {
if (!Array.isArray(subTitle)) {
@@ -554,6 +563,7 @@ export default createReactClass({
{ secondaryButton }
+ { extraComponents }
{ primaryButton }
diff --git a/src/i18n/strings/en_EN.json b/src/i18n/strings/en_EN.json
index 2e92cbd282..9acbfbd1f3 100644
--- a/src/i18n/strings/en_EN.json
+++ b/src/i18n/strings/en_EN.json
@@ -1046,6 +1046,7 @@
"Do you want to join %(roomName)s?": "Do you want to join %(roomName)s?",
"
invited you": "
invited you",
"Reject": "Reject",
+ "Reject & Ignore user": "Reject & Ignore user",
"You're previewing %(roomName)s. Want to join it?": "You're previewing %(roomName)s. Want to join it?",
"%(roomName)s can't be previewed. Do you want to join it?": "%(roomName)s can't be previewed. Do you want to join it?",
"%(roomName)s does not exist.": "%(roomName)s does not exist.",
From 873952a83e9ac886606a733415c30f1f1d8c9cdd Mon Sep 17 00:00:00 2001
From: Michael Telatynski <7t3chguy@gmail.com>
Date: Thu, 23 Jan 2020 11:51:31 +0000
Subject: [PATCH 2/4] delint
---
src/components/views/rooms/RoomPreviewBar.js | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/components/views/rooms/RoomPreviewBar.js b/src/components/views/rooms/RoomPreviewBar.js
index e9d752a80f..9af06190f7 100644
--- a/src/components/views/rooms/RoomPreviewBar.js
+++ b/src/components/views/rooms/RoomPreviewBar.js
@@ -477,7 +477,7 @@ export default createReactClass({
extraComponents.push(
{ _t("Reject & Ignore user") }
-
+ ,
);
}
break;
From 1747a621189d909c643247206d88399f76f0fa1b Mon Sep 17 00:00:00 2001
From: Michael Telatynski <7t3chguy@gmail.com>
Date: Thu, 23 Jan 2020 11:55:08 +0000
Subject: [PATCH 3/4] add missing awaits
---
src/components/structures/RoomView.js | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/src/components/structures/RoomView.js b/src/components/structures/RoomView.js
index b3dafc4acd..3f438ea909 100644
--- a/src/components/structures/RoomView.js
+++ b/src/components/structures/RoomView.js
@@ -1378,9 +1378,9 @@ export default createReactClass({
const inviteEvent = myMember.events.member;
const ignoredUsers = MatrixClientPeg.get().getIgnoredUsers();
ignoredUsers.push(inviteEvent.getSender()); // de-duped internally in the js-sdk
- cli.setIgnoredUsers(ignoredUsers);
+ await cli.setIgnoredUsers(ignoredUsers);
- cli.leave(this.state.roomId);
+ await cli.leave(this.state.roomId);
dis.dispatch({ action: 'view_next_room' });
this.setState({
rejecting: false,
From 30bfd4046d9eb135217688ddab9a8db962b6d55e Mon Sep 17 00:00:00 2001
From: Michael Telatynski <7t3chguy@gmail.com>
Date: Thu, 23 Jan 2020 12:27:25 +0000
Subject: [PATCH 4/4] improve spacing of buttons on RoomPreviewBar
---
res/css/views/rooms/_RoomPreviewBar.scss | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/res/css/views/rooms/_RoomPreviewBar.scss b/res/css/views/rooms/_RoomPreviewBar.scss
index c7d03e3523..85b6916226 100644
--- a/res/css/views/rooms/_RoomPreviewBar.scss
+++ b/res/css/views/rooms/_RoomPreviewBar.scss
@@ -117,12 +117,17 @@ limitations under the License.
.mx_RoomPreviewBar_actions {
flex-direction: column-reverse;
.mx_AccessibleButton {
- padding: 7px 50px;//extra wide
+ padding: 7px 50px; //extra wide
}
& > * {
margin-top: 12px;
}
+ .mx_AccessibleButton.mx_AccessibleButton_kind_primary {
+ // to account for the padding of the primary button which causes inconsistent look between
+ // subsequent secondary (text) buttons
+ margin-bottom: 7px;
+ }
}
}