From 8a99ccd97692aea0768fbd81c5f6d7b91f9c7834 Mon Sep 17 00:00:00 2001 From: miruka Date: Sun, 15 Mar 2020 17:26:41 -0400 Subject: [PATCH] Make retry_decrypt_events() work for good --- src/backend/matrix_client.py | 6 ++++-- src/backend/models/model.py | 3 ++- src/gui/PythonBridge/Privates/EventHandlers.qml | 4 ++-- 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/src/backend/matrix_client.py b/src/backend/matrix_client.py index 33e0f86d..ca57440c 100644 --- a/src/backend/matrix_client.py +++ b/src/backend/matrix_client.py @@ -1179,17 +1179,19 @@ class MatrixClient(nio.AsyncClient): # Add the Event to model + model = self.models[self.user_id, room.room_id, "events"] + tx_id = ev.source.get("content", {}).get( f"{__app_name__}.transaction_id", ) local_sender = ev.sender in self.backend.clients - if local_sender and tx_id: + if local_sender and tx_id and tx_id in model: item.id = f"echo-{tx_id}" if not local_sender and not await self.event_is_past(ev): AlertRequested() - self.models[self.user_id, room.room_id, "events"][item.id] = item + model[item.id] = item await self.set_room_last_event(room.room_id, item) diff --git a/src/backend/models/model.py b/src/backend/models/model.py index 343d70d8..ea53f749 100644 --- a/src/backend/models/model.py +++ b/src/backend/models/model.py @@ -82,7 +82,8 @@ class Model(MutableMapping): setattr(existing, field, getattr(new, field)) return - new.parent_model = self + if self.sync_id: + new.parent_model = self self._data[key] = new index = bisect(self._sorted_data, new) diff --git a/src/gui/PythonBridge/Privates/EventHandlers.qml b/src/gui/PythonBridge/Privates/EventHandlers.qml index 113d7344..46124d86 100644 --- a/src/gui/PythonBridge/Privates/EventHandlers.qml +++ b/src/gui/PythonBridge/Privates/EventHandlers.qml @@ -60,13 +60,13 @@ QtObject { function onModelItemInserted(syncId, index, item) { - print("insert", syncId, index, item) + // print("insert", syncId, index, item) ModelStore.get(syncId).insert(index, item) } function onModelItemFieldChanged(syncId, oldIndex, newIndex, field, value){ - print("change", syncId, oldIndex, newIndex, field, value) + // print("change", syncId, oldIndex, newIndex, field, value) const model = ModelStore.get(syncId) model.setProperty(oldIndex, field, value)