Commit 23a64356 authored by Saul Ibarra's avatar Saul Ibarra

Fix stopping composing timer when session is ended or chat is removed

parent bb6d1f72
...@@ -484,6 +484,8 @@ class IconDescriptor(object): ...@@ -484,6 +484,8 @@ class IconDescriptor(object):
ui_class, base_class = uic.loadUiType(Resources.get('chat_widget.ui')) ui_class, base_class = uic.loadUiType(Resources.get('chat_widget.ui'))
class ChatWidget(base_class, ui_class): class ChatWidget(base_class, ui_class):
implements(IObserver)
default_user_icon = IconDescriptor(Resources.get('icons/default-avatar.png')) default_user_icon = IconDescriptor(Resources.get('icons/default-avatar.png'))
chat_template = open(Resources.get('chat/template.html')).read() chat_template = open(Resources.get('chat/template.html')).read()
...@@ -502,6 +504,9 @@ class ChatWidget(base_class, ui_class): ...@@ -502,6 +504,9 @@ class ChatWidget(base_class, ui_class):
self.composing_timer = QTimer() self.composing_timer = QTimer()
self.last_message = None self.last_message = None
self.session = session self.session = session
if session is not None:
notification_center = NotificationCenter()
notification_center.add_observer(ObserverWeakrefProxy(self), sender=session.blink_session)
# connect to signals # connect to signals
self.chat_input.textChanged.connect(self._SH_ChatInputTextChanged) self.chat_input.textChanged.connect(self._SH_ChatInputTextChanged)
self.chat_input.textEntered.connect(self._SH_ChatInputTextEntered) self.chat_input.textEntered.connect(self._SH_ChatInputTextEntered)
...@@ -626,6 +631,21 @@ class ChatWidget(base_class, ui_class): ...@@ -626,6 +631,21 @@ class ChatWidget(base_class, ui_class):
except Exception: except Exception:
pass pass
@run_in_gui_thread
def handle_notification(self, notification):
handler = getattr(self, '_NH_%s' % notification.name, Null)
handler(notification)
def _NH_BlinkSessionDidEnd(self, notification):
self.composing_timer.stop()
def _NH_BlinkSessionWasDeleted(self, notification):
self.setParent(None)
def _NH_BlinkSessionDidRemoveStream(self, notification):
if notification.data.stream.type == 'chat':
self.composing_timer.stop()
del ui_class, base_class del ui_class, base_class
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment