[polari/wip/fmuellner/room-list: 4/11] don't use sort function
- From: Florian Müllner <fmuellner src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [polari/wip/fmuellner/room-list: 4/11] don't use sort function
- Date: Mon, 12 Dec 2016 11:30:39 +0000 (UTC)
commit 786c9a0442ec27951eaefd87211d02096055b7d3
Author: Florian Müllner <fmuellner gnome org>
Date: Fri Nov 11 10:53:44 2016 +0100
don't use sort function
partially revert
src/serverRoomManager.js | 17 ++++++++++-------
1 files changed, 10 insertions(+), 7 deletions(-)
---
diff --git a/src/serverRoomManager.js b/src/serverRoomManager.js
index a9d601a..7eadc83 100644
--- a/src/serverRoomManager.js
+++ b/src/serverRoomManager.js
@@ -116,7 +116,6 @@ const ServerRoomList = new Lang.Class({
});
this._list = new Gtk.ListBox({ visible: true });
- this._list.set_sort_func(Lang.bind(this, this._sort));
this._list.set_header_func(Lang.bind(this, this._updateHeader));
this._list.connect('row-activated',
Lang.bind(this, this._onRowActivated));
@@ -138,11 +137,6 @@ const ServerRoomList = new Lang.Class({
row.activate();
},
- _sort: function(row1, row2) {
- return row2.info.get_members_count(null) -
- row1.info.get_members_count(null);
- },
-
get selectedRooms() {
let selectedRows = this._list.get_children().filter(r => r.checked);
return selectedRows.map(r => r.info.get_name());
@@ -168,7 +162,16 @@ const ServerRoomList = new Lang.Class({
return;
this._list.foreach(function(w) { w.destroy(); });
- this._manager.getRoomInfos(account).forEach(roomInfo => {
+
+ let roomInfos = this._manager.getRoomInfos(account);
+ roomInfos.sort((info1, info2) => {
+ let count1 = info1.get_members_count(null);
+ let count2 = info2.get_members_count(null);
+ if (count1 != count2)
+ return count2 - count1;
+ return info1.get_name().localeCompare(info2.get_name());
+ });
+ roomInfos.forEach(roomInfo => {
let row = new ServerRoomRow({ info: roomInfo });
row.connect('notify::checked', () => { this.notify('can-join'); });
this._list.add(row);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]