Skip to content
Snippets Groups Projects
Commit ade56853 authored by Brendan Taylor's avatar Brendan Taylor
Browse files

moved session.remove_events. fixes #3942

parent f8b12e3b
No related branches found
No related tags found
No related merge requests found
......@@ -924,7 +924,7 @@ class ChatControlBase(MessageControl):
self.parent_win.get_active_control() == self and \
self.parent_win.window.is_active():
# we are at the end
if not self.session.remove_events(types_list):
if self.session.remove_events(types_list):
# There were events to remove
self.redraw_after_event_removed(jid)
......
......@@ -49,6 +49,26 @@ class StanzaSession(object):
return self.loggable and account not in no_log_for and self.jid not in no_log_for
# remove events associated with this session from the queue
# returns True if any events were removed (unlike gajim.events.remove_events)
def remove_events(self, types):
any_removed = False
for event in gajim.events.get_events(self.conn.name, self.jid, types=types):
# the event wasn't in this session
if (event.type_ == 'chat' and event.parameters[8] != self) or \
(event.type_ == 'printed_chat' and event.parameters[0] != self):
continue
# events.remove_events returns True when there were no events
# for some reason
r = gajim.events.remove_events(self.conn.name, self.jid, event)
if not r:
any_removed = True
return any_removed
def generate_thread_id(self):
return "".join([random.choice(string.ascii_letters) for x in xrange(0,32)])
......
......@@ -26,21 +26,6 @@ class ChatControlSession(stanza_session.EncryptedStanzaSession):
if self.control:
self.control.session = None
# remove events associated with this session from the queue
def remove_events(self, types):
any_removed = False
for event in gajim.events.get_events(self.conn, self.jid, types=types):
if event.parameters[8] != self:
continue
r = gajim.events.remove_events(self.conn, self.jid, event)
if not_any_removed:
any_removed = r
return any_removed
# extracts chatstate from a <message/> stanza
def get_chatstate(self, msg, msgtxt):
composing_xep = None
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment