[polari/wip/fmuellner/combined-gsoc: 97/137] chatView: Clean up a bit
- From: Florian Müllner <fmuellner src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [polari/wip/fmuellner/combined-gsoc: 97/137] chatView: Clean up a bit
- Date: Thu, 28 Jul 2016 16:23:36 +0000 (UTC)
commit e81529c52163d56fdabf21d0f6951ab606d49b3e
Author: Florian Müllner <fmuellner gnome org>
Date: Tue Jul 19 23:50:02 2016 +0200
chatView: Clean up a bit
src/chatView.js | 35 ++++++++++++++++++-----------------
1 files changed, 18 insertions(+), 17 deletions(-)
---
diff --git a/src/chatView.js b/src/chatView.js
index bc7bf89..3b18091 100644
--- a/src/chatView.js
+++ b/src/chatView.js
@@ -306,7 +306,8 @@ const ChatView = new Lang.Class({
this._statusCount = { left: 0, joined: 0, total: 0 };
this._logWalker = null;
- this._userStatusMonitor = UserTracker.getUserStatusMonitor();
+ let statusMonitor = UserTracker.getUserStatusMonitor();
+ this._userTracker = statusMonitor.getUserTrackerForAccount(room.account);
this._room.account.connect('notify::nickname', Lang.bind(this,
function() {
@@ -346,8 +347,14 @@ const ChatView = new Lang.Class({
}));
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));
+ this._roomStatusChangedId =
+ this._userTracker.watchUser(this._room, null,
+ Lang.bind(this, this._onStatusChanged));
+
+ this.connect('destroy', () => {
+ this._userTracker.unwatchUser(this._room, this._roomStatusChangedId);
+ this._userTracker = null;
+ });
},
_createTags: function() {
@@ -1212,7 +1219,8 @@ const ChatView = new Lang.Class({
nickTag = this._createNickTag(nickTagName);
buffer.get_tag_table().add(nickTag);
- this._updateNickTag(nickTag,
this._userStatusMonitor.getUserTrackerForAccount(this._room.account).getNickStatus(message.nick));
+ let status = this._userTracker.getNickStatus(message.nick));
+ this._updateNickTag(nickTag, status);
}
tags.push(nickTag);
if (needsGap)
@@ -1254,17 +1262,7 @@ const ChatView = new Lang.Class({
this._view.buffer.create_mark(null, iter, true));
},
- /*_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) {
+ _onStatusChanged: function(nick, status) {
let nickTagName = this._getNickTagName(nick);
let nickTag = this._lookupTag(nickTagName);
@@ -1283,7 +1281,6 @@ 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._userStatusMonitor.getUserTrackerForAccount(this._room.account), width_request: 280 });
tag.connect('clicked', Lang.bind(this, this._onNickTagClicked));
return tag;
},
@@ -1316,7 +1313,11 @@ const ChatView = new Lang.Class({
let actualNickName = view.get_buffer().get_slice(start, end, false);
if (!tag._popover)
- tag._popover = new UserList.UserPopover({ relative_to: this._view, margin: 0, room: this._room,
userTracker: this._userStatusMonitor.getUserTrackerForAccount(this._room.account), width_request: 280 });
+ tag._popover = new UserList.UserPopover({ relative_to: this._view,
+ margin: 0,
+ room: this._room,
+ userTracker: this._userTracker,
+ width_request: 280 });
tag._popover.nickname = actualNickName;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]