Add verified devices indicator to room header

This commit is contained in:
miruka 2020-06-27 11:11:14 -04:00
parent 90a7a3a6cf
commit 0a2d274824
5 changed files with 65 additions and 8 deletions

View File

@ -1,7 +1,6 @@
# TODO
- issue templates
- ctrl-tab highlight
## Refactoring
@ -11,6 +10,7 @@
## Issues
- Signing out leaves the account's rooms in the list
- Need to unregister popups/menus when they are destroyed without being closed
- Bottom focus line for an `HTextArea` inside a `ScrollView` is invisible,

View File

@ -1412,6 +1412,11 @@ class MatrixClient(nio.AsyncClient):
local_unreads = False
local_highlights = False
update_account_unread_counts = True
unverified_devices = (
False
if isinstance(room, nio.MatrixInvitedRoom) else
self.room_contains_unverified(room.room_id)
)
else:
last_event_date = registered.last_event_date
typing_members = registered.typing_members
@ -1421,6 +1426,7 @@ class MatrixClient(nio.AsyncClient):
registered.unreads != room.unread_notifications or
registered.highlights != room.unread_highlights
)
unverified_devices = registered.unverified_devices
room_item = Room(
id = room.room_id,
@ -1442,9 +1448,10 @@ class MatrixClient(nio.AsyncClient):
typing_members = typing_members,
encrypted = room.encrypted,
invite_required = room.join_rule == "invite",
guests_allowed = room.guest_access == "can_join",
encrypted = room.encrypted,
unverified_devices = unverified_devices,
invite_required = room.join_rule == "invite",
guests_allowed = room.guest_access == "can_join",
can_invite = levels.can_user_invite(self.user),
can_kick = levels.can_user_kick(self.user),

View File

@ -68,10 +68,11 @@ class Room(ModelItem):
typing_members: List[str] = field(default_factory=list)
federated: bool = True
encrypted: bool = False
invite_required: bool = True
guests_allowed: bool = True
federated: bool = True
encrypted: bool = False
unverified_devices: bool = False
invite_required: bool = True
guests_allowed: bool = True
can_invite: bool = False
can_kick: bool = False

View File

@ -105,6 +105,25 @@ class NioCallbacks:
account.first_sync_done = True
async def onKeysQueryResponse(self, resp: nio.KeysQueryResponse) -> None:
refresh_rooms = {}
for user_id in resp.changed:
for room in self.client.rooms.values():
if user_id in room.users:
refresh_rooms[room.room_id] = room
for room_id, room in refresh_rooms.items():
room_item = self.models[self.user_id, "rooms"].get(room_id)
if room_item:
room_item.unverified_devices = \
self.client.room_contains_unverified(room_id)
else:
await self.client.register_nio_room(room)
# Room events, invite events and misc events callbacks
async def onRoomMessageText(

View File

@ -122,6 +122,36 @@ Rectangle {
visible: center
}
HButton {
id: encryptionStatusButton
padded: false
visible: Layout.preferredWidth > 0
backgroundColor: "transparent"
icon.name:
chat.roomInfo.unverified_devices ?
"device-unset" :
"device-verified"
icon.color:
chat.roomInfo.unverified_devices ?
theme.colors.warningText :
theme.colors.positiveText
toolTip.text:
chat.roomInfo.unverified_devices ?
qsTr("Some members in this encrypted room have " +
"unverified devices") :
qsTr("All members in this encrypted room are verified")
onClicked: toolTip.instantShow()
Layout.preferredWidth: chat.roomInfo.encrypted ? avatar.width : 0
Layout.fillHeight: true
Behavior on Layout.preferredWidth { HNumberAnimation {} }
}
HButton {
id: goToRoomPaneButton
padded: false