1
0
mirror of https://github.com/moparisthebest/mail synced 2024-12-23 15:58:49 -05:00

[WO-312] Fix slowness for large inbox

* Fix memory leak causing iScroll to be re-initialized each time mail-list model changes
* Only do $scope.$apply() when keyboard shortcuts are actually executed
This commit is contained in:
Tankred Hase 2014-04-22 19:41:14 +02:00
parent c2ce4e73ef
commit fdd9c22144
2 changed files with 24 additions and 12 deletions

View File

@ -289,6 +289,8 @@ define(function(require) {
}]; // sender address
this.to = [{
address: 'max.musterman@gmail.com'
}, {
address: 'max.musterman@gmail.com'
}]; // list of receivers
this.cc = [{
address: 'john.doe@gmail.com'
@ -403,7 +405,8 @@ define(function(require) {
return {
link: function(scope, elm, attrs) {
var model = attrs.ngIscroll,
listEl = elm[0];
listEl = elm[0],
myScroll;
/*
* iterates over the mails in the mail list and loads their bodies if they are visible in the viewport
@ -439,17 +442,19 @@ define(function(require) {
}
};
// re-init iScroll when model length changes
scope.$watch(model, function() {
var myScroll;
// activate iscroll
myScroll = new IScroll(listEl, {
mouseWheel: true
mouseWheel: true,
scrollbars: true,
fadeScrollbars: true
});
myScroll.on('scrollEnd', scope.loadVisibleBodies);
// refresh iScroll when model length changes
scope.$watch(model, function() {
myScroll.refresh();
// load the visible message bodies, when the list is re-initialized and when scrolling stopped
scope.loadVisibleBodies();
myScroll.on('scrollEnd', scope.loadVisibleBodies);
}, true);
}
};

View File

@ -153,6 +153,7 @@ define(function(require) {
// n -> new mail
e.preventDefault();
scope.state.writer.write();
scope.$apply();
} else if (modifier && e.keyCode === 70 && !scope.state.writer.open) {
// f -> find
@ -161,39 +162,45 @@ define(function(require) {
$timeout(function() {
scope.state.mailList.searching = false;
}, 200);
scope.$apply();
} else if (modifier && e.keyCode === 82 && scope.state.writer && !scope.state.writer.open && scope.state.mailList.selected) {
// r -> reply
e.preventDefault();
scope.state.writer.write(scope.state.mailList.selected);
scope.$apply();
} else if (modifier && e.keyCode === 83 && scope.state.writer && !scope.state.writer.open && scope.state.mailList.synchronize) {
// s -> sync folder
e.preventDefault();
scope.state.mailList.synchronize();
scope.$apply();
} else if (e.keyCode === 27 && scope.state.writer.open) {
// escape -> close writer
e.preventDefault();
scope.state.writer.close();
scope.$apply();
} else if (e.keyCode === 27 && scope.state.account.open) {
// escape -> close account view
e.preventDefault();
scope.state.account.toggle(false);
scope.$apply();
} else if (e.keyCode === 27 && scope.state.contacts.open) {
// escape -> close contacts view
e.preventDefault();
scope.state.contacts.toggle(false);
scope.$apply();
} else if (e.keyCode === 27 && scope.state.nav.open) {
// escape -> close nav view
e.preventDefault();
scope.state.nav.toggle(false);
scope.$apply();
}
scope.$apply();
});
};
});