[polari] roomList: Only show unread counter for highlighted messages
- From: Florian Müllner <fmuellner src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [polari] roomList: Only show unread counter for highlighted messages
- Date: Sat, 12 Oct 2013 19:33:24 +0000 (UTC)
commit cb69f7d3a62ea83e15246eb30503d39311e40c1d
Author: Florian Müllner <fmuellner gnome org>
Date: Thu Oct 10 19:47:46 2013 +0100
roomList: Only show unread counter for highlighted messages
Indicating every single unread message prominently pushes users to
make sure to read up all missed messages, however irrelevant they
are to them. Instead, reserve the prominent message counter to
highlighted messages, which we can assume to be relevant.
While at it, stop using bold labels for rooms with highlighted messages,
as the counter is already prominent enough.
https://bugzilla.gnome.org/show_bug.cgi?id=709842
src/roomList.js | 37 ++++++++++++++++---------------------
1 files changed, 16 insertions(+), 21 deletions(-)
---
diff --git a/src/roomList.js b/src/roomList.js
index 23107da..0d2c022 100644
--- a/src/roomList.js
+++ b/src/roomList.js
@@ -26,13 +26,13 @@ const RoomRow = new Lang.Class({
Lang.bind(this, this._onSelectionModeChanged));
room.channel.connect('message-received',
- Lang.bind(this, this._updateCounter));
+ Lang.bind(this, this._updatePending));
room.channel.connect('pending-message-removed',
- Lang.bind(this, this._updateCounter));
- room.connect('notify::display-name',
- Lang.bind(this, this._updateLabel));
+ Lang.bind(this, this._updatePending));
+ room.bind_property('display-name', this._roomLabel, 'label',
+ GObject.BindingFlags.SYNC_CREATE);
- this._updateCounter();
+ this._updatePending();
this._updateMode();
},
@@ -44,26 +44,21 @@ const RoomRow = new Lang.Class({
this.selection_button.active = false;
},
- _updateCounter: function() {
- let channel = this.widget.room.channel;
- let numPending = channel.dup_pending_messages().length;
-
- this._counter.label = numPending.toString();
- this._counter.opacity = numPending > 0 ? 1. : 0.;
-
- this._updateLabel();
- },
-
- _updateLabel: function() {
+ _updatePending: function() {
let room = this.widget.room;
- let highlight = false;
let pending = room.channel.dup_pending_messages();
- for (let i = 0; i < pending.length && !highlight; i++)
- highlight = room.should_highlight_message(pending[i]);
+ let numPendingHighlights;
+ if (room.channel.has_interface(Tp.IFACE_CHANNEL_INTERFACE_GROUP))
+ numPendingHighlights = pending.filter(function(m) {
+ return room.should_highlight_message(m);
+ }).length;
+ else
+ numPendingHighlights = pending.length;
+
+ this._counter.label = numPendingHighlights.toString();
+ this._counter.opacity = numPendingHighlights > 0 ? 1. : 0.;
- this._roomLabel.label = (highlight ? "<b>%s</b>"
- : "%s").format(room.display_name);
},
_onSelectionModeChanged: function() {
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]