[polari/wip/fmuellner/roomlist-filtering: 11/12] serverRoomList: Hide custom room item for exact matches
- From: Florian Müllner <fmuellner src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [polari/wip/fmuellner/roomlist-filtering: 11/12] serverRoomList: Hide custom room item for exact matches
- Date: Mon, 13 Mar 2017 02:51:45 +0000 (UTC)
commit d94e1c67e4fe62d8d53519fc9980a7db410c7660
Author: Florian Müllner <fmuellner gnome org>
Date: Sat Mar 11 02:08:24 2017 +0100
serverRoomList: Hide custom room item for exact matches
Now that we mirror the filter text in a row, we can end up with a
duplicated room name in case the list contains an exact match. We
don't need a custom item in that case, so hide it.
src/serverRoomManager.js | 24 ++++++++++++++++++++++++
1 files changed, 24 insertions(+), 0 deletions(-)
---
diff --git a/src/serverRoomManager.js b/src/serverRoomManager.js
index 4548f47..105c61c 100644
--- a/src/serverRoomManager.js
+++ b/src/serverRoomManager.js
@@ -108,6 +108,10 @@ const RoomListColumn = {
SENSITIVE: 3,
};
+function _strBaseEqual(str1, str2) {
+ return str1.localeCompare(str2, {}, { sensitivity: 'base'}) == 0;
+};
+
const ServerRoomList = new Lang.Class({
Name: 'ServerRoomList',
Extends: Gtk.Box,
@@ -226,6 +230,20 @@ const ServerRoomList = new Lang.Class({
if (newName.search(/\s/) != -1)
newName = '';
+ if (newName) {
+ let exactMatch = false;
+ this._store.foreach((model, path, iter) => {
+ if (this._isCustomRoomItem(iter))
+ return false;
+
+ let name = model.get_value(iter, RoomListColumn.NAME);
+ return exactMatch = _strBaseEqual(newName, name);
+ });
+
+ if (exactMatch)
+ newName = '';
+ }
+
this._store.set_value(this._customRoomItem, RoomListColumn.NAME, newName);
},
@@ -270,6 +288,8 @@ const ServerRoomList = new Lang.Class({
let roomManager = RoomManager.getDefault();
this._idleId = Mainloop.idle_add(() => {
+ let customName = this._store.get_value(this._customRoomItem,
+ RoomListColumn.NAME);
this._pendingInfos.splice(0, LIST_CHUNK_SIZE).forEach(roomInfo => {
let store = this._store;
@@ -277,6 +297,10 @@ const ServerRoomList = new Lang.Class({
if (name[0] == '#')
name = name.substr(1, name.length);
+ if (_strBaseEqual(name, customName))
+ this._store.set_value(this._customRoomItem,
+ RoomListColumn.NAME, customName = '');
+
let room = roomManager.lookupRoomByName(roomInfo.get_name(), this._account);
let sensitive = room == null;
let checked = !sensitive;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]