[polari/wip/fmuellner/tracker: 53/55] chatView: Replace TpLogger with tracker



commit e9ca01d49dfda1027db4f6068e32417b06abecb2
Author: Florian Müllner <fmuellner gnome org>
Date:   Fri Jan 8 16:10:17 2016 +0100

    chatView: Replace TpLogger with tracker

 src/chatView.js |   32 +++++++++++++-------------------
 1 files changed, 13 insertions(+), 19 deletions(-)
---
diff --git a/src/chatView.js b/src/chatView.js
index 1f8bf4a..b3c9cd4 100644
--- a/src/chatView.js
+++ b/src/chatView.js
@@ -10,6 +10,7 @@ const Tp = imports.gi.TelepathyGLib;
 const Tpl = imports.gi.TelepathyLogger;
 
 const Lang = imports.lang;
+const LogManager = imports.logManager;
 const Mainloop = imports.mainloop;
 const PasteManager = imports.pasteManager;
 const Signals = imports.signals;
@@ -307,18 +308,12 @@ const ChatView = new Lang.Class({
             }));
         this._updateMaxNickChars(this._room.account.nickname.length);
 
-        let isRoom = room.type == Tp.HandleType.ROOM;
-        let target = new Tpl.Entity({ type: isRoom ? Tpl.EntityType.ROOM
-                                                   : Tpl.EntityType.CONTACT,
-                                      identifier: room.channel_name });
-        let logManager = Tpl.LogManager.dup_singleton();
-        this._logWalker =
-            logManager.walk_filtered_events(room.account, target,
-                                            Tpl.EventTypeMask.TEXT, null);
+        let logManager = LogManager.getDefault();
+        this._logWalker = logManager.walkEvents(room.account, room.channel_name);
 
         this._fetchingBacklog = true;
-        this._logWalker.get_events_async(NUM_INITIAL_LOG_EVENTS,
-                                         Lang.bind(this, this._onLogEventsReady));
+        this._logWalker.getEvents(NUM_INITIAL_LOG_EVENTS,
+                                  Lang.bind(this, this._onLogEventsReady));
 
         this._autoscroll = true;
 
@@ -469,11 +464,10 @@ const ChatView = new Lang.Class({
         this._roomSignals = [];
     },
 
-    _onLogEventsReady: function(lw, res) {
+    _onLogEventsReady: function(events) {
         this._hideLoadingIndicator();
         this._fetchingBacklog = false;
 
-        let [, events] = lw.get_events_finish(res);
         let messages = events.map(e => this._createMessage(e));
         this._pendingLogs = messages.concat(this._pendingLogs);
         this._insertPendingLogs();
@@ -489,18 +483,18 @@ const ChatView = new Lang.Class({
                                 source.get_received_timestamp(),
                      messageType: source.get_message_type(),
                      pendingId: valid ? id : undefined };
-        } else if (source instanceof Tpl.Event) {
-            return { nick: source.sender.alias,
+        } else {
+            return { nick: source.sender,
                      text: source.message,
                      timestamp: source.timestamp,
-                     messageType: source.get_message_type() };
+                     messageType: source.messageType };
         }
 
         throw new Error('Cannot create message from source ' + source);
     },
 
     _getReadyLogs: function() {
-        if (this._logWalker.is_end())
+        if (this._logWalker.isEnd())
             return this._pendingLogs.splice(0);
 
         let nick = this._pendingLogs[0].nick;
@@ -678,7 +672,7 @@ const ChatView = new Lang.Class({
 
     _fetchBacklog: function() {
         if (this.vadjustment.value != 0 ||
-            this._logWalker.is_end())
+            this._logWalker.isEnd())
             return Gdk.EVENT_PROPAGATE;
 
         if (this._fetchingBacklog)
@@ -688,8 +682,8 @@ const ChatView = new Lang.Class({
         this._showLoadingIndicator();
         Mainloop.timeout_add(500, Lang.bind(this,
             function() {
-                this._logWalker.get_events_async(NUM_LOG_EVENTS,
-                                                 Lang.bind(this, this._onLogEventsReady));
+                this._logWalker.getEvents(NUM_LOG_EVENTS,
+                                          Lang.bind(this, this._onLogEventsReady));
                 return GLib.SOURCE_REMOVE;
             }));
         return Gdk.EVENT_STOP;


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