mirror of
https://github.com/moparisthebest/mail
synced 2024-12-24 00:08:48 -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:
parent
c2ce4e73ef
commit
fdd9c22144
@ -289,6 +289,8 @@ define(function(require) {
|
|||||||
}]; // sender address
|
}]; // sender address
|
||||||
this.to = [{
|
this.to = [{
|
||||||
address: 'max.musterman@gmail.com'
|
address: 'max.musterman@gmail.com'
|
||||||
|
}, {
|
||||||
|
address: 'max.musterman@gmail.com'
|
||||||
}]; // list of receivers
|
}]; // list of receivers
|
||||||
this.cc = [{
|
this.cc = [{
|
||||||
address: 'john.doe@gmail.com'
|
address: 'john.doe@gmail.com'
|
||||||
@ -403,7 +405,8 @@ define(function(require) {
|
|||||||
return {
|
return {
|
||||||
link: function(scope, elm, attrs) {
|
link: function(scope, elm, attrs) {
|
||||||
var model = attrs.ngIscroll,
|
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
|
* 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
|
// activate iscroll
|
||||||
scope.$watch(model, function() {
|
myScroll = new IScroll(listEl, {
|
||||||
var myScroll;
|
mouseWheel: true,
|
||||||
// activate iscroll
|
scrollbars: true,
|
||||||
myScroll = new IScroll(listEl, {
|
fadeScrollbars: true
|
||||||
mouseWheel: 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
|
// load the visible message bodies, when the list is re-initialized and when scrolling stopped
|
||||||
scope.loadVisibleBodies();
|
scope.loadVisibleBodies();
|
||||||
myScroll.on('scrollEnd', scope.loadVisibleBodies);
|
|
||||||
}, true);
|
}, true);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -153,6 +153,7 @@ define(function(require) {
|
|||||||
// n -> new mail
|
// n -> new mail
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
scope.state.writer.write();
|
scope.state.writer.write();
|
||||||
|
scope.$apply();
|
||||||
|
|
||||||
} else if (modifier && e.keyCode === 70 && !scope.state.writer.open) {
|
} else if (modifier && e.keyCode === 70 && !scope.state.writer.open) {
|
||||||
// f -> find
|
// f -> find
|
||||||
@ -161,39 +162,45 @@ define(function(require) {
|
|||||||
$timeout(function() {
|
$timeout(function() {
|
||||||
scope.state.mailList.searching = false;
|
scope.state.mailList.searching = false;
|
||||||
}, 200);
|
}, 200);
|
||||||
|
scope.$apply();
|
||||||
|
|
||||||
} else if (modifier && e.keyCode === 82 && scope.state.writer && !scope.state.writer.open && scope.state.mailList.selected) {
|
} else if (modifier && e.keyCode === 82 && scope.state.writer && !scope.state.writer.open && scope.state.mailList.selected) {
|
||||||
// r -> reply
|
// r -> reply
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
scope.state.writer.write(scope.state.mailList.selected);
|
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) {
|
} else if (modifier && e.keyCode === 83 && scope.state.writer && !scope.state.writer.open && scope.state.mailList.synchronize) {
|
||||||
// s -> sync folder
|
// s -> sync folder
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
scope.state.mailList.synchronize();
|
scope.state.mailList.synchronize();
|
||||||
|
scope.$apply();
|
||||||
|
|
||||||
} else if (e.keyCode === 27 && scope.state.writer.open) {
|
} else if (e.keyCode === 27 && scope.state.writer.open) {
|
||||||
// escape -> close writer
|
// escape -> close writer
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
scope.state.writer.close();
|
scope.state.writer.close();
|
||||||
|
scope.$apply();
|
||||||
|
|
||||||
} else if (e.keyCode === 27 && scope.state.account.open) {
|
} else if (e.keyCode === 27 && scope.state.account.open) {
|
||||||
// escape -> close account view
|
// escape -> close account view
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
scope.state.account.toggle(false);
|
scope.state.account.toggle(false);
|
||||||
|
scope.$apply();
|
||||||
|
|
||||||
} else if (e.keyCode === 27 && scope.state.contacts.open) {
|
} else if (e.keyCode === 27 && scope.state.contacts.open) {
|
||||||
// escape -> close contacts view
|
// escape -> close contacts view
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
scope.state.contacts.toggle(false);
|
scope.state.contacts.toggle(false);
|
||||||
|
scope.$apply();
|
||||||
|
|
||||||
} else if (e.keyCode === 27 && scope.state.nav.open) {
|
} else if (e.keyCode === 27 && scope.state.nav.open) {
|
||||||
// escape -> close nav view
|
// escape -> close nav view
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
scope.state.nav.toggle(false);
|
scope.state.nav.toggle(false);
|
||||||
|
scope.$apply();
|
||||||
}
|
}
|
||||||
|
|
||||||
scope.$apply();
|
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
Loading…
Reference in New Issue
Block a user