Call () in onError handler to cleanup controller

This commit is contained in:
Tankred Hase 2013-11-14 23:57:06 +01:00
parent f23dee9369
commit 8bbb7d7d34
7 changed files with 21 additions and 25 deletions

View File

@ -55,7 +55,6 @@ define(function(require) {
$scope.incorrect = true;
$scope.buttonEnabled = true;
$scope.onError(err);
$scope.$apply();
}
};

View File

@ -38,12 +38,13 @@ define(function(require) {
setTimeout(function() {
emailDao.unlock({}, passphrase, function(err) {
if (err) {
$scope.setState(states.IDLE);
$scope.onError(err);
$scope.setState(states.IDLE, true);
return;
}
$scope.setState(states.DONE, true);
$scope.setState(states.DONE);
$scope.$apply();
});
}, 500);
};
@ -78,12 +79,8 @@ define(function(require) {
$location.path('/desktop');
};
$scope.setState = function(state, async) {
$scope.setState = function(state) {
$scope.state.ui = state;
if (async) {
$scope.$apply();
}
};
};

View File

@ -43,7 +43,6 @@ define(function(require) {
if (err) {
$scope.incorrect = true;
$scope.onError(err);
$scope.$apply();
return;
}

View File

@ -162,9 +162,8 @@ define(function(require) {
function moved(err) {
if (err) {
$scope.onError(err);
$scope.emails.splice(index, 0, email);
$scope.$apply();
$scope.onError(err);
return;
}
}
@ -227,9 +226,8 @@ define(function(require) {
function syncImapFolder(options, callback) {
emailDao.unreadMessages(getFolder().path, function(err, unreadCount) {
if (err) {
$scope.onError(err);
updateStatus('Error on sync!');
$scope.$apply();
$scope.onError(err);
return;
}
// set unread count in folder model
@ -238,9 +236,8 @@ define(function(require) {
emailDao.imapSync(options, function(err) {
if (err) {
$scope.onError(err);
updateStatus('Error on sync!');
$scope.$apply();
$scope.onError(err);
return;
}
@ -253,9 +250,8 @@ define(function(require) {
firstSelect = true;
emailDao.listMessages(options, function(err, emails) {
if (err) {
$scope.onError(err);
updateStatus('Error listing cache!');
$scope.$apply();
$scope.onError(err);
return;
}
@ -313,9 +309,8 @@ define(function(require) {
uid: email.uid
}, function(err) {
if (err) {
$scope.onError(err);
updateStatus('Error marking read!');
$scope.$apply();
$scope.onError(err);
return;
}
});

View File

@ -59,8 +59,8 @@ define(function(require) {
// get last item from outbox
emailDao._devicestorage.listItems(dbType, 0, null, function(err, pending) {
if (err) {
$scope.onError(err);
outboxBusy = false;
$scope.onError(err);
return;
}
@ -82,8 +82,8 @@ define(function(require) {
var email = emails.shift();
emailDao.smtpSend(email, function(err) {
if (err) {
$scope.onError(err);
outboxBusy = false;
$scope.onError(err);
return;
}
@ -94,10 +94,10 @@ define(function(require) {
function removeFromStorage(id) {
if (!id) {
outboxBusy = false;
$scope.onError({
errMsg: 'Cannot remove email from storage without a valid id!'
});
outboxBusy = false;
return;
}
@ -105,8 +105,8 @@ define(function(require) {
var key = dbType + '_' + id;
emailDao._devicestorage.removeList(key, function(err) {
if (err) {
$scope.onError(err);
outboxBusy = false;
$scope.onError(err);
return;
}

View File

@ -140,7 +140,8 @@ define(function(require) {
to = $scope.to.replace(/\s/g, '').split(/[,;]/);
if (!to || to.length < 1) {
$scope.onError({
errMsg: 'Seperate recipients with a comma!'
errMsg: 'Seperate recipients with a comma!',
sync: true
});
return;
}
@ -148,7 +149,8 @@ define(function(require) {
// only allow secure recipients until invitation is implemented
if (!$scope.toKey) {
$scope.onError({
errMsg: 'Invitations not yet supported!'
errMsg: 'Invitations not yet supported!',
sync: true
});
return;
}

View File

@ -16,6 +16,10 @@ define(function() {
title: options.title || 'Error',
message: options.errMsg || options.message
};
// don't call apply for synchronous calls
if (!options.sync) {
scope.$apply();
}
};
};