diff --git a/NEWS b/NEWS index b19f0cb2b..8c1d07176 100644 --- a/NEWS +++ b/NEWS @@ -7,6 +7,8 @@ Enhancements Bug fixes - [web] handle birthday dates before 1970 - [web] safe-guarding against bogus value coming from the quick tables + - [web] apply search filters when automatically reloading current mailbox (#3507) + - [web] fixed virtual repeater when moving up in messages list 3.0.1 (2016-02-05) ------------------ diff --git a/UI/WebServerResources/js/Mailer/Mailbox.service.js b/UI/WebServerResources/js/Mailer/Mailbox.service.js index 9896d9092..8b9e86275 100644 --- a/UI/WebServerResources/js/Mailer/Mailbox.service.js +++ b/UI/WebServerResources/js/Mailer/Mailbox.service.js @@ -312,6 +312,7 @@ Mailbox.prototype.$loadMessage = function(messageId) { var startIndex = this.uidsMap[messageId], endIndex, + index, max = this.$messages.length, loaded = false, uids, @@ -325,9 +326,25 @@ // Preload more headers if possible endIndex = Math.min(startIndex + Mailbox.PRELOAD.LOOKAHEAD, max - 1); - if (!angular.isDefined(this.$messages[endIndex].subject) && - !angular.isDefined(this.$messages[endIndex].loading)) { + if (angular.isDefined(this.$messages[endIndex].subject) || + angular.isDefined(this.$messages[endIndex].loading)) { + index = Math.max(startIndex - Mailbox.PRELOAD.LOOKAHEAD, 0); + if (!angular.isDefined(this.$messages[index].subject) && + !angular.isDefined(this.$messages[index].loading)) { + // Previous messages not loaded; preload more headers further up + endIndex = startIndex; + startIndex = Math.max(startIndex - Mailbox.PRELOAD.SIZE, 0); + } + } + else + // Next messages not load; preload more headers further down endIndex = Math.min(startIndex + Mailbox.PRELOAD.SIZE, max); + + if (!angular.isDefined(this.$messages[startIndex].subject) && + !angular.isDefined(this.$messages[startIndex].loading) || + !angular.isDefined(this.$messages[endIndex].subject) && + !angular.isDefined(this.$messages[endIndex].loading)) { + for (uids = []; startIndex < endIndex && startIndex < max; startIndex++) { if (angular.isDefined(this.$messages[startIndex].subject) || this.$messages[startIndex].loading) { // Message at this index is already loaded; increase the end index