Merge pull request #249 from whiteout-io/dev/WO-690

Fetch message contents when leaving read mode
This commit is contained in:
Felix Hammerl 2015-01-15 11:36:56 +01:00
commit c165ced523
4 changed files with 26 additions and 5 deletions

View File

@ -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;
}

View File

@ -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;

View File

@ -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

View File

@ -6,7 +6,7 @@
<div class="read__folder-toolbar">
<div class="toolbar">
<a class="toolbar__label" href="#" wo-touch="$event.preventDefault(); state.read.toggle(false)">
<a class="toolbar__label" href="#" wo-touch="$event.preventDefault(); close()">
<svg><use xlink:href="#icon-back" /><title>Back</title></svg>
{{state.nav.currentFolder.wellknown ? state.nav.currentFolder.type : state.nav.currentFolder.name}}
</a>
@ -51,7 +51,7 @@
{{state.mailList.selected.subject ? state.mailList.selected.subject : 'No subject'}}
</h2>
<h2 class="read__subject-md" wo-touch="state.read.toggle(false)">
<h2 class="read__subject-md" wo-touch="close()">
<svg><use xlink:href="#icon-back" /><title>Back</title></svg>
{{state.mailList.selected.subject ? state.mailList.selected.subject : 'No subject'}}
</h2>