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:
parent
9a8e6ff3dd
commit
cf031a105e
@ -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);
|
||||
});
|
||||
}
|
||||
|
@ -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() {});
|
||||
}
|
||||
|
@ -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() {});
|
||||
}
|
||||
};
|
||||
|
||||
//
|
||||
|
@ -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;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user