[polari] roomList: Fix room order in corner case
- From: Florian Müllner <fmuellner src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [polari] roomList: Fix room order in corner case
- Date: Fri, 12 Feb 2016 22:29:59 +0000 (UTC)
commit 883bc8054fca49cea18332e8215a9bbac9a6015c
Author: Florian Müllner <fmuellner gnome org>
Date: Fri Feb 12 23:04:43 2016 +0100
roomList: Fix room order in corner case
Our sort function currently assumes that different accounts use
different names. While that's generally a good idea to distinguish
accounts, an account's display name is under user control and crazy
people do crazy stuff (Hi Bastian!), so make sure we still sort
rooms reliably in that case.
src/roomList.js | 16 ++++++++++++++--
1 files changed, 14 insertions(+), 2 deletions(-)
---
diff --git a/src/roomList.js b/src/roomList.js
index 1942c68..8ea9e77 100644
--- a/src/roomList.js
+++ b/src/roomList.js
@@ -579,8 +579,20 @@ const RoomList = new Lang.Class({
if (hasRooms1 != hasRooms2)
return hasRooms1 ? -1 : 1;
- if (account1 != account2)
- return account1.display_name.localeCompare(account2.display_name);
+
+ if (account1 != account2) {
+ let displayName1 = account1.display_name;
+ let displayName2 = account2.display_name;
+
+ if (displayName1 != displayName2)
+ return displayName1.localeCompare(displayName2);
+
+ // Different account with the same display name :-(
+ // Fall back to the object path to guarantee a stable sort order
+ let accountPath1 = account1.get_path_suffix();
+ let accountPath2 = account2.get_path_suffix();
+ return accountPath1.localeCompare(accountPath2);
+ }
let room1 = row1.room;
let room2 = row2.room;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]