From 52299ce98765c64b382a223017f0e6404cdd22c5 Mon Sep 17 00:00:00 2001 From: Steve Howell Date: Thu, 12 Oct 2017 13:11:43 -0700 Subject: [PATCH] Highlight alert words in mentions you send to yourself. Fixes #6946. --- static/js/alert_words.js | 8 +++++++- static/js/echo.js | 10 ++++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/static/js/alert_words.js b/static/js/alert_words.js index fed423e0f4..3c5025472e 100644 --- a/static/js/alert_words.js +++ b/static/js/alert_words.js @@ -14,7 +14,9 @@ function escape_user_regex(value) { } exports.process_message = function (message) { - if (!exports.notifies(message)) { + // Parsing for alert words is expensive, so we rely on the host + // to tell us there any alert words to even look for. + if (!message.alerted) { return; } @@ -47,6 +49,10 @@ exports.process_message = function (message) { }; exports.notifies = function (message) { + // We exclude ourselves from notifications when we type one of our own + // alert words into a message, just because that can be annoying for + // certain types of workflows where everybody on your team, including + // yourself, sets up an alert word to effectively mention the team. return !people.is_current_user(message.sender_email) && message.alerted; }; diff --git a/static/js/echo.js b/static/js/echo.js index 483a62015a..2e38017631 100644 --- a/static/js/echo.js +++ b/static/js/echo.js @@ -230,6 +230,16 @@ exports.process_from_server = function process_from_server(messages) { sent_messages.mark_disparity(message.local_id); } + // Update our flags based on what the server gave us. + client_message.flags = message.flags; + message_store.set_message_booleans(client_message, client_message.flags); + + // We don't try to highlight alert words locally, so we have to + // do it now. (Note that we will indeed highlight alert words in + // messages that we sent to ourselves, since we might want to test + // that our alert words are set up correctly.) + alert_words.process_message(client_message); + // Previously, the message had the "local echo" timestamp set // by the browser; if there was some round-trip delay to the // server, the actual server-side timestamp could be slightly