fixed canUpdate bug

This commit is contained in:
cubedro 2015-04-28 11:12:47 +03:00
parent a6077c1d92
commit 13680815f1
2 changed files with 10 additions and 2 deletions

4
app.js
View File

@ -63,7 +63,7 @@ api.on('connection', function(spark) {
var info = Nodes.add(data);
spark.emit('ready');
if(Nodes.getHistory().requiresUpdate() && !askedForHistory && Nodes.getNode({id: data.id}).canUpdate())
if(Nodes.getHistory().requiresUpdate() && !askedForHistory && Nodes.canNodeUpdate(data.id))
{
spark.emit('history', Nodes.getHistory().getHistoryRequestInterval());
askedForHistory = true;
@ -87,7 +87,7 @@ api.on('connection', function(spark) {
client.write({action: 'charts', data: Nodes.getCharts()});
}
if(Nodes.getHistory().requiresUpdate() && !askedForHistory && Nodes.getNode({id: data.id}).canUpdate())
if(Nodes.getHistory().requiresUpdate() && !askedForHistory && Nodes.canNodeUpdate(data.id))
{
spark.emit('history', Nodes.getHistory().getHistoryRequestInterval());
askedForHistory = true;

View File

@ -136,4 +136,12 @@ Collection.prototype.getHistory = function()
return this._history;
}
Collection.prototype.canNodeUpdate = function(id)
{
var node = this.getNode({id: id});
if(!node)
return false;
return node.canUpdate();
}
module.exports = Collection;