comparison frontends/src/primitivus/chat.py @ 518:75216d94a89d

primitivus: fixed messages order in chat window
author Goffi <goffi@goffi.org>
date Sun, 21 Oct 2012 12:03:29 +0200
parents fe79a724e6fa
children 4d7248f4c577
comparison
equal deleted inserted replaced
517:59b32c04e105 518:75216d94a89d
245 for _chat_text in self.content: 245 for _chat_text in self.content:
246 if (msg == _chat_text.message and 246 if (msg == _chat_text.message and
247 timestamp - time.mktime(_chat_text.timestamp) < 5): 247 timestamp - time.mktime(_chat_text.timestamp) < 5):
248 #we discard double messages, to avoid backlog / history conflict 248 #we discard double messages, to avoid backlog / history conflict
249 return 249 return
250 my_jid = self.host.profiles[profile]['whoami']
251 self.content.append(ChatText(self, timestamp or None, nick, mymess, msg)) 250 self.content.append(ChatText(self, timestamp or None, nick, mymess, msg))
251 if timestamp:
252 self.content.sort(key=lambda chat_text: chat_text.timestamp)
252 if self.text_list.get_focus()[1] == len(self.content)-2: 253 if self.text_list.get_focus()[1] == len(self.content)-2:
253 #we don't change focus if user is not at the bottom 254 #we don't change focus if user is not at the bottom
254 #as that mean that he is probably watching discussion history 255 #as that mean that he is probably watching discussion history
255 self.text_list.set_focus(len(self.content)-1) 256 self.text_list.set_focus(len(self.content)-1)
256 self.host.redraw() 257 self.host.redraw()