diff --git a/src/js/controller/app/mail-list.js b/src/js/controller/app/mail-list.js index 6ca7cf1..9327aa5 100644 --- a/src/js/controller/app/mail-list.js +++ b/src/js/controller/app/mail-list.js @@ -294,6 +294,13 @@ var MailListCtrl = function($scope, $timeout, $location, $filter, $q, status, no }).catch(dialog.error); } + $scope.$on('read', function(e, state) { + if (!state) { + // load bodies after closing read mode + $scope.loadVisibleBodies(); + } + }); + function currentFolder() { return $scope.state.nav && $scope.state.nav.currentFolder; } diff --git a/src/js/controller/app/read.js b/src/js/controller/app/read.js index f27b3d0..bae4f48 100644 --- a/src/js/controller/app/read.js +++ b/src/js/controller/app/read.js @@ -4,7 +4,7 @@ // Controller // -var ReadCtrl = function($scope, $location, $q, email, invitation, outbox, pgp, keychain, appConfig, download, auth, dialog) { +var ReadCtrl = function($scope, $location, $q, email, invitation, outbox, pgp, keychain, appConfig, download, auth, dialog, status) { var str = appConfig.string; @@ -47,6 +47,13 @@ var ReadCtrl = function($scope, $location, $q, email, invitation, outbox, pgp, k // scope functions // + /** + * Close read mode and return to mail-list + */ + $scope.close = function() { + status.setReading(false); + }; + $scope.getKeyId = function(address) { if ($location.search().dev || !address) { return; diff --git a/src/js/directive/mail-list.js b/src/js/directive/mail-list.js index 27f622b..0ed8679 100644 --- a/src/js/directive/mail-list.js +++ b/src/js/directive/mail-list.js @@ -2,7 +2,7 @@ var ngModule = angular.module('woDirectives'); -ngModule.directive('listScroll', function() { +ngModule.directive('listScroll', function($timeout) { return { link: function(scope, elm, attrs) { var model = attrs.listScroll, @@ -12,7 +12,7 @@ ngModule.directive('listScroll', function() { /* * iterates over the mails in the mail list and loads their bodies if they are visible in the viewport */ - scope.loadVisibleBodies = function() { + function loadVisibleBodies() { var listBorder = listEl.getBoundingClientRect(), top = listBorder.top, bottom = listBorder.bottom, @@ -53,6 +53,13 @@ ngModule.directive('listScroll', function() { break; } } + } + + scope.loadVisibleBodies = function() { + // wait for next tick so that scope is digested and synced to DOM + $timeout(function() { + loadVisibleBodies(); + }); }; // load body when scrolling diff --git a/src/tpl/read.html b/src/tpl/read.html index 9c26dcb..ca5461e 100644 --- a/src/tpl/read.html +++ b/src/tpl/read.html @@ -6,7 +6,7 @@
- + Back {{state.nav.currentFolder.wellknown ? state.nav.currentFolder.type : state.nav.currentFolder.name}} @@ -51,7 +51,7 @@ {{state.mailList.selected.subject ? state.mailList.selected.subject : 'No subject'}} -

+

Back {{state.mailList.selected.subject ? state.mailList.selected.subject : 'No subject'}}