frontends: printInfo and printMessage timestamp attribute defaults to None instead of ''
This commit is contained in:
parent
4f339272b7
commit
7a344fcf5d
1 changed files with 15 additions and 11 deletions
|
|
@ -290,14 +290,14 @@ class Chat(urwid.WidgetWrap, QuickChat):
|
|||
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 @@ class Chat(urwid.WidgetWrap, QuickChat):
|
|||
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 @@ class Chat(urwid.WidgetWrap, QuickChat):
|
|||
# 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)
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue