diff --git a/TODO.md b/TODO.md index 5da975e1..16196c1c 100644 --- a/TODO.md +++ b/TODO.md @@ -4,7 +4,6 @@ - Bug fixes - dataclass-like `default_factory` for ListItem - - Local echo messages all have the same time - Prevent briefly seeing login screen if there are accounts to resumeSession for but they take time to appear - 100% CPU usage when hitting top edge to trigger messages loading diff --git a/harmonyqml/backend/model/items.py b/harmonyqml/backend/model/items.py index 8003df59..60d7ab05 100644 --- a/harmonyqml/backend/model/items.py +++ b/harmonyqml/backend/model/items.py @@ -43,12 +43,12 @@ class Room(ListItem): # ---------- class RoomEvent(ListItem): - _required_init_values = {"type", "dict"} + _required_init_values = {"type", "dict", "dateTime"} _constant = {"type"} type: str = "" dict: Dict[str, Any] = {} - dateTime: QDateTime = QDateTime.currentDateTime() + dateTime: QDateTime = QDateTime() isLocalEcho: bool = False diff --git a/harmonyqml/backend/signal_manager.py b/harmonyqml/backend/signal_manager.py index f2b6c61d..002c1e2a 100644 --- a/harmonyqml/backend/signal_manager.py +++ b/harmonyqml/backend/signal_manager.py @@ -376,17 +376,20 @@ class SignalManager(QObject): room_id: str, content: Dict[str, str]) -> None: + date_time = QDateTime.currentDateTime() + with self._lock: model = self.backend.roomEvents[room_id] nio_event = nio.events.RoomMessage.parse_event({ "event_id": "", "sender": client.userId, - "origin_server_ts": QDateTime.currentMSecsSinceEpoch(), + "origin_server_ts": date_time.toMSecsSinceEpoch(), "content": content, }) event = RoomEvent( type = type(nio_event).__name__, dict = nio_event.__dict__, + dateTime = date_time, isLocalEcho = True, ) model.insert(0, event)