From b81dea9bc28cf4dd290ab1436c73494fbda105a0 Mon Sep 17 00:00:00 2001 From: miruka Date: Fri, 5 Jun 2020 01:39:17 -0400 Subject: [PATCH] Fix KeyError when forgetting a room --- CHANGELOG.md | 2 ++ src/backend/matrix_client.py | 7 ++++--- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6026b153..c32426f1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -93,6 +93,8 @@ and this project adheres to - Starting a direct chat, creating or joining a room will now correctly update the left pane room list's highlighted item +- Fix `KeyError` when forgetting a room + ## 0.5.0 ### Added diff --git a/src/backend/matrix_client.py b/src/backend/matrix_client.py index df810c38..ab9a7b7c 100644 --- a/src/backend/matrix_client.py +++ b/src/backend/matrix_client.py @@ -727,7 +727,7 @@ class MatrixClient(nio.AsyncClient): replace the local one we registered. """ - our_info = self.models[self.user_id, room_id, "members"][self.user_id] + our_info = self.models["accounts"][self.user_id] content = event_fields.get("content", "").strip() @@ -782,9 +782,10 @@ class MatrixClient(nio.AsyncClient): member list when the user is currently viewing the room. """ - room = self.all_rooms[room_id] + # Room may be gone by the time this is called due to room_forget() + room = self.all_rooms.get(room_id) - if not room.members_synced: + if room and not room.members_synced: await super().joined_members(room_id) await self.register_nio_room(room, force_register_members=True)