[polari/wip/fmuellner/log-highlighting: 6/6] chatView: Highlight mentions in the backlog



commit 0e124d5c07367fc1561a4c5ab65af2659b75993f
Author: Florian Müllner <fmuellner gnome org>
Date:   Sat Jul 9 02:32:05 2016 +0200

    chatView: Highlight mentions in the backlog
    
    We generally try to minimize differences between messages that we
    sent or received, and messages that we fetched from the logs.
    In other words, when restarting polari, the state after the restart
    should match the one before as closely as possible. Besides status
    messages that are not logged, the most glaring difference for now is
    that we don't restore message highlights in the backlog. However
    highlighting mentions is not only useful in the active session, it
    can be just as helpful while skimming through the backlogs, so not
    having them in logs is actually worse than introducing some visual
    inconsistency. Luckily PolariRoom's should_highlight_message()
    is now capable of handling this case, so we can finally fix this.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=768613

 src/chatView.js |   13 ++++++-------
 1 files changed, 6 insertions(+), 7 deletions(-)
---
diff --git a/src/chatView.js b/src/chatView.js
index a8099e8..bc433b6 100644
--- a/src/chatView.js
+++ b/src/chatView.js
@@ -502,8 +502,7 @@ const ChatView = new Lang.Class({
             let message = { nick: pending[i].sender.alias,
                             text: pending[i].message,
                             timestamp: pending[i].timestamp,
-                            messageType: pending[i].get_message_type(),
-                            shouldHighlight: false };
+                            messageType: pending[i].get_message_type() };
             this._insertMessage(iter, message, state);
 
             if (!iter.is_end() || i < pending.length - 1)
@@ -1145,7 +1144,7 @@ const ChatView = new Lang.Class({
             timestamp = tpMessage.get_received_timestamp();
         message.timestamp = timestamp;
 
-        message.shouldHighlight = this._room.should_highlight_message(message.nick, text);
+        let shouldHighlight = this._room.should_highlight_message(message.nick, text);
 
         this._ensureNewLine();
 
@@ -1155,7 +1154,7 @@ const ChatView = new Lang.Class({
 
         let [id, valid] = tpMessage.get_pending_message_id();
 
-        if (message.shouldHighlight &&
+        if (shouldHighlight &&
             !(this._toplevelFocus && this._active)) {
             let summary = '%s %s'.format(this._room.display_name, message.nick);
             let notification = new Gio.Notification();
@@ -1175,10 +1174,10 @@ const ChatView = new Lang.Class({
         if (!valid /* outgoing */ ||
             (this._active && this._toplevelFocus && this._nPending == 0)) {
             this._channel.ack_message_async(tpMessage, null);
-        } else if (message.shouldHighlight || this._needsIndicator) {
+        } else if (shouldHighlight || this._needsIndicator) {
             let iter = buffer.get_end_iter();
 
-            if (message.shouldHighlight) {
+            if (shouldHighlight) {
                 let mark = buffer.create_mark(null, iter, true);
                 this._pending[id] = mark;
             }
@@ -1249,7 +1248,7 @@ const ChatView = new Lang.Class({
             tags.push(this._lookupTag('message'));
         }
 
-        if (message.shouldHighlight)
+        if (this._room.should_highlight_message(message.nick, message.text))
             tags.push(this._lookupTag('highlight'));
 
         let params = this._room.account.dup_parameters_vardict().deep_unpack();


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]