[polari] roomList: Handle muted contacts
- From: Florian Müllner <fmuellner src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [polari] roomList: Handle muted contacts
- Date: Wed, 1 Apr 2020 02:04:15 +0000 (UTC)
commit f81038d041ee3b857c10805627052f1aadaf6446
Author: Florian Müllner <fmuellner gnome org>
Date: Sat Apr 20 11:57:12 2019 +0000
roomList: Handle muted contacts
The room list is where all active conversations are represented, so
it makes sense to adjust the behavior for muted nicks here as well:
- suppress the attention-drawing counter
- ignore muted contacts when navigating between "pending" rooms
- add a small indication that a nick is muted
https://gitlab.gnome.org/GNOME/polari/-/merge_requests/153
src/roomList.js | 38 +++++++++++++++++++++++++++++++++++---
1 file changed, 35 insertions(+), 3 deletions(-)
---
diff --git a/src/roomList.js b/src/roomList.js
index 103c39a1..e1470c67 100644
--- a/src/roomList.js
+++ b/src/roomList.js
@@ -4,6 +4,7 @@ const { Gdk, Gio, GLib, GObject, Gtk, TelepathyGLib: Tp } = imports.gi;
const { AccountsMonitor } = imports.accountsMonitor;
const { RoomManager } = imports.roomManager;
+const { UserStatusMonitor } = imports.userTracker;
const MIN_SPINNER_TIME = 1000000; // in microsecond
@@ -33,9 +34,16 @@ var RoomRow = GObject.registerClass({
this._room = room;
this._popover = null;
+ const mon = UserStatusMonitor.getDefault();
+ this._userTracker = mon.getUserTrackerForAccount(this.account);
+
this._connectingTimeoutId = 0;
- this._icon.gicon = room.icon;
+ this._mutedIcon = new Gio.EmblemedIcon({ gicon: room.icon });
+ this._mutedIcon.add_emblem(new Gio.Emblem({
+ icon: new Gio.ThemedIcon({ name: 'emblem-unreadable' }),
+ }));
+
this._icon.visible = room.icon !== null;
this._eventBox.connect('button-release-event',
@@ -51,12 +59,18 @@ var RoomRow = GObject.registerClass({
this._onChannelChanged.bind(this));
let connectionStatusChangedId = 0;
+ let mutedChangedId = 0;
if (this._room.type === Tp.HandleType.ROOM) {
connectionStatusChangedId =
this.account.connect('notify::connection-status',
this._onConnectionStatusChanged.bind(this));
this._onConnectionStatusChanged();
+ } else {
+ mutedChangedId = this._userTracker.connect(
+ `muted-changed::${room.channel_name}`,
+ this._onMutedChanged.bind(this));
+ this._onMutedChanged();
}
this.connect('destroy', () => {
@@ -64,6 +78,8 @@ var RoomRow = GObject.registerClass({
this._channelSignals.forEach(id => {
room.channel.disconnect(id);
});
+ if (mutedChangedId)
+ this._userTracker.disconnect(mutedChangedId);
if (connectionStatusChangedId)
this.account.disconnect(connectionStatusChangedId);
this._clearConnectingTimeout();
@@ -86,6 +102,10 @@ var RoomRow = GObject.registerClass({
return !this.get_style_context().has_class('inactive');
}
+ get muted() {
+ return this._userTracker.isMuted(this._room.channel_name);
+ }
+
selected() {
if (!this._room.channel)
this._updatePending();
@@ -98,6 +118,9 @@ var RoomRow = GObject.registerClass({
let pending = this._room.channel.dup_pending_messages();
let nPending = pending.length;
+ if (this.muted)
+ return [nPending, 0];
+
let highlights = pending.filter(m => {
let [text] = m.to_text();
return this._room.should_highlight_message(m.sender.alias, text);
@@ -130,6 +153,15 @@ var RoomRow = GObject.registerClass({
}
}
+ _onMutedChanged() {
+ if (this.muted)
+ this._icon.gicon = this._mutedIcon;
+ else
+ this._icon.gicon = this.room.icon;
+
+ this._updatePending();
+ }
+
_updatePending() {
let [nPending, nHighlights] = this._getNumPending();
@@ -496,13 +528,13 @@ class RoomList extends Gtk.ListBox {
name: 'next-pending-room',
handler: () => {
this._moveSelectionFull(Gtk.DirectionType.DOWN,
- row => row.hasPending);
+ row => row.hasPending && !row.muted);
},
}, {
name: 'previous-pending-room',
handler: () => {
this._moveSelectionFull(Gtk.DirectionType.UP,
- row => row.hasPending);
+ row => row.hasPending && !row.muted);
},
}];
actions.forEach(a => {
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]