From 0e191f11d0b410d147a7501508030c77fe1b5efe Mon Sep 17 00:00:00 2001 From: miruka Date: Tue, 24 Mar 2020 03:56:31 -0400 Subject: [PATCH 1/4] Member ev. processing: don't assume any key exists --- src/backend/nio_callbacks.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/backend/nio_callbacks.py b/src/backend/nio_callbacks.py index f3565c1c..be3ca300 100644 --- a/src/backend/nio_callbacks.py +++ b/src/backend/nio_callbacks.py @@ -269,13 +269,13 @@ class NioCallbacks: # Profile changes changed = [] - if prev and now["avatar_url"] != prev["avatar_url"]: + if prev and now.get("avatar_url") != prev.get("avatar_url"): changed.append("profile picture") # TODO: s - if prev and now["displayname"] != prev["displayname"]: + if prev and now.get("displayname") != prev.get("displayname"): changed.append('display name from "{}" to "{}"'.format( - prev["displayname"] or ev.state_key, - now["displayname"] or ev.state_key, + prev.get("displayname") or ev.state_key, + now.get("displayname") or ev.state_key, )) if changed: @@ -285,8 +285,8 @@ class NioCallbacks: if account.profile_updated < ev_date: account.profile_updated = ev_date - account.display_name = now["displayname"] or "" - account.avatar_url = now["avatar_url"] or "" + account.display_name = now.get("displayname") or "" + account.avatar_url = now.get("avatar_url") or "" if self.client.backend.ui_settings["hideProfileChangeEvents"]: self.client.skipped_events[room.room_id] += 1 From 3dc81700c1f0472b3373b772f6e8bce5275c9d93 Mon Sep 17 00:00:00 2001 From: miruka Date: Tue, 24 Mar 2020 04:08:00 -0400 Subject: [PATCH 2/4] Correct mailto: linkifying in some special cases adresses where the host ends with a digit or where the host is only one character --- src/backend/html_markdown.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/backend/html_markdown.py b/src/backend/html_markdown.py index 9fe1d313..49cf5116 100644 --- a/src/backend/html_markdown.py +++ b/src/backend/html_markdown.py @@ -132,7 +132,7 @@ class HTMLProcessor: r"(?:/[/\-_.,a-z\d#%&?;=~]*)?(?:\([/\-_.,a-z\d#%&?;=~]*\))?)"), # mailto: and tel: - r"mailto:(?P[a-z0-9._-]+@(?P[a-z0-9_.-]+[a-z](?:\:\d+)?))", + r"mailto:(?P[a-z0-9._-]+@(?P[a-z0-9.-:]*[a-z\d]))", r"tel:(?P[0-9+-]+)(?P)", # magnet: From 684ddd364c2ece9e19aae04c17aada5bee1e15f1 Mon Sep 17 00:00:00 2001 From: miruka Date: Tue, 24 Mar 2020 04:12:09 -0400 Subject: [PATCH 3/4] Don't ignore case when linkifying display names --- src/backend/html_markdown.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/backend/html_markdown.py b/src/backend/html_markdown.py index 49cf5116..bcb6cbaf 100644 --- a/src/backend/html_markdown.py +++ b/src/backend/html_markdown.py @@ -298,7 +298,7 @@ class HTMLProcessor: "span": {"data-mx-color"}, }} - username_link_regexes = [re.compile(r, re.IGNORECASE) for r in [ + username_link_regexes = [re.compile(r) for r in [ rf"(?{re.escape(username)})(?!\w)(?P)" for username in self.rooms_user_id_names[room_id].values() ]] From 379a851a62c849894710795b9cfe3f8cdb623572 Mon Sep 17 00:00:00 2001 From: miruka Date: Tue, 24 Mar 2020 11:31:32 -0400 Subject: [PATCH 4/4] alertOnMessageForMsec: correctly handle 0 value If 0: don't show any alert If -1: show alert indefinitly until user focuses the window --- src/gui/PythonBridge/Privates/EventHandlers.qml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/gui/PythonBridge/Privates/EventHandlers.qml b/src/gui/PythonBridge/Privates/EventHandlers.qml index c5f9c62d..b98ebc14 100644 --- a/src/gui/PythonBridge/Privates/EventHandlers.qml +++ b/src/gui/PythonBridge/Privates/EventHandlers.qml @@ -11,8 +11,10 @@ QtObject { function onAlertRequested() { - if (Qt.application.state !== Qt.ApplicationActive) { - window.alert(window.settings.alertOnMessageForMsec) + const msec = window.settings.alertOnMessageForMsec + + if (Qt.application.state !== Qt.ApplicationActive && msec !== 0) { + window.alert(msec === -1 ? 0 : msec) // -1 → 0 = no time out } }