mirror of
https://github.com/moparisthebest/mail
synced 2024-11-25 18:32:20 -05:00
[WO-302] fix first message not selected
This commit is contained in:
parent
fb12488c5f
commit
67939a04d9
@ -9,7 +9,7 @@ define(function(require) {
|
||||
notification = require('js/util/notification'),
|
||||
emailDao, outboxBo;
|
||||
|
||||
var MailListCtrl = function($scope) {
|
||||
var MailListCtrl = function($scope, $timeout) {
|
||||
//
|
||||
// Init
|
||||
//
|
||||
@ -128,7 +128,7 @@ define(function(require) {
|
||||
}
|
||||
|
||||
// sort emails
|
||||
selectFirstMessage(getFolder().messages);
|
||||
selectFirstMessage();
|
||||
// display last update
|
||||
updateStatus('Last update: ', new Date());
|
||||
$scope.$apply();
|
||||
@ -198,7 +198,7 @@ define(function(require) {
|
||||
if (!window.chrome || !chrome.identity) {
|
||||
updateStatus('Last update: ', new Date());
|
||||
getFolder().messages = createDummyMails();
|
||||
selectFirstMessage(getFolder().messages);
|
||||
selectFirstMessage();
|
||||
return;
|
||||
}
|
||||
|
||||
@ -206,8 +206,11 @@ define(function(require) {
|
||||
|
||||
// unselect selection from old folder
|
||||
$scope.select();
|
||||
// display and select first
|
||||
selectFirstMessage(getFolder().messages);
|
||||
$timeout(function() {
|
||||
// display and select first
|
||||
selectFirstMessage();
|
||||
$scope.$apply();
|
||||
});
|
||||
|
||||
$scope.synchronize();
|
||||
});
|
||||
@ -256,7 +259,9 @@ define(function(require) {
|
||||
$scope.lastUpdate = (time) ? time : '';
|
||||
}
|
||||
|
||||
function selectFirstMessage(emails) {
|
||||
function selectFirstMessage() {
|
||||
var emails = $scope.filteredMessages;
|
||||
|
||||
if (!emails || emails.length < 1) {
|
||||
$scope.select();
|
||||
return;
|
||||
@ -264,7 +269,7 @@ define(function(require) {
|
||||
|
||||
if (!$scope.state.mailList.selected) {
|
||||
// select first message
|
||||
$scope.select(emails[emails.length - 1]);
|
||||
$scope.select(emails[0]);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -200,9 +200,12 @@ define(function(require) {
|
||||
currentFolder: currentFolder
|
||||
};
|
||||
|
||||
var loadVisibleBodiesStub = sinon.stub(scope, 'loadVisibleBodies');
|
||||
|
||||
scope.synchronize(function() {
|
||||
expect(scope.state.nav.currentFolder.messages).to.deep.equal(emails);
|
||||
expect(scope.state.mailList.selected).to.exist;
|
||||
expect(loadVisibleBodiesStub.calledOnce).to.be.true;
|
||||
loadVisibleBodiesStub.restore();
|
||||
done();
|
||||
});
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user