diff --git a/public/js/stores/ArchivedToggleStore.js b/public/js/stores/ArchivedToggleStore.js index 8c7265f591..15b8dea8f7 100644 --- a/public/js/stores/ArchivedToggleStore.js +++ b/public/js/stores/ArchivedToggleStore.js @@ -1,5 +1,6 @@ var Reflux = require('reflux'); var FeatureActions = require('./FeatureToggleActions'); +var ErrorActions = require('./ErrorActions'); var Timer = require('../utils/Timer'); var Server = require('./FeatureToggleServerFacade'); var filter = require('lodash/collection/filter'); @@ -9,47 +10,53 @@ var _archivedToggles = []; // Creates a DataStore var FeatureStore = Reflux.createStore({ - //The store should be split in two: toggleStore && archivedToggleStore! - // Initial setup - init: function() { - this.listenTo(FeatureActions.archive.completed, this.onArchive); - this.listenTo(FeatureActions.revive.completed, this.onRevive); + // Initial setup + init: function() { + this.listenTo(FeatureActions.archive.completed, this.onArchive); + this.listenTo(FeatureActions.revive.completed, this.onRevive); - this.timer = new Timer(this.loadDataFromServer, 30*1000); - this.timer.start(); - }, + this.timer = new Timer(this.loadDataFromServer, 30*1000); + this.timer.start(); + }, - loadDataFromServer: function() { - //TODO: this should not be part of the store! - Server.getArchivedFeatures(function(err, archivedToggles) { - _archivedToggles = archivedToggles; - this.trigger(); - }.bind(this)); - }, + loadDataFromServer: function() { + //TODO: this should not be part of the store! + Server.getArchivedFeatures(function(err, archivedToggles) { - onArchive: function(feature) { - var toggles = _archivedToggles.concat([feature]); - _archivedToggles = sortBy(toggles, 'name'); - this.trigger(); - }, + if(err) { + ErrorActions.error(err); + return; + } else { + _archivedToggles = archivedToggles; + this.trigger(_archivedToggles); + } - onRevive: function(item) { - var newStore = filter(_archivedToggles, function(f) { - return f.name !== item.name; - }); + }.bind(this)); + }, - _archivedToggles = sortBy(newStore, 'name'); - this.trigger(); - }, + onArchive: function(feature) { + var toggles = _archivedToggles.concat([feature]); + _archivedToggles = sortBy(toggles, 'name'); + this.trigger(); + }, - getArchivedToggles: function() { - return _archivedToggles; - }, + onRevive: function(item) { + var newStore = filter(_archivedToggles, function(f) { + return f.name !== item.name; + }); - initStore: function(archivedToggles) { - _archivedToggles = archivedToggles; - } + _archivedToggles = sortBy(newStore, 'name'); + this.trigger(); + }, + + getArchivedToggles: function() { + return _archivedToggles; + }, + + initStore: function(archivedToggles) { + _archivedToggles = archivedToggles; + } }); module.exports = FeatureStore; diff --git a/public/js/stores/FeatureToggleStore.js b/public/js/stores/FeatureToggleStore.js index 2554b81d14..672b94017d 100644 --- a/public/js/stores/FeatureToggleStore.js +++ b/public/js/stores/FeatureToggleStore.js @@ -1,5 +1,6 @@ var Reflux = require('reflux'); var FeatureActions = require('./FeatureToggleActions'); +var ErrorActions = require('./ErrorActions'); var Server = require('./FeatureToggleServerFacade'); var Timer = require('../utils/Timer'); var filter = require('lodash/collection/filter'); @@ -20,7 +21,7 @@ var FeatureStore = Reflux.createStore({ this.listenTo(FeatureActions.revive.completed, this.onRevive); //TODO: this should not be part of the store! - this.timer = new Timer(this.loadDataFromServer, 3*1000); + this.timer = new Timer(this.loadDataFromServer, 30*1000); this.timer.start(); }, @@ -28,6 +29,7 @@ var FeatureStore = Reflux.createStore({ //TODO: this should not be part of the store! Server.getFeatures(function(err, featureToggles) { if(err) { + ErrorActions.error(err); return; } else { this.setToggles(featureToggles);