refactor delete function for future use

This commit is contained in:
Synox 2017-03-21 12:35:17 +01:00
parent 27756d881c
commit 04d350713b
2 changed files with 5 additions and 3 deletions

View file

@ -113,11 +113,13 @@ app.controller('MailboxController', ["$interval", "$http", "$log", function ($in
});
};
self.deleteMail = function (mailid, index) {
self.deleteMail = function (mail, index) {
// instantly remove from frontend.
self.mails.splice(index, 1);
// remove on backend.
$http.get(backend_url, {params: {username: self.username, delete_email_id: mailid}})
var firstTo = Object.keys(mail.to)[0];
$http.get(backend_url, {params: {username: firstTo, delete_email_id: mail.id}})
.then(
function successCallback(response) {
self.updateMails();

View file

@ -86,7 +86,7 @@
download="true">Download
</a>
<button ng-click="$ctrl.deleteMail(mail.id)" type="button"
<button ng-click="$ctrl.deleteMail(mail)" type="button"
class="btn btn-sm btn-outline-danger">Delete
</button>
</form>