[polari] chatView: Ignore status messages for some time after joining
- From: Florian Müllner <fmuellner src gnome org>
 
- To: commits-list gnome org
 
- Cc: 
 
- Subject: [polari] chatView: Ignore status messages for some time after joining
 
- Date: Thu, 17 Oct 2013 21:38:38 +0000 (UTC)
 
commit d2bbe17a76578eb8f2edfd5464835fe097546295
Author: Florian Müllner <fmuellner gnome org>
Date:   Wed Oct 16 07:36:46 2013 +0200
    chatView: Ignore status messages for some time after joining
    
    Tp doesn't distinguish between members that we discover after
    joining and members that actually join after us, resulting in
    a flood of join status messages when joining a busy room.
    Work around this the same way Empathy does, by ignoring these
    events for a couple of seconds after joining.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=710006
 src/chatView.js |    6 ++++++
 1 files changed, 6 insertions(+), 0 deletions(-)
---
diff --git a/src/chatView.js b/src/chatView.js
index 34bfe22..3e6df61 100644
--- a/src/chatView.js
+++ b/src/chatView.js
@@ -1,4 +1,5 @@
 const Gdk = imports.gi.Gdk;
+const GLib = imports.gi.GLib;
 const Gio = imports.gi.Gio;
 const Gtk = imports.gi.Gtk;
 const Pango = imports.gi.Pango;
@@ -9,6 +10,7 @@ const Notify = imports.notify;
 const Utils = imports.utils;
 
 const MAX_NICK_CHARS = 8;
+const IGNORE_STATUS_TIME = 5;
 
 // Workaround for GtkTextView growing horizontally over time when
 // added to a GtkScrolledWindow with horizontal scrolling disabled
@@ -35,6 +37,7 @@ const ChatView = new Lang.Class({
         this._lastNick = null;
         this._active = false;
         this._toplevelFocus = false;
+        this._joinTime = GLib.DateTime.new_now_utc().to_unix();
         this._maxNickChars = MAX_NICK_CHARS;
         this._hoveringLink = false;
         this._pending = [];
@@ -337,6 +340,9 @@ const ChatView = new Lang.Class({
     },
 
     _insertStatus: function(text) {
+        let time = GLib.DateTime.new_now_utc().to_unix();
+        if (time - this._joinTime < IGNORE_STATUS_TIME)
+            return;
         this._lastNick = null;
         this._ensureNewLine();
         this._insertWithTagName(text, 'status');
[
Date Prev][
Date Next]   [
Thread Prev][
Thread Next]   
[
Thread Index]
[
Date Index]
[
Author Index]