Fix stored messages growing infinitely on reloads

This commit is contained in:
Kristóf Tóth 2018-07-20 09:20:42 +02:00
parent 7376504dd2
commit bd6cdc5409

View File

@ -47,6 +47,7 @@ class TFWServer:
def handle_recover(self, message): def handle_recover(self, message):
if message['key'] == 'recover': if message['key'] == 'recover':
self._frontend_messages.replay_messages(self._uplink_connector) self._frontend_messages.replay_messages(self._uplink_connector)
self._frontend_messages.clear()
def save_frontend_messages(self, message): def save_frontend_messages(self, message):
self._frontend_messages.save_message(message) self._frontend_messages.save_message(message)
@ -70,6 +71,9 @@ class MessageStorage(ABC):
def transform_message(self, message): # pylint: disable=no-self-use def transform_message(self, message): # pylint: disable=no-self-use
yield message yield message
def clear(self):
self.saved_messages.clear()
class FrontendMessageStorage(MessageStorage): class FrontendMessageStorage(MessageStorage):
def filter_message(self, message): def filter_message(self, message):