diff --git a/src/js/bo/outbox.js b/src/js/bo/outbox.js index 648986e..35dca95 100644 --- a/src/js/bo/outbox.js +++ b/src/js/bo/outbox.js @@ -65,6 +65,16 @@ define(function(require) { delete this._intervalId; }; + /** + * Private Api which is called whenever a message has been sent + * The public callback "onSent" can be set by the caller to get notified. + */ + OutboxBO.prototype._onSent = function(message) { + if (typeof this.onSent === 'function') { + this.onSent(message); + } + }; + /** * Checks the local device storage for pending mails. * @param {Function} callback(error, pendingMailsCount) Callback that informs you about the count of pending mails. @@ -225,6 +235,10 @@ define(function(require) { callback(err); return; } + + // fire sent notification + self._onSent(invitationMail); + invitationFinished(); }); } @@ -241,6 +255,9 @@ define(function(require) { return; } + // fire sent notification + self._onSent(email); + removeFromStorage(email.id); }); } diff --git a/src/js/controller/mail-list.js b/src/js/controller/mail-list.js index 3bc9c96..66bee59 100644 --- a/src/js/controller/mail-list.js +++ b/src/js/controller/mail-list.js @@ -79,6 +79,11 @@ define(function(require) { emailDao.sync({ folder: getFolder().path }, function(err) { + if (err && err.code === 409) { + // sync still busy + return; + } + if (err) { updateStatus('Error on sync!'); $scope.onError(err); @@ -176,10 +181,10 @@ define(function(require) { // function notificationForEmail(email) { - chrome.notifications.create('' + email.uid, { + chrome.notifications.create('i' + email.uid, { type: 'basic', - title: email.from[0].address, - message: email.subject.split(str.subjectPrefix)[1], + title: email.from[0].name || email.from[0].address, + message: email.subject.replace(str.subjectPrefix, ''), iconUrl: chrome.runtime.getURL(cfg.iconPath) }, function() {}); } diff --git a/src/js/controller/navigation.js b/src/js/controller/navigation.js index 9f08a96..429f542 100644 --- a/src/js/controller/navigation.js +++ b/src/js/controller/navigation.js @@ -2,6 +2,8 @@ define(function(require) { 'use strict'; var angular = require('angular'), + str = require('js/app-config').string, + cfg = require('js/app-config').config, appController = require('js/app-controller'), errorUtil = require('js/util/error'), _ = require('underscore'), @@ -67,6 +69,8 @@ define(function(require) { // get pointer to account/folder/message tree on root scope $scope.$root.account = emailDao._account; + // set notificatio handler for sent messages + outboxBo.onSent = sentNotification; // start checking outbox periodically outboxBo.startChecking($scope.onOutboxUpdate); // make function available globally for write controller @@ -98,6 +102,15 @@ define(function(require) { path: 'TRASH' }]; } + + function sentNotification(email) { + chrome.notifications.create('o' + email.id, { + type: 'basic', + title: 'Sent successfully!', + message: email.subject.replace(str.subjectPrefix, ''), + iconUrl: chrome.runtime.getURL(cfg.iconPath) + }, function() {}); + } }; // diff --git a/src/js/dao/email-dao.js b/src/js/dao/email-dao.js index 3d39c8c..9751f29 100644 --- a/src/js/dao/email-dao.js +++ b/src/js/dao/email-dao.js @@ -165,7 +165,8 @@ define(function(require) { if (self._account.busy) { callback({ - errMsg: 'Sync aborted: Previous sync still in progress' + errMsg: 'Sync aborted: Previous sync still in progress', + code: 409 }); return; }