comparison sat_frontends/primitivus/chat.py @ 2992:4d5b9d4c7448

primitivus (chat): don't show minor notifications (all but mentions) when printing history fix 316
author Goffi <goffi@goffi.org>
date Mon, 08 Jul 2019 09:20:06 +0200
parents b5f8cb26ef6f
children ab2696e34d29
comparison
equal deleted inserted replaced
2991:f4590ca2acff 2992:4d5b9d4c7448
424 bottom = len(self.mess_walker) - 1 424 bottom = len(self.mess_walker) - 1
425 if current_focus == bottom - 1: 425 if current_focus == bottom - 1:
426 self.mess_widgets.focus_position = bottom # scroll down 426 self.mess_widgets.focus_position = bottom # scroll down
427 self.host.redraw() # FIXME: should not be necessary 427 self.host.redraw() # FIXME: should not be necessary
428 428
429 def appendMessage(self, message): 429 def appendMessage(self, message, minor_notifs=True):
430 """Create a MessageWidget and append it 430 """Create a MessageWidget and append it
431 431
432 Can merge messages together is desirable (e.g.: multiple joined/leave) 432 Can merge info messages together if desirable (e.g.: multiple joined/leave)
433 @param message(quick_chat.Message): message to add 433 @param message(quick_chat.Message): message to add
434 @param minor_notifs(boolean): if True, basic notifications are allowed
435 If False, notification are not shown except if we have an important one
436 (like a mention).
437 False is generally used when printing history, when we don't want every
438 message to be notified.
434 """ 439 """
435 if self.filters: 440 if self.filters:
436 if not all([f(message) for f in self.filters]): 441 if not all([f(message) for f in self.filters]):
437 return 442 return
438 443
479 ) 484 )
480 ) 485 )
481 self.host.notify( 486 self.host.notify(
482 C.NOTIFY_MENTION, from_jid, msg, widget=self, profile=self.profile 487 C.NOTIFY_MENTION, from_jid, msg, widget=self, profile=self.profile
483 ) 488 )
489 elif not minor_notifs:
490 return
484 elif self.type == C.CHAT_ONE2ONE: 491 elif self.type == C.CHAT_ONE2ONE:
485 from_jid = wid.mess_data.from_jid 492 from_jid = wid.mess_data.from_jid
486 msg = _(u"{entity} is talking to you".format(entity=from_jid)) 493 msg = _(u"{entity} is talking to you".format(entity=from_jid))
487 self.host.notify( 494 self.host.notify(
488 C.NOTIFY_MESSAGE, from_jid, msg, widget=self, profile=self.profile 495 C.NOTIFY_MESSAGE, from_jid, msg, widget=self, profile=self.profile
565 @param clear(bool): clear message before printing if true 572 @param clear(bool): clear message before printing if true
566 """ 573 """
567 if clear: 574 if clear:
568 del self.mess_walker[:] 575 del self.mess_walker[:]
569 for message in self.messages.itervalues(): 576 for message in self.messages.itervalues():
570 self.appendMessage(message) 577 self.appendMessage(message, minor_notifs=False)
571 578
572 def redraw(self): 579 def redraw(self):
573 """redraw all messages""" 580 """redraw all messages"""
574 for w in self.mess_walker: 581 for w in self.mess_walker:
575 try: 582 try: