[polari/wip/raresv/userTracker] tags are now updated based on the UserTracker, userTracker part 14
- From: Rares Visalom <raresvisalom src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [polari/wip/raresv/userTracker] tags are now updated based on the UserTracker, userTracker part 14
- Date: Wed, 6 Jul 2016 16:08:15 +0000 (UTC)
commit c3816a8ac1b37230a0f9dfc655d258a478a0b322
Author: raresv <rares visalom gmail com>
Date: Wed Jul 6 19:07:55 2016 +0300
tags are now updated based on the UserTracker, userTracker part 14
src/chatView.js | 19 ++++++++++++++-----
src/userTracker.js | 23 +++++++++++++++++------
2 files changed, 31 insertions(+), 11 deletions(-)
---
diff --git a/src/chatView.js b/src/chatView.js
index 2f48cd5..a0c8d18 100644
--- a/src/chatView.js
+++ b/src/chatView.js
@@ -381,10 +381,6 @@ const ChatView = new Lang.Class({
});
},
- _onStatusChangedCallback: function(nick, status) {
- log("Nick " + nick + " has local status " + status);
- },
-
_onStyleUpdated: function() {
let context = this.get_style_context();
context.save();
@@ -1209,11 +1205,24 @@ const ChatView = new Lang.Class({
let nickTagName = this._getNickTagName(nickName);
let tag = new Gtk.TextTag({ name: nickTagName });
- //this._updateNickTag(tag, this._userTracker.getNickGlobalStatus(nickName));
+ //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;
diff --git a/src/userTracker.js b/src/userTracker.js
index 1aecd84..0f4931f 100644
--- a/src/userTracker.js
+++ b/src/userTracker.js
@@ -156,7 +156,8 @@ const UserTracker = new Lang.Class({
/*since we have no channel, all users must be locally marked offline. so call the callbacks*/
for ([handlerID, handlerInfo] of this._roomMapping.get(emittingRoom)._handlerMapping) {
- handlerInfo.handler(handlerInfo.nickName, Tp.ConnectionPresenceType.OFFLINE);
+ if (handlerInfo.nickName)
+ handlerInfo.handler(handlerInfo.nickName, Tp.ConnectionPresenceType.OFFLINE);
}
}
},
@@ -242,9 +243,10 @@ const UserTracker = new Lang.Class({
if (map == this._globalContactMapping)log("length: " +
this._globalContactMapping.get(baseNick).length)
if (map.get(baseNick).length == 1)
- if (map == this._globalContactMapping)
- //this.emit("global-status-changed::" + member.alias, Tp.ConnectionPresenceType.AVAILABLE);
+ if (map == this._globalContactMapping) {
+ this.emit("global-status-changed::" + member.alias, Tp.ConnectionPresenceType.AVAILABLE);
log("[global status] user " + member.alias + " is globally online");
+ }
else
//log("[Local UserTracker] User " + member.alias + " is now available in room " +
member._room.channelName + " on " + this._account.get_display_name());
for ([handlerID, handlerInfo] of this._roomMapping.get(room)._handlerMapping)
@@ -265,9 +267,10 @@ const UserTracker = new Lang.Class({
let removedMember = contacts.splice(indexToDelete, 1)[0];
if (contacts.length == 0)
- if (map == this._globalContactMapping)
- //this.emit("global-status-changed::" + member.alias, Tp.ConnectionPresenceType.OFFLINE);
+ if (map == this._globalContactMapping) {
+ this.emit("global-status-changed::" + member.alias, Tp.ConnectionPresenceType.OFFLINE);
log("[global status] user " + member.alias + " is globally offline");
+ }
else
//log("[Local UserTracker] User " + member.alias + " is now offline in room " +
member._room.channelName + " on " + this._account.get_display_name());
for ([handlerID, handlerInfo] of this._roomMapping.get(room)._handlerMapping)
@@ -278,7 +281,7 @@ const UserTracker = new Lang.Class({
}
},
- getNickGlobalStatus: function(nickName) {
+ getNickStatus: function(nickName) {
let baseNick = Polari.util_get_basenick(nickName);
let contacts = this._globalContactMapping.get(baseNick) || [];
@@ -286,6 +289,14 @@ const UserTracker = new Lang.Class({
: Tp.ConnectionPresenceType.AVAILABLE;
},
+ getNickRoomStatus: function(nickName, room) {
+ let baseNick = Polari.util_get_basenick(nickName);
+
+ let contacts = this._roomMapping.get(room)._contactMapping.get(baseNick) || [];
+ return contacts.length == 0 ? Tp.ConnectionPresenceType.OFFLINE
+ : Tp.ConnectionPresenceType.AVAILABLE;
+ },
+
watchUser: function(room, nick, callback) {
this._ensureRoomMappingForRoom(room);
this._ensureHandlerMappingForRoom(room);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]