From c110760ac5b710dd7220e639f3c3e25acd43a560 Mon Sep 17 00:00:00 2001 From: Ivan Alejandro Date: Fri, 18 Sep 2015 12:53:57 -0300 Subject: [bug] show unread emails after sync complete Right after a complete sync we show the unread emails. - Resolves: #7453 --- src/leap/bitmask/gui/mail_status.py | 44 ++++++++++++++++++++++++++++--------- 1 file changed, 34 insertions(+), 10 deletions(-) (limited to 'src/leap/bitmask/gui') diff --git a/src/leap/bitmask/gui/mail_status.py b/src/leap/bitmask/gui/mail_status.py index 1a38c8cf..eebae49b 100644 --- a/src/leap/bitmask/gui/mail_status.py +++ b/src/leap/bitmask/gui/mail_status.py @@ -53,6 +53,8 @@ class MailStatusWidget(QtGui.QWidget): self._disabled = True self._started = False + self._unread_mails = 0 + self.ui = Ui_MailStatusWidget() self.ui.setupUi(self) @@ -92,6 +94,8 @@ class MailStatusWidget(QtGui.QWidget): callback=self._mail_handle_soledad_events) register(event=catalog.SOLEDAD_INVALID_AUTH_TOKEN, callback=self.set_soledad_invalid_auth_token) + register(event=catalog.SOLEDAD_DONE_DATA_SYNC, + callback=self._mail_handle_soledad_events) register(event=catalog.MAIL_UNREAD_MESSAGES, callback=self._mail_handle_imap_events) @@ -276,6 +280,14 @@ class MailStatusWidget(QtGui.QWidget): else: ext_status = self.tr("Sync: upload complete.") + ready = 2 + elif event == catalog.SOLEDAD_DONE_DATA_SYNC: + if self._unread_mails > 0: + self._show_unread_mails() + return + else: + ext_status = self.tr("Sync: completed.") + ready = 2 else: leap_assert(False, @@ -395,21 +407,33 @@ class MailStatusWidget(QtGui.QWidget): # We could make this configurable to include all unread mail # or all unread mail in subscribed folders. if self._started: - count = content - if count != "0": - status = self.tr("{0} Unread Emails " - "in your Inbox").format(count) - if count == "1": - status = self.tr("1 Unread Email in your Inbox") - - self._set_mail_status(status, ready=2) - else: - self._set_mail_status("", ready=2) + try: + self._unread_mails = int(content) + except: + self._unread_mails = 0 + + self._show_unread_mails() elif event == catalog.IMAP_SERVICE_STARTED: self._imap_started = True if ext_status is not None: self._set_mail_status(ext_status, ready=1) + def _show_unread_mails(self): + """ + Show the user the amount of unread emails. + """ + count = self._unread_mails + + if count > 0: + status = self.tr("{0} Unread Emails " + "in your Inbox").format(count) + if count == 1: + status = self.tr("1 Unread Email in your Inbox") + + self._set_mail_status(status, ready=2) + else: + self._set_mail_status("", ready=2) + def about_to_start(self): """ Display the correct UI for the point where mail components -- cgit v1.2.3