Add setting to sort rooms lexically
This commit is contained in:
parent
8d61826887
commit
a1b9f34958
1
TODO.md
1
TODO.md
|
@ -2,7 +2,6 @@
|
|||
|
||||
- handle invalid access token
|
||||
- If an account is gone from the user's config, discard UI state last page
|
||||
- room A-Z sorting
|
||||
- filter > enter > room list is always scrolled to top
|
||||
- session list: prevent tab-focusing the delegates
|
||||
- refresh server list button
|
||||
|
|
|
@ -1866,6 +1866,8 @@ class MatrixClient(nio.AsyncClient):
|
|||
highlights = room.unread_highlights,
|
||||
local_unreads = local_unreads,
|
||||
local_highlights = local_highlights,
|
||||
|
||||
lexical_sorting = self.backend.ui_settings["lexicalRoomSorting"],
|
||||
)
|
||||
|
||||
self.models[self.user_id, "rooms"][room.room_id] = room_item
|
||||
|
|
|
@ -130,6 +130,8 @@ class Room(ModelItem):
|
|||
local_unreads: bool = False
|
||||
local_highlights: bool = False
|
||||
|
||||
lexical_sorting: bool = False
|
||||
|
||||
def __lt__(self, other: "Room") -> bool:
|
||||
"""Sort by membership, highlights/unread events, last event date, name.
|
||||
|
||||
|
@ -140,6 +142,19 @@ class Room(ModelItem):
|
|||
then by display names or ID.
|
||||
"""
|
||||
|
||||
if self.lexical_sorting:
|
||||
return (
|
||||
self.for_account,
|
||||
self.left,
|
||||
other.inviter_id,
|
||||
(self.display_name or self.id).lower(),
|
||||
) < (
|
||||
other.for_account,
|
||||
other.left,
|
||||
self.inviter_id,
|
||||
(other.display_name or other.id).lower(),
|
||||
)
|
||||
|
||||
# Left rooms may still have an inviter_id, so check left first.
|
||||
return (
|
||||
self.for_account,
|
||||
|
@ -171,6 +186,23 @@ class AccountOrRoom(Account, Room):
|
|||
account_order: int = -1
|
||||
|
||||
def __lt__(self, other: "AccountOrRoom") -> bool: # type: ignore
|
||||
if self.lexical_sorting:
|
||||
return (
|
||||
self.account_order,
|
||||
self.id if self.type is Account else self.for_account,
|
||||
other.type is Account,
|
||||
self.left,
|
||||
other.inviter_id,
|
||||
(self.display_name or self.id).lower(),
|
||||
) < (
|
||||
other.account_order,
|
||||
other.id if other.type is Account else other.for_account,
|
||||
self.type is Account,
|
||||
other.left,
|
||||
self.inviter_id,
|
||||
(other.display_name or other.id).lower(),
|
||||
)
|
||||
|
||||
return (
|
||||
self.account_order,
|
||||
self.id if self.type is Account else self.for_account,
|
||||
|
|
|
@ -280,6 +280,7 @@ class UISettings(JSONDataFile):
|
|||
"hideUnknownEvents": True,
|
||||
"kineticScrollingMaxSpeed": 2500,
|
||||
"kineticScrollingDeceleration": 1500,
|
||||
"lexicalRoomSorting": False,
|
||||
"markRoomReadMsecDelay": 200,
|
||||
"maxMessageCharactersPerLine": 65,
|
||||
"ownMessagesOnLeftAboveWidth": 895,
|
||||
|
|
Loading…
Reference in New Issue
Block a user