Mercurial > libervia-web
comparison src/browser/sat_browser/chat.py @ 807:0576fec37be0
browser_side (chat): adapt printMessage to recent modifications done in quick_chat
author | souliane <souliane@mailoo.org> |
---|---|
date | Tue, 15 Dec 2015 19:35:00 +0100 |
parents | f3cd261ea12f |
children | 9e1e6d5241f9 |
comparison
equal
deleted
inserted
replaced
806:cab7bf950fa0 | 807:0576fec37be0 |
---|---|
54 unicode = str # FIXME: pyjamas workaround | 54 unicode = str # FIXME: pyjamas workaround |
55 | 55 |
56 | 56 |
57 class ChatText(HTMLPanel): | 57 class ChatText(HTMLPanel): |
58 | 58 |
59 def __init__(self, nick, mymess, msg, extra): | 59 def __init__(self, timestamp, nick, mymess, msg, extra): |
60 try: | |
61 timestamp = float(extra['timestamp']) | |
62 except KeyError: | |
63 timestamp=None | |
64 xhtml = extra.get('xhtml') | 60 xhtml = extra.get('xhtml') |
65 _date = datetime.fromtimestamp(float(timestamp or time())) | 61 _date = datetime.fromtimestamp(float(timestamp or time())) |
66 _msg_class = ["chat_text_msg"] | 62 _msg_class = ["chat_text_msg"] |
67 if mymess: | 63 if mymess: |
68 _msg_class.append("chat_text_mymess") | 64 _msg_class.append("chat_text_mymess") |
241 else: | 237 else: |
242 raise ValueError("Unknown printInfo type %s" % type_) | 238 raise ValueError("Unknown printInfo type %s" % type_) |
243 self.content.add(_wid) | 239 self.content.add(_wid) |
244 self.content_scroll.scrollToBottom() | 240 self.content_scroll.scrollToBottom() |
245 | 241 |
246 def printMessage(self, from_jid, msg, extra=None, profile=C.PROF_KEY_NONE): | 242 def printMessage(self, nick, my_message, message, timestamp, extra=None, profile=C.PROF_KEY_NONE): |
247 if extra is None: | 243 if extra is None: |
248 extra = {} | 244 extra = {} |
249 try: | 245 self.content.add(ChatText(timestamp, nick, my_message, message, extra)) |
250 nick, mymess = QuickChat.printMessage(self, from_jid, msg, extra, profile) | |
251 except TypeError: | |
252 # None is returned, the message is managed | |
253 return | |
254 self.content.add(ChatText(nick, mymess, msg, extra)) | |
255 self.content_scroll.scrollToBottom() | 246 self.content_scroll.scrollToBottom() |
256 | 247 |
257 def setTitle(self, title=None, extra=None): | 248 def setTitle(self, title=None, extra=None): |
258 """Refresh the title of this Chat dialog | 249 """Refresh the title of this Chat dialog |
259 | 250 |