diff options
Diffstat (limited to 'web-ui/app/js/services')
-rw-r--r-- | web-ui/app/js/services/mail_service.js | 21 |
1 files changed, 12 insertions, 9 deletions
diff --git a/web-ui/app/js/services/mail_service.js b/web-ui/app/js/services/mail_service.js index b8e72a7f..1fa41619 100644 --- a/web-ui/app/js/services/mail_service.js +++ b/web-ui/app/js/services/mail_service.js @@ -75,7 +75,7 @@ define( }; - function extractMailIds(data) { + this.readMail = function (ev, data) { var mailIdents; if (data.checkedMails) { mailIdents = _.map(data.checkedMails, function (mail) { @@ -84,25 +84,28 @@ define( } else { mailIdents = [data.ident]; } - return mailIdents; - } - - this.readMail = function (ev, data) { - monitoredAjax(this, '/mails/read', { type: 'POST', - data: JSON.stringify({idents: extractMailIds(data)}) + data: JSON.stringify({idents: mailIdents}) }).done(this.triggerMailsRead(data.checkedMails)); }; this.unreadMail = function (ev, data) { + var mailIdents; + if (data.checkedMails) { + mailIdents = _.map(data.checkedMails, function (mail) { + return mail.ident; + }); + } else { + mailIdents = [data.ident]; + } monitoredAjax(this, '/mails/unread', { type: 'POST', - data: JSON.stringify({idents: extractMailIds(data)}) + data: JSON.stringify({idents: mailIdents}) }).done(this.triggerMailsRead(data.checkedMails)); }; - this.triggerMailsRead = function () { + this.triggerMailsRead = function (mails) { return _.bind(function () { this.refreshMails(); this.trigger(document, events.ui.mails.uncheckAll); |