mirror of
https://github.com/moparisthebest/mail
synced 2025-02-17 23:40:22 -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'),
|
notification = require('js/util/notification'),
|
||||||
emailDao, outboxBo;
|
emailDao, outboxBo;
|
||||||
|
|
||||||
var MailListCtrl = function($scope) {
|
var MailListCtrl = function($scope, $timeout) {
|
||||||
//
|
//
|
||||||
// Init
|
// Init
|
||||||
//
|
//
|
||||||
@ -128,7 +128,7 @@ define(function(require) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// sort emails
|
// sort emails
|
||||||
selectFirstMessage(getFolder().messages);
|
selectFirstMessage();
|
||||||
// display last update
|
// display last update
|
||||||
updateStatus('Last update: ', new Date());
|
updateStatus('Last update: ', new Date());
|
||||||
$scope.$apply();
|
$scope.$apply();
|
||||||
@ -198,7 +198,7 @@ define(function(require) {
|
|||||||
if (!window.chrome || !chrome.identity) {
|
if (!window.chrome || !chrome.identity) {
|
||||||
updateStatus('Last update: ', new Date());
|
updateStatus('Last update: ', new Date());
|
||||||
getFolder().messages = createDummyMails();
|
getFolder().messages = createDummyMails();
|
||||||
selectFirstMessage(getFolder().messages);
|
selectFirstMessage();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -206,8 +206,11 @@ define(function(require) {
|
|||||||
|
|
||||||
// unselect selection from old folder
|
// unselect selection from old folder
|
||||||
$scope.select();
|
$scope.select();
|
||||||
// display and select first
|
$timeout(function() {
|
||||||
selectFirstMessage(getFolder().messages);
|
// display and select first
|
||||||
|
selectFirstMessage();
|
||||||
|
$scope.$apply();
|
||||||
|
});
|
||||||
|
|
||||||
$scope.synchronize();
|
$scope.synchronize();
|
||||||
});
|
});
|
||||||
@ -256,7 +259,9 @@ define(function(require) {
|
|||||||
$scope.lastUpdate = (time) ? time : '';
|
$scope.lastUpdate = (time) ? time : '';
|
||||||
}
|
}
|
||||||
|
|
||||||
function selectFirstMessage(emails) {
|
function selectFirstMessage() {
|
||||||
|
var emails = $scope.filteredMessages;
|
||||||
|
|
||||||
if (!emails || emails.length < 1) {
|
if (!emails || emails.length < 1) {
|
||||||
$scope.select();
|
$scope.select();
|
||||||
return;
|
return;
|
||||||
@ -264,7 +269,7 @@ define(function(require) {
|
|||||||
|
|
||||||
if (!$scope.state.mailList.selected) {
|
if (!$scope.state.mailList.selected) {
|
||||||
// select first message
|
// select first message
|
||||||
$scope.select(emails[emails.length - 1]);
|
$scope.select(emails[0]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -200,9 +200,12 @@ define(function(require) {
|
|||||||
currentFolder: currentFolder
|
currentFolder: currentFolder
|
||||||
};
|
};
|
||||||
|
|
||||||
|
var loadVisibleBodiesStub = sinon.stub(scope, 'loadVisibleBodies');
|
||||||
|
|
||||||
scope.synchronize(function() {
|
scope.synchronize(function() {
|
||||||
expect(scope.state.nav.currentFolder.messages).to.deep.equal(emails);
|
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();
|
done();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user