[polari] roomList: Connect channel signals immediately if possible
- From: Florian Müllner <fmuellner src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [polari] roomList: Connect channel signals immediately if possible
- Date: Mon, 18 Jul 2016 11:19:40 +0000 (UTC)
commit 5a0d871d305d921739b34f0dc0b37beb5c5b56a5
Author: Florian Müllner <fmuellner gnome org>
Date: Fri Jul 15 17:59:02 2016 +0200
roomList: Connect channel signals immediately if possible
We use the channel's ::message-received and ::pending-message-removed
signals to mark rooms as active/inactive and update the highlight
counter. Currently we are only connecting to those signals when the
room's channel changed, so we fail to update rows for rooms that
already had a channel when added to the list. While this is not the
common case, it can still happen, e.g. when someone initiates a
private chat with us or when re-launched by mission-control after
a crash.
https://bugzilla.gnome.org/show_bug.cgi?id=768909
src/roomList.js | 22 +++++++++++++---------
1 files changed, 13 insertions(+), 9 deletions(-)
---
diff --git a/src/roomList.js b/src/roomList.js
index 1386d4f..10f3cf5 100644
--- a/src/roomList.js
+++ b/src/roomList.js
@@ -38,19 +38,13 @@ const RoomRow = new Lang.Class({
this.connect('key-press-event',
Lang.bind(this, this._onKeyPress));
- room.connect('notify::channel', Lang.bind(this,
- function() {
- if (!room.channel)
- return;
- room.channel.connect('message-received',
- Lang.bind(this, this._updatePending));
- room.channel.connect('pending-message-removed',
- Lang.bind(this, this._updatePending));
- }));
+ room.connect('notify::channel',
+ Lang.bind(this, this._onChannelChanged));
room.bind_property('display-name', this._roomLabel, 'label',
GObject.BindingFlags.SYNC_CREATE);
this._updatePending();
+ this._onChannelChanged();
},
get room() {
@@ -99,6 +93,16 @@ const RoomRow = new Lang.Class({
context.remove_class('inactive');
},
+ _onChannelChanged: function() {
+ if (!this._room.channel)
+ return;
+ this._room.channel.connect('message-received',
+ Lang.bind(this, this._updatePending));
+ this._room.channel.connect('pending-message-removed',
+ Lang.bind(this, this._updatePending));
+ this._updatePending();
+ },
+
_onButtonRelease: function(w, event) {
let [, button] = event.get_button();
if (button != Gdk.BUTTON_SECONDARY)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]