[polari/wip/fmuellner/tracker: 87/88] chatView: Replace TpLogger with tracker
- From: Florian Müllner <fmuellner src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [polari/wip/fmuellner/tracker: 87/88] chatView: Replace TpLogger with tracker
- Date: Thu, 9 Mar 2017 22:21:09 +0000 (UTC)
commit 015a8a2905959073c5f366bf3dacdb2f6a3a15e9
Author: Florian Müllner <fmuellner gnome org>
Date: Fri Jan 8 16:10:17 2016 +0100
chatView: Replace TpLogger with tracker
configure.ac | 2 +-
src/chatView.js | 33 +++++++++++++--------------------
2 files changed, 14 insertions(+), 21 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index 01e42d1..c9665be 100644
--- a/configure.ac
+++ b/configure.ac
@@ -55,7 +55,7 @@ AX_CHECK_GIRS_GJS([PangoCairo], [1.0])
AX_CHECK_GIRS_GJS([Secret], [1])
AX_CHECK_GIRS_GJS([Soup], [2.4])
AX_CHECK_GIRS_GJS([TelepathyGLib], [0.12])
-AX_CHECK_GIRS_GJS([TelepathyLogger], [0.2])
+AX_CHECK_GIRS_GJS([Tracker], [1.0])
AC_PROG_LN_S
diff --git a/src/chatView.js b/src/chatView.js
index f3f3c3b..8bbf718 100644
--- a/src/chatView.js
+++ b/src/chatView.js
@@ -7,9 +7,9 @@ const Pango = imports.gi.Pango;
const PangoCairo = imports.gi.PangoCairo;
const Polari = imports.gi.Polari;
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;
@@ -371,18 +371,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);
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;
@@ -549,11 +543,10 @@ const ChatView = new Lang.Class({
this._logWalker = null;
},
- _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();
@@ -569,18 +562,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;
@@ -732,7 +725,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)
@@ -742,8 +735,8 @@ const ChatView = new Lang.Class({
this._showLoadingIndicator();
this._backlogTimeoutId = 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));
this._backlogTimeoutId = 0;
return GLib.SOURCE_REMOVE;
}));
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]