(js) Fix virtual repeater when moving up in msgs

pull/198/head
Francis Lachapelle 2016-02-08 15:39:00 -05:00
parent ee3276f01d
commit 5a408bf14b
2 changed files with 21 additions and 2 deletions

2
NEWS
View File

@ -7,6 +7,8 @@ Enhancements
Bug fixes Bug fixes
- [web] handle birthday dates before 1970 - [web] handle birthday dates before 1970
- [web] safe-guarding against bogus value coming from the quick tables - [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) 3.0.1 (2016-02-05)
------------------ ------------------

View File

@ -312,6 +312,7 @@
Mailbox.prototype.$loadMessage = function(messageId) { Mailbox.prototype.$loadMessage = function(messageId) {
var startIndex = this.uidsMap[messageId], var startIndex = this.uidsMap[messageId],
endIndex, endIndex,
index,
max = this.$messages.length, max = this.$messages.length,
loaded = false, loaded = false,
uids, uids,
@ -325,9 +326,25 @@
// Preload more headers if possible // Preload more headers if possible
endIndex = Math.min(startIndex + Mailbox.PRELOAD.LOOKAHEAD, max - 1); endIndex = Math.min(startIndex + Mailbox.PRELOAD.LOOKAHEAD, max - 1);
if (!angular.isDefined(this.$messages[endIndex].subject) && if (angular.isDefined(this.$messages[endIndex].subject) ||
!angular.isDefined(this.$messages[endIndex].loading)) { 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); 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++) { for (uids = []; startIndex < endIndex && startIndex < max; startIndex++) {
if (angular.isDefined(this.$messages[startIndex].subject) || this.$messages[startIndex].loading) { if (angular.isDefined(this.$messages[startIndex].subject) || this.$messages[startIndex].loading) {
// Message at this index is already loaded; increase the end index // Message at this index is already loaded; increase the end index