Support and sort invited room members
This commit is contained in:
parent
4b13b75617
commit
707ac61ff6
1
TODO.md
1
TODO.md
|
@ -64,7 +64,6 @@
|
|||
- Way to open context menus without a right mouse button
|
||||
- `smartVerticalFlick()` gradual acceleration
|
||||
|
||||
- Restore previous focus after closing right click context menu
|
||||
- Choose a better default easing type for animations
|
||||
- Make HListView scrollbars visible
|
||||
- Remove first html lists left margin
|
||||
|
|
|
@ -91,7 +91,7 @@ class App:
|
|||
ba = self.backend # noqa
|
||||
mo = self.backend.models # noqa
|
||||
cl = self.backend.clients
|
||||
tcl = lambda user: cl[f"@test_{user}:matrix.org"] # noqa
|
||||
tcl = lambda user: cl[f"@{user}:matrix.org"] # noqa
|
||||
|
||||
from .models.items import Account, Room, Member, Event, Device # noqa
|
||||
|
||||
|
|
|
@ -590,14 +590,14 @@ class MatrixClient(nio.AsyncClient):
|
|||
if uid not in self.all_rooms[room_id].users
|
||||
)
|
||||
|
||||
async def invite(user_id):
|
||||
if not self.user_id_regex.match(user_id):
|
||||
return InvalidUserId(user_id)
|
||||
async def invite(user):
|
||||
if not self.user_id_regex.match(user):
|
||||
return InvalidUserId(user)
|
||||
|
||||
if isinstance(await self.get_profile(invite), nio.ProfileGetError):
|
||||
return UserNotFound(user_id)
|
||||
if isinstance(await self.get_profile(user), nio.ProfileGetError):
|
||||
return UserNotFound(user)
|
||||
|
||||
return await self.room_invite(room_id, user_id)
|
||||
return await self.room_invite(room_id, user)
|
||||
|
||||
coros = [invite(uid) for uid in user_ids]
|
||||
successes = []
|
||||
|
@ -841,6 +841,7 @@ class MatrixClient(nio.AsyncClient):
|
|||
avatar_url = member.avatar_url or "",
|
||||
typing = user_id in room.typing_users,
|
||||
power_level = member.power_level,
|
||||
invited = member.invited,
|
||||
) for user_id, member in room.users.items()
|
||||
}
|
||||
self.models[Member, room.room_id].update(new_dict)
|
||||
|
|
|
@ -94,12 +94,19 @@ class Member(ModelItem):
|
|||
avatar_url: str = ""
|
||||
typing: bool = False
|
||||
power_level: int = 0
|
||||
invited: bool = False
|
||||
|
||||
def __lt__(self, other: "Member") -> bool:
|
||||
# Sort by name, but have members with higher power-level first
|
||||
# Sort by name, but have members with higher power-level first and
|
||||
# invited-but-not-joined members last
|
||||
name = (self.display_name or self.user_id[1:]).lower()
|
||||
other_name = (other.display_name or other.user_id[1:]).lower()
|
||||
return (other.power_level, name) < (self.power_level, other_name)
|
||||
|
||||
return (
|
||||
self.invited, other.power_level, name,
|
||||
) < (
|
||||
other.invited, self.power_level, other_name,
|
||||
)
|
||||
|
||||
|
||||
@property
|
||||
|
|
|
@ -270,14 +270,15 @@ class NioCallbacks:
|
|||
async def onRoomMemberEvent(self, room, ev) -> None:
|
||||
type_and_content = await self.process_room_member_event(room, ev)
|
||||
|
||||
if type_and_content is None:
|
||||
# This is run from register_nio_event otherwise
|
||||
await self.client.register_nio_room(room)
|
||||
else:
|
||||
if type_and_content is not None:
|
||||
type_specifier, content = type_and_content
|
||||
await self.client.register_nio_event(
|
||||
room, ev, content=content, type_specifier=type_specifier,
|
||||
)
|
||||
else:
|
||||
# Normally, register_nio_event() will call register_nio_room().
|
||||
# but in this case we don't have any event we want to register.
|
||||
await self.client.register_nio_room(room)
|
||||
|
||||
|
||||
async def onRoomAliasEvent(self, room, ev) -> None:
|
||||
|
|
Loading…
Reference in New Issue
Block a user