Bug fix and minor improvements

Bug fixes:
- Do not send typing notice and set room read
  markers when the account is invisible
- Fix typing on set_presence
- Allow users to unset status message by setting
  it to blank
- Escape html tags of status message on
  SubtitleLabel of MemberDelegate

Improvements:
- Display user ID and status message on a tooltip
  by hovering account or room member name
This commit is contained in:
vslg 2020-07-07 11:42:16 -03:00 committed by miruka
parent a1f38fe8d8
commit edc8e04ce7
4 changed files with 48 additions and 8 deletions

View File

@ -318,6 +318,7 @@ class Backend:
async def update(client: MatrixClient) -> None: async def update(client: MatrixClient) -> None:
room = self.models[client.user_id, "rooms"].get(room_id) room = self.models[client.user_id, "rooms"].get(room_id)
account = self.models["accounts"][client.user_id]
if room: if room:
room.set_fields( room.set_fields(
@ -327,6 +328,9 @@ class Backend:
local_highlights = False, local_highlights = False,
) )
await client.update_account_unread_counts() await client.update_account_unread_counts()
# Only update server markers if the account is not invisible
if account.presence != Presence.State.invisible:
await client.update_receipt_marker(room_id, event_id) await client.update_receipt_marker(room_id, event_id)
await asyncio.gather(*[update(c) for c in self.clients.values()]) await asyncio.gather(*[update(c) for c in self.clients.values()])

View File

@ -1064,6 +1064,17 @@ class MatrixClient(nio.AsyncClient):
]) ])
async def room_typing(
self, room_id: str, typing_state: bool = True, timeout: int = 5000,
):
"""Set typing notice to the server."""
# Do not send typing notice if the user is invisible
if self.models["accounts"][self.user_id].presence != \
Presence.State.invisible:
await super().room_typing(room_id, typing_state, timeout)
async def get_redacted_event_content( async def get_redacted_event_content(
self, self,
nio_type: Type[nio.Event], nio_type: Type[nio.Event],
@ -1222,11 +1233,11 @@ class MatrixClient(nio.AsyncClient):
async def set_presence( async def set_presence(
self, presence: str, status_msg: str = None, self, presence: str, status_msg: Optional[str] = None,
) -> None: ) -> None:
"""Set presence state for this account.""" """Set presence state for this account."""
status_msg = status_msg or ( status_msg = status_msg if status_msg is not None else (
self.models["accounts"][self.user_id].status_msg self.models["accounts"][self.user_id].status_msg
) )

View File

@ -66,8 +66,9 @@ HTile {
} }
HColumnLayout { HColumnLayout {
TitleLabel {
id: title id: title
TitleLabel {
text: model.display_name || model.id text: model.display_name || model.id
color: color:
hovered ? hovered ?
@ -82,12 +83,22 @@ HTile {
} }
SubtitleLabel { SubtitleLabel {
id: statusMsg
tile: account tile: account
text: model.status_msg text: utils.escapeHtml(model.status_msg.trim())
visible: model.status_msg visible: model.status_msg.trim()
Layout.leftMargin: theme.spacing Layout.leftMargin: theme.spacing
} }
HoverHandler { id: nameHover }
HToolTip {
visible: nameHover.hovered
text:
model.id +
(statusMsg.text ? " - " + model.status_msg.trim() : "")
}
} }
HButton { HButton {

View File

@ -2,6 +2,7 @@
import QtQuick 2.12 import QtQuick 2.12
import Clipboard 0.1 import Clipboard 0.1
import "../../../.."
import "../../../../Base" import "../../../../Base"
import "../../../../Base/HTile" import "../../../../Base/HTile"
import "../../../../Popups" import "../../../../Popups"
@ -57,7 +58,20 @@ HTile {
SubtitleLabel { SubtitleLabel {
tile: member tile: member
color: theme.chat.roomPane.listView.member.subtitle color: theme.chat.roomPane.listView.member.subtitle
text: model.status_msg.trim() || model.id text: utils.escapeHtml(model.status_msg.trim()) || model.id
}
HoverHandler { id: nameHover }
HToolTip {
visible: nameHover.hovered
text:
model.id +
(
model.status_msg.trim() ?
" - " + model.status_msg.trim() :
""
)
} }
} }
} }