(js) Improve handling of message flags

We now call the model's methods from the template. Uncluttered the
message controller. Fixed the synchronization of the flags with the
messages list.
This commit is contained in:
Francis Lachapelle
2015-06-12 12:02:19 -04:00
parent ec123b4512
commit a9ad21b395
5 changed files with 60 additions and 31 deletions
@@ -10,17 +10,6 @@
function MessageController($scope, $rootScope, $stateParams, $state, stateAccount, stateMailbox, stateMessage, $timeout, encodeUriFilter, focus, Dialog, Account, Mailbox) {
$rootScope.message = stateMessage;
$scope.tags = {};
$scope.addOrRemoveTag = function(operation, tag) {
if (tag) {
stateMessage.$addOrRemoveTag(operation, tag);
}
};
$scope.markAsFlaggedOrUnflagged = function() {
var operation = (stateMessage.isflagged ? 'remove' : 'add');
stateMessage.$markAsFlaggedOrUnflagged(operation).then(function() {
stateMessage.isflagged = !stateMessage.isflagged;
});
};
$scope.doDelete = function() {
stateMailbox.$deleteMessages([stateMessage.uid]).then(function() {
// Remove message from list of messages