[polari/wip/raresv/userTrackerAndPopoversRebase: 16/24] chatView: split the _createNickTag() method and the _onStatusChangedCallback() method. _createNickTa
- From: Rares Visalom <raresvisalom src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [polari/wip/raresv/userTrackerAndPopoversRebase: 16/24] chatView: split the _createNickTag() method and the _onStatusChangedCallback() method. _createNickTa
- Date: Fri, 5 Aug 2016 23:41:32 +0000 (UTC)
commit 558688cfcd8b587ea92b989c02e5ba7c7006de75
Author: raresv <rares visalom gmail com>
Date: Thu Aug 4 14:44:09 2016 +0300
chatView: split the _createNickTag() method and the _onStatusChangedCallback() method. _createNickTag is
duplicated and will be removed in the future. Replace the use of the old global tracker with the new one.
src/chatView.js | 36 ++++++++++++++++++++++++++++--------
1 files changed, 28 insertions(+), 8 deletions(-)
---
diff --git a/src/chatView.js b/src/chatView.js
index c46ee9a..4e7bddd 100644
--- a/src/chatView.js
+++ b/src/chatView.js
@@ -298,10 +298,7 @@ const ChatView = new Lang.Class({
this._pending = {};
this._pendingLogs = [];
this._statusCount = { left: 0, joined: 0, total: 0 };
- this._chatroomManager = ChatroomManager.getDefault();
-
- this._userTracker = new UserTracker.UserTracker(this._room);
- this._userTracker.connect('status-changed', Lang.bind(this, this._onNickStatusChanged));
+ this._userStatusMonitor = UserTracker.getUserStatusMonitor();
this._room.account.connect('notify::nickname', Lang.bind(this,
function() {
@@ -354,6 +351,9 @@ const ChatView = new Lang.Class({
this._roomSignals.push(room.connect(signal.name, signal.handler));
}));
this._onChannelChanged();
+
+ /*where should we unwatch? int onChannelChanged when we don't have a channel?*/
+ this._roomWatchHandler =
this._userStatusMonitor.getUserTrackerForAccount(this._room.account).watchUser(this._room, null,
Lang.bind(this, this._onStatusChangedCallback));
},
_createTags: function() {
@@ -1177,7 +1177,7 @@ const ChatView = new Lang.Class({
nickTag = this._createNickTag(nickTagName);
buffer.get_tag_table().add(nickTag);
- this._updateNickTag(nickTag, this._userTracker.getNickStatus(message.nick));
+ this._updateNickTag(nickTag,
this._userStatusMonitor.getUserTrackerForAccount(this._room.account).getNickStatus(message.nick));
}
tags.push(nickTag);
if (needsGap)
@@ -1215,6 +1215,28 @@ const ChatView = new Lang.Class({
this._insertWithTags(iter, text.substr(pos), tags);
},
+ _createNickTag: function(nickName) {
+ let nickTagName = this._getNickTagName(nickName);
+
+ let tag = new Gtk.TextTag({ name: nickTagName });
+ //this._updateNickTag(tag,
this._userStatusMonitor.getUserTrackerForAccount(this._room.account).getNickRoomStatus(nickName, this._room));
+ this._updateNickTag(tag, Tp.ConnectionPresenceType.OFFLINE);
+
+ return tag;
+ },
+
+ _onStatusChangedCallback: function(nick, status) {
+ log("Nick " + nick + " has local status " + status);
+
+ let nickTagName = this._getNickTagName(nick);
+ let nickTag = this._lookupTag(nickTagName);
+
+ if (!nickTag)
+ return;
+
+ this._updateNickTag(nickTag, status);
+ },
+
_updateNickTag: function(tag, status) {
if (status == Tp.ConnectionPresenceType.AVAILABLE)
tag.foreground_rgba = this._activeNickColor;
@@ -1224,7 +1246,7 @@ const ChatView = new Lang.Class({
_createNickTag: function(name) {
let tag = new ButtonTag({ name: name });
- tag._popover = new UserList.UserPopover({ relative_to: this._view, margin: 0, room: this._room,
userTracker: this._userTracker });
+ tag._popover = new UserList.UserPopover({ relative_to: this._view, margin: 0, room: this._room,
userTracker: this._userStatusMonitor.getUserTrackerForAccount(this._room.account) });
tag.connect('clicked', Lang.bind(this, this._onNickTagClicked));
return tag;
},
@@ -1258,8 +1280,6 @@ const ChatView = new Lang.Class({
tag._popover.nickname = actualNickName;
- //tag._popover.user = this._userTracker.getBestMatchingContact(actualNickName);
-
tag._popover.pointing_to = rect1;
tag._popover.show();
},
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]