[polari] Use actual event time over TP_CURRENT_TIME where possible



commit 4c0c726c98cb2ee32aca98901786d44e8718661e
Author: Florian Müllner <fmuellner gnome org>
Date:   Thu Oct 1 18:59:45 2015 +0200

    Use actual event time over TP_CURRENT_TIME where possible
    
    If we request a channel as result of user interaction, we *may* want
    to present it when ready, but not necessarily (for instance when
    the request takes some time and the user did something else in the
    meantime).

 src/chatView.js      |    3 +--
 src/ircParser.js     |    7 +++----
 src/joinDialog.js    |    5 ++---
 src/messageDialog.js |    4 ++--
 src/utils.js         |    9 +++++++++
 5 files changed, 17 insertions(+), 11 deletions(-)
---
diff --git a/src/chatView.js b/src/chatView.js
index 1459d05..2422921 100644
--- a/src/chatView.js
+++ b/src/chatView.js
@@ -14,7 +14,6 @@ const Utils = imports.utils;
 
 const MAX_NICK_CHARS = 8;
 const IGNORE_STATUS_TIME = 5;
-const TP_CURRENT_TIME = GLib.MAXUINT32;
 
 const SCROLL_TIMEOUT = 100; // ms
 
@@ -847,7 +846,7 @@ const ChatView = new Lang.Class({
             let param = GLib.Variant.new('(ssu)',
                                          [ account.get_object_path(),
                                            this._room.channel_name,
-                                           TP_CURRENT_TIME ]);
+                                           Utils.getTpEventTime() ]);
             notification.set_default_action_and_target('app.join-room', param);
             this._app.send_notification('pending-message-' + id, notification);
         }
diff --git a/src/ircParser.js b/src/ircParser.js
index 673cdb4..ef9f8f4 100644
--- a/src/ircParser.js
+++ b/src/ircParser.js
@@ -6,11 +6,10 @@ const AppNotifications = imports.appNotifications;
 const ChatroomManager = imports.chatroomManager;
 const Lang = imports.lang;
 const Signals = imports.signals;
+const Utils = imports.utils;
 
 const N_ = function(s) { return s; };
 
-const TP_CURRENT_TIME = GLib.MAXUINT32;
-
 const knownCommands = {
     /* commands that would be nice to support: */
     /*
@@ -132,7 +131,7 @@ const IrcParser = new Lang.Class({
                 action.activate(GLib.Variant.new('(ssu)',
                                                  [ account.get_object_path(),
                                                    room,
-                                                   TP_CURRENT_TIME ]));
+                                                   Utils.getTpEventTime() ]));
                 break;
             }
             case 'KICK': {
@@ -222,7 +221,7 @@ const IrcParser = new Lang.Class({
                 action.activate(GLib.Variant.new('(ssu)',
                                                  [ account.get_object_path(),
                                                    nick,
-                                                   TP_CURRENT_TIME ]));
+                                                   Utils.getTpEventTime() ]));
                 break;
             }
             case 'QUIT': {
diff --git a/src/joinDialog.js b/src/joinDialog.js
index 74d8f54..5b26ec0 100644
--- a/src/joinDialog.js
+++ b/src/joinDialog.js
@@ -7,8 +7,7 @@ const Tpl = imports.gi.TelepathyLogger;
 const AccountsMonitor = imports.accountsMonitor;
 const Connections = imports.connections;
 const Lang = imports.lang;
-
-const TP_CURRENT_TIME = GLib.MAXUINT32;
+const Utils = imports.utils;
 
 const DialogPage = {
     MAIN: 0,
@@ -162,7 +161,7 @@ const JoinDialog = new Lang.Class({
         action.activate(GLib.Variant.new('(ssu)',
                                          [ account.get_object_path(),
                                            room,
-                                           TP_CURRENT_TIME ]));
+                                           Utils.getTpEventTime() ]));
     },
 
     _updateConnectionCombo: function() {
diff --git a/src/messageDialog.js b/src/messageDialog.js
index b2545e4..9f49065 100644
--- a/src/messageDialog.js
+++ b/src/messageDialog.js
@@ -6,8 +6,8 @@ const Tpl = imports.gi.TelepathyLogger;
 
 const AccountsMonitor = imports.accountsMonitor;
 const Lang = imports.lang;
+const Utils = imports.utils;
 
-const TP_CURRENT_TIME = GLib.MAXUINT32;
 const MAX_RECENT_USERS = 5;
 
 const MessageDialog = new Lang.Class({
@@ -177,7 +177,7 @@ const MessageDialog = new Lang.Class({
         action.activate(GLib.Variant.new('(ssu)',
                                          [ account.get_object_path(),
                                            user,
-                                           TP_CURRENT_TIME ]));
+                                           Utils.getTpEventTime() ]));
     },
 
     _updateCanConfirm: function() {
diff --git a/src/utils.js b/src/utils.js
index eb912c9..df0f480 100644
--- a/src/utils.js
+++ b/src/utils.js
@@ -21,7 +21,9 @@
  */
 
 const GLib = imports.gi.GLib;
+const Gtk = imports.gi.Gtk;
 const Soup = imports.gi.Soup;
+const Tp = imports.gi.TelepathyGLib;
 
 const Signals = imports.signals;
 
@@ -78,6 +80,13 @@ function addJSSignalMethods(proto) {
     proto.disconnectAllJS = Signals._disconnectAll;
 }
 
+function getTpEventTime() {
+    let time = Gtk.get_current_event_time ();
+    if (time == 0)
+      return GLib.MAXUINT32;
+    return Tp.user_action_time_from_x11 (time);
+}
+
 // findUrls:
 // @str: string to find URLs in
 //


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