diff options
author | Duda Dornelles <ddornell@thoughtworks.com> | 2015-02-22 04:36:40 -0300 |
---|---|---|
committer | Duda Dornelles <ddornell@thoughtworks.com> | 2015-02-22 04:43:26 -0300 |
commit | 66ff78361a8ef71bc05e95e614401a114b6ae42c (patch) | |
tree | e57ae83e6695939781557a3cb9ffce7e508a4cc3 /web-ui/app/js/services/mail_service.js | |
parent | 26be3c59b174eb9f1a6f73c67489738c7517ce8c (diff) |
#289 making checked mail tag aware
Diffstat (limited to 'web-ui/app/js/services/mail_service.js')
-rw-r--r-- | web-ui/app/js/services/mail_service.js | 21 |
1 files changed, 9 insertions, 12 deletions
diff --git a/web-ui/app/js/services/mail_service.js b/web-ui/app/js/services/mail_service.js index 1fa41619..b8e72a7f 100644 --- a/web-ui/app/js/services/mail_service.js +++ b/web-ui/app/js/services/mail_service.js @@ -75,7 +75,7 @@ define( }; - this.readMail = function (ev, data) { + function extractMailIds(data) { var mailIdents; if (data.checkedMails) { mailIdents = _.map(data.checkedMails, function (mail) { @@ -84,28 +84,25 @@ define( } else { mailIdents = [data.ident]; } + return mailIdents; + } + + this.readMail = function (ev, data) { + monitoredAjax(this, '/mails/read', { type: 'POST', - data: JSON.stringify({idents: mailIdents}) + data: JSON.stringify({idents: extractMailIds(data)}) }).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: mailIdents}) + data: JSON.stringify({idents: extractMailIds(data)}) }).done(this.triggerMailsRead(data.checkedMails)); }; - this.triggerMailsRead = function (mails) { + this.triggerMailsRead = function () { return _.bind(function () { this.refreshMails(); this.trigger(document, events.ui.mails.uncheckAll); |