Fix local echoed messages having a wrong time
This commit is contained in:
parent
6af1c0e27c
commit
a3e080c9a0
1
TODO.md
1
TODO.md
@ -4,7 +4,6 @@
|
|||||||
|
|
||||||
- Bug fixes
|
- Bug fixes
|
||||||
- dataclass-like `default_factory` for ListItem
|
- dataclass-like `default_factory` for ListItem
|
||||||
- Local echo messages all have the same time
|
|
||||||
- Prevent briefly seeing login screen if there are accounts to
|
- Prevent briefly seeing login screen if there are accounts to
|
||||||
resumeSession for but they take time to appear
|
resumeSession for but they take time to appear
|
||||||
- 100% CPU usage when hitting top edge to trigger messages loading
|
- 100% CPU usage when hitting top edge to trigger messages loading
|
||||||
|
@ -43,12 +43,12 @@ class Room(ListItem):
|
|||||||
# ----------
|
# ----------
|
||||||
|
|
||||||
class RoomEvent(ListItem):
|
class RoomEvent(ListItem):
|
||||||
_required_init_values = {"type", "dict"}
|
_required_init_values = {"type", "dict", "dateTime"}
|
||||||
_constant = {"type"}
|
_constant = {"type"}
|
||||||
|
|
||||||
type: str = ""
|
type: str = ""
|
||||||
dict: Dict[str, Any] = {}
|
dict: Dict[str, Any] = {}
|
||||||
dateTime: QDateTime = QDateTime.currentDateTime()
|
dateTime: QDateTime = QDateTime()
|
||||||
isLocalEcho: bool = False
|
isLocalEcho: bool = False
|
||||||
|
|
||||||
|
|
||||||
|
@ -376,17 +376,20 @@ class SignalManager(QObject):
|
|||||||
room_id: str,
|
room_id: str,
|
||||||
content: Dict[str, str]) -> None:
|
content: Dict[str, str]) -> None:
|
||||||
|
|
||||||
|
date_time = QDateTime.currentDateTime()
|
||||||
|
|
||||||
with self._lock:
|
with self._lock:
|
||||||
model = self.backend.roomEvents[room_id]
|
model = self.backend.roomEvents[room_id]
|
||||||
nio_event = nio.events.RoomMessage.parse_event({
|
nio_event = nio.events.RoomMessage.parse_event({
|
||||||
"event_id": "",
|
"event_id": "",
|
||||||
"sender": client.userId,
|
"sender": client.userId,
|
||||||
"origin_server_ts": QDateTime.currentMSecsSinceEpoch(),
|
"origin_server_ts": date_time.toMSecsSinceEpoch(),
|
||||||
"content": content,
|
"content": content,
|
||||||
})
|
})
|
||||||
event = RoomEvent(
|
event = RoomEvent(
|
||||||
type = type(nio_event).__name__,
|
type = type(nio_event).__name__,
|
||||||
dict = nio_event.__dict__,
|
dict = nio_event.__dict__,
|
||||||
|
dateTime = date_time,
|
||||||
isLocalEcho = True,
|
isLocalEcho = True,
|
||||||
)
|
)
|
||||||
model.insert(0, event)
|
model.insert(0, event)
|
||||||
|
Loading…
Reference in New Issue
Block a user