From e9618aac5cc578b4b9ddc5102f65bf0abf0152d8 Mon Sep 17 00:00:00 2001 From: cubedro Date: Tue, 28 Apr 2015 12:01:34 +0300 Subject: [PATCH] fixed front-end stats undefined bug --- public/js/controllers.js | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/public/js/controllers.js b/public/js/controllers.js index 32e37f8..2d9eae3 100644 --- a/public/js/controllers.js +++ b/public/js/controllers.js @@ -124,9 +124,12 @@ function StatsCtrl($scope, $filter, socket, _, toastr) { data.stats.hashrate = 0; var index = findIndex({id: data.id}); - $scope.nodes[index].stats = data.stats; - $scope.nodes[index].history = data.history; - makePeerPropagationChart($scope.nodes[index]); + + if(typeof $scope.nodes[index].stats !== 'undefined') { + $scope.nodes[index].stats = data.stats; + $scope.nodes[index].history = data.history; + makePeerPropagationChart($scope.nodes[index]); + } break; @@ -174,7 +177,10 @@ function StatsCtrl($scope, $filter, socket, _, toastr) { break; case "latency": - $scope.nodes[findIndex({id: data.id})].stats.latency = data.latency; + var node = $scope.nodes[findIndex({id: data.id})]; + + if(typeof node.stats !== 'undefined' && typeof node.stats.latency !== 'undefined') + $scope.nodes[findIndex({id: data.id})].stats.latency = data.latency; break;