diff --git a/src/js/controller/mail-list.js b/src/js/controller/mail-list.js index 1eb83a7..4954e6c 100644 --- a/src/js/controller/mail-list.js +++ b/src/js/controller/mail-list.js @@ -5,12 +5,12 @@ define(function(require) { _ = require('underscore'), appController = require('js/app-controller'), notification = require('js/util/notification'), - emailDao, outboxBo, keychainDao, searchTimeout; + emailDao, outboxBo, keychainDao, searchTimeout, firstSelect; var INIT_DISPLAY_LEN = 20, SCROLL_DISPLAY_LEN = 10; - var MailListCtrl = function($scope, $timeout) { + var MailListCtrl = function($scope) { // // Init // @@ -56,7 +56,12 @@ define(function(require) { } $scope.state.mailList.selected = email; - $scope.state.read.toggle(true); + + if (!firstSelect) { + // only toggle to read view on 2nd select in mobile mode + $scope.state.read.toggle(true); + } + firstSelect = false; keychainDao.refreshKeyForUserId(email.from[0].address, onKeyRefreshed); @@ -183,9 +188,8 @@ define(function(require) { // Shows the next message based on the uid of the currently selected element if (currentFolder().messages.indexOf(currentMessage()) === -1) { - $timeout(function() { - $scope.select($scope.displayMessages[0]); - }); + firstSelect = true; // reset first selection + $scope.select($scope.displayMessages[0]); } }); @@ -388,6 +392,7 @@ define(function(require) { return; } + firstSelect = false; $scope.select(_.findWhere(currentFolder().messages, { uid: uid })); diff --git a/test/unit/mail-list-ctrl-test.js b/test/unit/mail-list-ctrl-test.js index c4f93e8..c762a27 100644 --- a/test/unit/mail-list-ctrl-test.js +++ b/test/unit/mail-list-ctrl-test.js @@ -458,7 +458,7 @@ define(function(require) { scope.remove(mail); expect(emailDaoMock.deleteMessage.calledOnce).to.be.true; - expect(scope.state.mailList.selected).to.not.exist; + expect(scope.state.mailList.selected).to.exist; }); }); });