1
0
mirror of https://github.com/moparisthebest/mail synced 2024-11-22 17:02:17 -05:00

[WO-136] show notification when email has been sent

This commit is contained in:
Tankred Hase 2013-12-05 15:02:41 +01:00
parent 9a8e6ff3dd
commit cf031a105e
4 changed files with 40 additions and 4 deletions

View File

@ -65,6 +65,16 @@ define(function(require) {
delete this._intervalId; 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. * Checks the local device storage for pending mails.
* @param {Function} callback(error, pendingMailsCount) Callback that informs you about the count of 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); callback(err);
return; return;
} }
// fire sent notification
self._onSent(invitationMail);
invitationFinished(); invitationFinished();
}); });
} }
@ -241,6 +255,9 @@ define(function(require) {
return; return;
} }
// fire sent notification
self._onSent(email);
removeFromStorage(email.id); removeFromStorage(email.id);
}); });
} }

View File

@ -79,6 +79,11 @@ define(function(require) {
emailDao.sync({ emailDao.sync({
folder: getFolder().path folder: getFolder().path
}, function(err) { }, function(err) {
if (err && err.code === 409) {
// sync still busy
return;
}
if (err) { if (err) {
updateStatus('Error on sync!'); updateStatus('Error on sync!');
$scope.onError(err); $scope.onError(err);
@ -176,10 +181,10 @@ define(function(require) {
// //
function notificationForEmail(email) { function notificationForEmail(email) {
chrome.notifications.create('' + email.uid, { chrome.notifications.create('i' + email.uid, {
type: 'basic', type: 'basic',
title: email.from[0].address, title: email.from[0].name || email.from[0].address,
message: email.subject.split(str.subjectPrefix)[1], message: email.subject.replace(str.subjectPrefix, ''),
iconUrl: chrome.runtime.getURL(cfg.iconPath) iconUrl: chrome.runtime.getURL(cfg.iconPath)
}, function() {}); }, function() {});
} }

View File

@ -2,6 +2,8 @@ define(function(require) {
'use strict'; 'use strict';
var angular = require('angular'), var angular = require('angular'),
str = require('js/app-config').string,
cfg = require('js/app-config').config,
appController = require('js/app-controller'), appController = require('js/app-controller'),
errorUtil = require('js/util/error'), errorUtil = require('js/util/error'),
_ = require('underscore'), _ = require('underscore'),
@ -67,6 +69,8 @@ define(function(require) {
// get pointer to account/folder/message tree on root scope // get pointer to account/folder/message tree on root scope
$scope.$root.account = emailDao._account; $scope.$root.account = emailDao._account;
// set notificatio handler for sent messages
outboxBo.onSent = sentNotification;
// start checking outbox periodically // start checking outbox periodically
outboxBo.startChecking($scope.onOutboxUpdate); outboxBo.startChecking($scope.onOutboxUpdate);
// make function available globally for write controller // make function available globally for write controller
@ -98,6 +102,15 @@ define(function(require) {
path: 'TRASH' 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() {});
}
}; };
// //

View File

@ -165,7 +165,8 @@ define(function(require) {
if (self._account.busy) { if (self._account.busy) {
callback({ callback({
errMsg: 'Sync aborted: Previous sync still in progress' errMsg: 'Sync aborted: Previous sync still in progress',
code: 409
}); });
return; return;
} }