[polari] chatView: Mark all users as offline upon connection loss
- From: Florian Müllner <fmuellner src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [polari] chatView: Mark all users as offline upon connection loss
- Date: Fri, 10 Jun 2016 20:06:48 +0000 (UTC)
commit 6586693076e6c562e41923f8cbfbe8d1832a0d36
Author: raresv <rares visalom gmail com>
Date: Fri Jun 10 15:44:26 2016 +0300
chatView: Mark all users as offline upon connection loss
We currently update tracked contacts when a connection is
established, but we don't update their status when the
connection is lost. The problem with this is that
whenever an unexpected connection failure occurs, the
color of each nick remains the same as before the connection
failure (the color is not updated). Therefore, upon
reconnecting, some users will have the wrong color set (i.e.
if the user left before we reconnected, he/she will still
be marked as online).
To fix this, each time there is no channel set, mark all users
as offline.
https://bugzilla.gnome.org/show_bug.cgi?id=763868
src/chatView.js | 35 ++++++++++++++++++++++-------------
1 files changed, 22 insertions(+), 13 deletions(-)
---
diff --git a/src/chatView.js b/src/chatView.js
index 4be3765..a789070 100644
--- a/src/chatView.js
+++ b/src/chatView.js
@@ -376,6 +376,14 @@ const ChatView = new Lang.Class({
});
},
+ _foreachNickTag: function(func) {
+ let tagTable = this._view.get_buffer().get_tag_table();
+ tagTable.foreach(function(tag) {
+ if (tag._contacts)
+ func(tag);
+ });
+ },
+
_resetNickTag: function(nickTag) {
nickTag._contacts = [];
this._updateTagStatus(nickTag);
@@ -435,10 +443,7 @@ const ChatView = new Lang.Class({
}
});
- tagTable.foreach(Lang.bind(this, function(tag) {
- if (tag._contacts)
- this._updateTagStatus(tag);
- }));
+ this._foreachNickTag(t => { this._updateTagStatus(t); });
},
vfunc_destroy: function() {
@@ -822,6 +827,19 @@ const ChatView = new Lang.Class({
: this._room.account.nickname;
this._updateMaxNickChars(nick.length);
+ if (this._channel) {
+ if (this._room.type == Tp.HandleType.ROOM) {
+ let members = this._channel.group_dup_members_contacts();
+ for (let j = 0; j < members.length; j++)
+ this._trackContact(members[j]);
+ } else {
+ this._trackContact(this._channel.connection.self_contact);
+ this._trackContact(this._channel.target_contact);
+ }
+ } else {
+ this._foreachNickTag(t => { this._resetNickTag(t); });
+ }
+
if (!this._channel)
return;
@@ -844,15 +862,6 @@ const ChatView = new Lang.Class({
this._insertTpMessage(this._room, message);
}));
this._checkMessages();
-
- if (this._room.type == Tp.HandleType.ROOM) {
- let members = this._channel.group_dup_members_contacts();
- for (let j = 0; j < members.length; j++)
- this._trackContact(members[j]);
- } else {
- this._trackContact(this._channel.connection.self_contact);
- this._trackContact(this._channel.target_contact);
- }
},
_onMemberRenamed: function(room, oldMember, newMember) {
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]