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
|
- Way to open context menus without a right mouse button
|
||||||
- `smartVerticalFlick()` gradual acceleration
|
- `smartVerticalFlick()` gradual acceleration
|
||||||
|
|
||||||
- Restore previous focus after closing right click context menu
|
|
||||||
- Choose a better default easing type for animations
|
- Choose a better default easing type for animations
|
||||||
- Make HListView scrollbars visible
|
- Make HListView scrollbars visible
|
||||||
- Remove first html lists left margin
|
- Remove first html lists left margin
|
||||||
|
|
|
@ -91,7 +91,7 @@ class App:
|
||||||
ba = self.backend # noqa
|
ba = self.backend # noqa
|
||||||
mo = self.backend.models # noqa
|
mo = self.backend.models # noqa
|
||||||
cl = self.backend.clients
|
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
|
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
|
if uid not in self.all_rooms[room_id].users
|
||||||
)
|
)
|
||||||
|
|
||||||
async def invite(user_id):
|
async def invite(user):
|
||||||
if not self.user_id_regex.match(user_id):
|
if not self.user_id_regex.match(user):
|
||||||
return InvalidUserId(user_id)
|
return InvalidUserId(user)
|
||||||
|
|
||||||
if isinstance(await self.get_profile(invite), nio.ProfileGetError):
|
if isinstance(await self.get_profile(user), nio.ProfileGetError):
|
||||||
return UserNotFound(user_id)
|
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]
|
coros = [invite(uid) for uid in user_ids]
|
||||||
successes = []
|
successes = []
|
||||||
|
@ -835,12 +835,13 @@ class MatrixClient(nio.AsyncClient):
|
||||||
# Add the room members to the added room
|
# Add the room members to the added room
|
||||||
new_dict = {
|
new_dict = {
|
||||||
user_id: Member(
|
user_id: Member(
|
||||||
user_id = user_id,
|
user_id = user_id,
|
||||||
display_name = room.user_name(user_id) # disambiguated
|
display_name = room.user_name(user_id) # disambiguated
|
||||||
if member.display_name else "",
|
if member.display_name else "",
|
||||||
avatar_url = member.avatar_url or "",
|
avatar_url = member.avatar_url or "",
|
||||||
typing = user_id in room.typing_users,
|
typing = user_id in room.typing_users,
|
||||||
power_level = member.power_level,
|
power_level = member.power_level,
|
||||||
|
invited = member.invited,
|
||||||
) for user_id, member in room.users.items()
|
) for user_id, member in room.users.items()
|
||||||
}
|
}
|
||||||
self.models[Member, room.room_id].update(new_dict)
|
self.models[Member, room.room_id].update(new_dict)
|
||||||
|
|
|
@ -94,12 +94,19 @@ class Member(ModelItem):
|
||||||
avatar_url: str = ""
|
avatar_url: str = ""
|
||||||
typing: bool = False
|
typing: bool = False
|
||||||
power_level: int = 0
|
power_level: int = 0
|
||||||
|
invited: bool = False
|
||||||
|
|
||||||
def __lt__(self, other: "Member") -> bool:
|
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()
|
name = (self.display_name or self.user_id[1:]).lower()
|
||||||
other_name = (other.display_name or other.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
|
@property
|
||||||
|
|
|
@ -270,14 +270,15 @@ class NioCallbacks:
|
||||||
async def onRoomMemberEvent(self, room, ev) -> None:
|
async def onRoomMemberEvent(self, room, ev) -> None:
|
||||||
type_and_content = await self.process_room_member_event(room, ev)
|
type_and_content = await self.process_room_member_event(room, ev)
|
||||||
|
|
||||||
if type_and_content is None:
|
if type_and_content is not None:
|
||||||
# This is run from register_nio_event otherwise
|
|
||||||
await self.client.register_nio_room(room)
|
|
||||||
else:
|
|
||||||
type_specifier, content = type_and_content
|
type_specifier, content = type_and_content
|
||||||
await self.client.register_nio_event(
|
await self.client.register_nio_event(
|
||||||
room, ev, content=content, type_specifier=type_specifier,
|
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:
|
async def onRoomAliasEvent(self, room, ev) -> None:
|
||||||
|
|
Loading…
Reference in New Issue
Block a user