From ac4bde0447a5553d6a2515a8eac664806ccce03a Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Philipp=20H=C3=B6rist?= <philipp@hoerist.com>
Date: Wed, 15 May 2019 20:12:41 +0200
Subject: [PATCH] MAM: Always reset state on reconnect

It was not reset if the previous MAM query was interrupted because of a disconnect
---
 gajim/common/connection.py  | 1 +
 gajim/common/modules/mam.py | 4 ++++
 2 files changed, 5 insertions(+)

diff --git a/gajim/common/connection.py b/gajim/common/connection.py
index fadf4d51eb..d15826331c 100644
--- a/gajim/common/connection.py
+++ b/gajim/common/connection.py
@@ -1346,6 +1346,7 @@ class Connection(CommonConnection, ConnectionHandlers):
         self._discover_server()
         self._set_send_timeouts()
         self.get_module('Chatstate').enabled = True
+        self.get_module('MAM').reset_state()
 
     def _set_send_timeouts(self):
         if app.config.get_per('accounts', self.name, 'keep_alives_enabled'):
diff --git a/gajim/common/modules/mam.py b/gajim/common/modules/mam.py
index e0185777d5..6af64af71d 100644
--- a/gajim/common/modules/mam.py
+++ b/gajim/common/modules/mam.py
@@ -68,6 +68,10 @@ class MAM(BaseModule):
                          account=self._account,
                          feature=self.archiving_namespace))
 
+    def reset_state(self):
+        self._mam_query_ids.clear()
+        self._catch_up_finished.clear()
+
     def _from_valid_archive(self, _stanza, properties):
         if properties.type.is_groupchat:
             expected_archive = properties.jid
-- 
GitLab