From 2eff335680339dcba8320885a429cc2e0807a34f Mon Sep 17 00:00:00 2001 From: Tankred Hase Date: Thu, 24 Apr 2014 15:44:54 +0200 Subject: [PATCH] Use local () instead of () in certain cases for performance --- src/js/controller/mail-list.js | 4 +--- src/js/controller/write.js | 13 ++++++------- 2 files changed, 7 insertions(+), 10 deletions(-) diff --git a/src/js/controller/mail-list.js b/src/js/controller/mail-list.js index 6db465f..b637929 100644 --- a/src/js/controller/mail-list.js +++ b/src/js/controller/mail-list.js @@ -44,7 +44,7 @@ define(function(require) { } // display fetched body - $scope.$apply(); + $scope.$digest(); // automatically decrypt if it's the selected email if (email === $scope.state.mailList.selected) { @@ -209,7 +209,6 @@ define(function(require) { $timeout(function() { // display and select first selectFirstMessage(); - $scope.$apply(); }); $scope.synchronize(); @@ -455,7 +454,6 @@ define(function(require) { scope.$watchCollection(model, function() { $timeout(function() { myScroll.refresh(); - scope.$apply(); }); // load the visible message bodies, when the list is re-initialized and when scrolling stopped scope.loadVisibleBodies(); diff --git a/src/js/controller/write.js b/src/js/controller/write.js index 58cd807..055e225 100644 --- a/src/js/controller/write.js +++ b/src/js/controller/write.js @@ -174,7 +174,7 @@ define(function(require) { } $scope.checkSendStatus(); - $scope.$apply(); + $scope.$digest(); }); }; @@ -334,10 +334,9 @@ define(function(require) { link: function(scope, elm, attrs, ctrl) { // view -> model elm.on('keyup keydown', function() { - scope.$apply(function() { - // set model - ctrl.$setViewValue(elm[0].innerText); - }); + // set model + ctrl.$setViewValue(elm[0].innerText); + scope.$digest(); }); // model -> view @@ -481,7 +480,7 @@ define(function(require) { element.on('keydown', function(e) { var code = e.keyCode; - scope.$apply(); + scope.$digest(); if (code === 32 || code === 188 || code === 186) { // catch space, comma, semicolon @@ -523,7 +522,7 @@ define(function(require) { mimeType: file.type, content: new Uint8Array(e.target.result) }); - scope.$apply(); + scope.$digest(); }; reader.readAsArrayBuffer(file); }