Skip to content

Commit

Permalink
perf(): reduce memory usage when navigating away from dashboard or no…
Browse files Browse the repository at this point in the history
…de list
  • Loading branch information
Benjamin Reed committed Apr 19, 2016
1 parent 921d17f commit 2f61b4c
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/app/dashboard/DashboardController.js
Original file line number Diff line number Diff line change
Expand Up @@ -352,8 +352,8 @@
});

$scope.resetData = function() {
$log.debug('Resetting Data.');
$scope.server = null;
$log.debug('DashboardCtrl.resetData()');
//$scope.server = null;
resetAvailability();
resetOutages();
resetAlarms();
Expand Down Expand Up @@ -491,9 +491,14 @@

document.addEventListener('resume', $scope.refreshData, false);

var lazyReset;
$scope.$on('$ionicView.beforeEnter', function(ev, info) {
$timeout.cancel(lazyReset);
$scope.refreshData();
});
$scope.$on('$ionicView.afterLeave', function(ev) {
lazyReset = $timeout($scope.resetData, 10000);
});
});

}());
8 changes: 8 additions & 0 deletions src/app/nodes/NodesController.js
Original file line number Diff line number Diff line change
Expand Up @@ -120,9 +120,17 @@

util.onSettingsUpdated($scope.delayedSearch);

var lazyReset;
$scope.$on('ionicView.beforeEnter', function() {
$timeout.cancel(lazyReset);
$scope.delayedSearch();
});
$scope.$on('ionicView.afterLeave', function() {
lazyReset = $timeout(function() {
$scope.searching = false;
$scope.nodes = [];
}, 10000);
});
});

}());

0 comments on commit 2f61b4c

Please sign in to comment.