From a987cf48e607f7a64a44d9f39fb095a939c8a48b Mon Sep 17 00:00:00 2001 From: miruka Date: Fri, 30 Aug 2019 10:09:09 -0400 Subject: [PATCH] Don't add profile events to the timeline (for now) --- TODO.md | 8 ++++++++ src/python/matrix_client.py | 19 +++++++++++-------- 2 files changed, 19 insertions(+), 8 deletions(-) diff --git a/TODO.md b/TODO.md index 096e9358..c21f58fb 100644 --- a/TODO.md +++ b/TODO.md @@ -11,7 +11,14 @@ - When qml syntax highlighting supports ES6 string interpolation, use them - Fixes + - Daybreak? + - Collapsing last account with shortcut when focused on room + - Using up/down when sidepane focused + - Missing hourglass when changing avatar and applying + - Icons on KDE + - Send typing state when no alias - Greentext for local echo + - Show error if uploading avatar fails - Don't strip user spacing in html @@ -24,6 +31,7 @@ - UI - Reduce icons brightness + - Thinner expand arrow - Restore previous focus after closing right click context menu - Choose a better default easing type for animations - Make HListView scrollbars visible diff --git a/src/python/matrix_client.py b/src/python/matrix_client.py index 087dc9e9..9f3e7c49 100644 --- a/src/python/matrix_client.py +++ b/src/python/matrix_client.py @@ -386,17 +386,20 @@ class MatrixClient(nio.AsyncClient): room.last_event = item.serialized return - for_us = item.target_id in self.backend.clients is_profile_ev = item.type_specifier == TypeSpecifier.profile_change # If there were no better events available to show previously - prev_is_member_ev = \ - isinstance(room.last_event["source"], nio.RoomMemberEvent) + prev_is_profile_ev = \ + room.last_event["type_specifier"] == TypeSpecifier.profile_change - if is_profile_ev and for_us and not prev_is_member_ev: + # If this is a profile event, only replace the currently shown one if + # it was also a profile event (we had nothing better to show). + if is_profile_ev and not prev_is_profile_ev: return - if item.date < room.last_event["date"]: # If this is a past event + # If this event is older than the currently shown one, only replace + # it if the previous was a profile event. + if item.date < room.last_event["date"] and not prev_is_profile_ev: return room.last_event = item.serialized @@ -693,9 +696,9 @@ class MatrixClient(nio.AsyncClient): account.display_name = now["displayname"] or "" account.avatar_url = now["avatar_url"] or "" - if ev.state_key in self.backend.clients or len(room.users) > 50: - self.skipped_events[room.room_id] += 1 - return None + # Hide profile events from the timeline - XXX + self.skipped_events[room.room_id] += 1 + return None return ( TypeSpecifier.profile_change,