primitivus: fixed display of error if a message can't be sent

This commit is contained in:
Goffi 2017-02-05 14:55:21 +01:00
commit 61765efd9e

View file

@ -88,7 +88,7 @@ class EditBar(sat_widgets.ModalEdit):
chat_widget.target,
{'': editBar.get_edit_text()}, # TODO: handle language
mess_type = C.MESS_TYPE_GROUPCHAT if chat_widget.type == C.CHAT_GROUP else C.MESS_TYPE_CHAT, # TODO: put this in QuickChat
errback=lambda failure: self.host.notify(_("Error while sending message ({})").format(failure)),
errback=lambda failure: self.host.showDialog(_("Error while sending message ({})").format(failure), type="error"),
profile_key=chat_widget.profile
)
editBar.set_edit_text('')
@ -717,16 +717,16 @@ class PrimitivusApp(QuickApp, InputHistory):
if answer_cb is not None:
answer_cb(False, answer_data)
def showDialog(self, message, title="", type_="info", answer_cb = None, answer_data = None):
if type_ == 'info':
def showDialog(self, message, title="", type="info", answer_cb = None, answer_data = None):
if type == 'info':
popup = sat_widgets.Alert(title, message, ok_cb=answer_cb)
if answer_cb is None:
popup.setCallback('ok', lambda dummy: self.removePopUp(popup))
elif type_ == 'error':
elif type == 'error':
popup = sat_widgets.Alert(title, message, ok_cb=answer_cb)
if answer_cb is None:
popup.setCallback('ok', lambda dummy: self.removePopUp(popup))
elif type_ == 'yes/no':
elif type == 'yes/no':
popup = sat_widgets.ConfirmDialog(message)
popup.setCallback('yes', self._dialogOkCb, (popup, answer_cb, answer_data))
popup.setCallback('no', self._dialogCancelCb, (popup, answer_cb, answer_data))
@ -734,7 +734,7 @@ class PrimitivusApp(QuickApp, InputHistory):
popup = sat_widgets.Alert(title, message, ok_cb=answer_cb)
if answer_cb is None:
popup.setCallback('ok', lambda dummy: self.removePopUp(popup))
log.error(u'unmanaged dialog type: {}'.format(type_))
log.error(u'unmanaged dialog type: {}'.format(type))
self.showPopUp(popup)
def dialogFailure(self, failure):