diff frontends/src/primitivus/chat.py @ 1223:802b7e6bf098

frontends: printInfo and printMessage timestamp attribute defaults to None instead of ''
author souliane <souliane@mailoo.org>
date Sat, 04 Oct 2014 10:23:13 +0200
parents 6184779544c7
children e3a9ea76de35
line wrap: on
line diff
--- a/frontends/src/primitivus/chat.py	Wed Sep 24 13:49:43 2014 +0200
+++ b/frontends/src/primitivus/chat.py	Sat Oct 04 10:23:13 2014 +0200
@@ -290,14 +290,14 @@
             self.text_list.focus_position = len(self.content) - 1  # scroll down
         self.host.redraw()
 
-    def printMessage(self, from_jid, msg, profile, timestamp=""):
+    def printMessage(self, from_jid, msg, profile, timestamp=None):
         assert isinstance(from_jid, JID)
         try:
             jid, nick, mymess = QuickChat.printMessage(self, from_jid, msg, profile, timestamp)
         except TypeError:
             return
 
-        new_text = ChatText(self, timestamp or None, nick, mymess, msg)
+        new_text = ChatText(self, timestamp, nick, mymess, msg)
 
         if timestamp and self.content:
             for idx in range(len(self.content) - 1, -1, -1):
@@ -307,6 +307,7 @@
                     continue  # the new message is older, we need to insert it upper
 
                 #we discard double messages, to avoid backlog / history conflict
+                # FIXME: messages that have been sent several times will be displayed only once
                 if ((idx and self.content[idx - 1].message == msg) or
                     (self.content[idx].message == msg) or
                     (idx < len(self.content) - 2 and self.content[idx + 1].message)):
@@ -322,14 +323,15 @@
             # all messages and not only with the messages coming from the history.
             self._notify(from_jid, msg)
 
-    def printInfo(self, msg, type_='normal', timestamp=""):
+    def printInfo(self, msg, type_='normal', timestamp=None):
         """Print general info
         @param msg: message to print
         @type_: one of:
             normal: general info like "toto has joined the room"
             me: "/me" information like "/me clenches his fist" ==> "toto clenches his fist"
+        @param timestamp (float): number of seconds since epoch
         """
-        _widget = ChatText(self, timestamp or None, None, False, msg, is_info=True)
+        _widget = ChatText(self, timestamp, None, False, msg, is_info=True)
         self.content.append(_widget)
         self._notify(msg=msg)