From 13a251e29cfbee4fa615bff9a3f94183c722461c Mon Sep 17 00:00:00 2001 From: Travis Ralston Date: Thu, 14 Sep 2017 16:21:36 -0600 Subject: [PATCH] Give feedback for /ignore and /unignore Signed-off-by: Travis Ralston --- src/SlashCommands.js | 32 ++++++++++++++++++++++++++++---- src/i18n/strings/en_EN.json | 4 ++++ src/i18n/strings/en_US.json | 4 ++++ 3 files changed, 36 insertions(+), 4 deletions(-) diff --git a/src/SlashCommands.js b/src/SlashCommands.js index b72ea341b5..a7551a789c 100644 --- a/src/SlashCommands.js +++ b/src/SlashCommands.js @@ -244,10 +244,22 @@ const commands = { if (args) { const matches = args.match(/^(\S+)$/); if (matches) { + const userId = matches[1]; const ignoredUsers = MatrixClientPeg.get().getIgnoredUsers(); - ignoredUsers.push(matches[1]); // de-duped internally below + ignoredUsers.push(userId); // de-duped internally below return success( - MatrixClientPeg.get().setIgnoredUsers(ignoredUsers), + MatrixClientPeg.get().setIgnoredUsers(ignoredUsers).then(() => { + const QuestionDialog = sdk.getComponent("dialogs.QuestionDialog"); + Modal.createTrackedDialog('Slash Commands', 'User ignored', QuestionDialog, { + title: _t("Ignored user"), + description: ( +
+

{_t("You are now ignoring %(userId)s", {userId: userId})}

+
+ ), + hasCancelButton: false, + }); + }), ); } } @@ -258,11 +270,23 @@ const commands = { if (args) { const matches = args.match(/^(\S+)$/); if (matches) { + const userId = matches[1]; const ignoredUsers = MatrixClientPeg.get().getIgnoredUsers(); - const index = ignoredUsers.indexOf(matches[1]); + const index = ignoredUsers.indexOf(userId); if (index !== -1) ignoredUsers.splice(index, 1); return success( - MatrixClientPeg.get().setIgnoredUsers(ignoredUsers), + MatrixClientPeg.get().setIgnoredUsers(ignoredUsers).then(() => { + const QuestionDialog = sdk.getComponent("dialogs.QuestionDialog"); + Modal.createTrackedDialog('Slash Commands', 'User unignored', QuestionDialog, { + title: _t("Unignored user"), + description: ( +
+

{_t("You are no longer ignoring %(userId)s", {userId: userId})}

+
+ ), + hasCancelButton: false, + }); + }), ); } } diff --git a/src/i18n/strings/en_EN.json b/src/i18n/strings/en_EN.json index 57870a18e4..9b3135fa07 100644 --- a/src/i18n/strings/en_EN.json +++ b/src/i18n/strings/en_EN.json @@ -266,6 +266,10 @@ "Labs": "Labs", "Ignored Users": "Ignored Users", "Unignore": "Unignore", + "You are now ignoring %(userId)s": "You are now ignoring %(userId)s", + "You are no longer ignoring %(userId)s": "You are no longer ignoring %(userId)s", + "Unignored user": "Unignored user", + "Ignored user": "Ignored user", "Last seen": "Last seen", "Leave room": "Leave room", "left and rejoined": "left and rejoined", diff --git a/src/i18n/strings/en_US.json b/src/i18n/strings/en_US.json index 225d6e28d7..7051967abc 100644 --- a/src/i18n/strings/en_US.json +++ b/src/i18n/strings/en_US.json @@ -233,6 +233,10 @@ "Labs": "Labs", "Ignored Users": "Ignored Users", "Unignore": "Unignore", + "You are now ignoring %(userId)s": "You are now ignoring %(userId)s", + "You are no longer ignoring %(userId)s": "You are no longer ignoring %(userId)s", + "Unignored user": "Unignored user", + "Ignored user": "Ignored user", "Leave room": "Leave room", "left and rejoined": "left and rejoined", "left": "left",