Merge pull request #106 from cubedro/develop

fixed canUpdate bug
This commit is contained in:
Marian OANCΞA 2015-04-28 11:13:08 +03:00
commit cd99ff8c18
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;