Philipp Hörist pushed to branch master at gajim / gajim
Commits:
62882b6c by Philipp Hörist at 2025-11-20T18:48:47+01:00
imprv: SyncHistory: Don't open chats when syncing history
- - - - -
6 changed files:
- gajim/common/events.py
- gajim/common/modules/message.py
- gajim/common/modules/moderations.py
- gajim/common/modules/retraction.py
- gajim/gtk/history_sync.py
- gajim/gtk/main.py
Changes:
=====================================
gajim/common/events.py
=====================================
@@ -24,6 +24,7 @@
from nbxmpp.protocol import JID
from nbxmpp.structs import HTTPAuthData
from nbxmpp.structs import LocationData
+from nbxmpp.structs import MAMData
from nbxmpp.structs import RosterItem
from nbxmpp.structs import TuneData
@@ -466,7 +467,7 @@ class MessageReceived(ApplicationEvent):
account: str
jid: JID
m_type: MessageType
- from_mam: bool
+ mam: MAMData | None
pk: int
@cached_property
@@ -475,6 +476,10 @@ def message(self) -> mod.Message:
assert m is not None
return m
+ @property
+ def from_mam(self) -> bool:
+ return self.mam is not None
+
@dataclass
class MessageError(ApplicationEvent):
=====================================
gajim/common/modules/message.py
=====================================
@@ -257,7 +257,7 @@ def _message_received(self,
app.ged.raise_event(MessageReceived(account=self._account,
jid=remote_jid,
m_type=m_type,
- from_mam=properties.is_mam_message,
+ mam=properties.mam,
pk=pk))
def _message_error_received(self,
=====================================
gajim/common/modules/moderations.py
=====================================
@@ -217,7 +217,7 @@ def _insert_tombstone(
account=self._account,
jid=remote_jid,
m_type=MessageType.GROUPCHAT,
- from_mam=True,
+ mam=properties.mam,
pk=pk))
def _is_occupant_id_supported(self, properties: MessageProperties) -> bool:
=====================================
gajim/common/modules/retraction.py
=====================================
@@ -140,7 +140,7 @@ def _process_retraction_message(
account=self._account,
jid=remote_jid,
m_type=m_type,
- from_mam=True,
+ mam=properties.mam,
pk=pk,
)
)
=====================================
gajim/gtk/history_sync.py
=====================================
@@ -37,7 +37,7 @@
class HistorySyncAssistant(Assistant, EventHelper):
def __init__(self, account: str) -> None:
- Assistant.__init__(self, width=600)
+ Assistant.__init__(self, name="HistorySyncAssistant", width=600)
EventHelper.__init__(self)
self.account = account
@@ -95,6 +95,9 @@ def __init__(self, account: str) -> None:
self.show_all()
+ def get_active_query_id(self) -> str | None:
+ return self._query_id
+
@overload
def get_page(self, name: Literal["select"]) -> SelectTime: ...
=====================================
gajim/gtk/main.py
=====================================
@@ -1295,7 +1295,20 @@ def _load_chats(self) -> None:
self._set_startup_finished()
+ def _is_history_sync(self, event: events.MessageReceived) -> bool:
+ if event.mam is None:
+ return False
+
+ win = get_app_window("HistorySyncAssistant", account=event.account)
+ if win is None:
+ return False
+
+ return win.get_active_query_id() == event.mam.query_id
+
def _on_message_received(self, event: events.MessageReceived) -> bool |
None:
+ if self._is_history_sync(event):
+ return ged.STOP_PROPAGATION
+
if self.chat_exists(event.account, event.jid):
return
View it on GitLab:
https://dev.gajim.org/gajim/gajim/-/commit/62882b6c9f4706e58c9847f0d665ec3ff1d11b90
--
View it on GitLab:
https://dev.gajim.org/gajim/gajim/-/commit/62882b6c9f4706e58c9847f0d665ec3ff1d11b90
You're receiving this email because of your account on dev.gajim.org.
_______________________________________________
Commits mailing list -- [email protected]
To unsubscribe send an email to [email protected]