From 17c100ecb318b555a74bc9ae07569646d810a368 Mon Sep 17 00:00:00 2001 From: jeena Date: Thu, 5 Sep 2013 10:49:21 +0200 Subject: [PATCH] fixed #6 handling of invalid data --- js/App.js | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/js/App.js b/js/App.js index befe108..cb341fd 100644 --- a/js/App.js +++ b/js/App.js @@ -127,7 +127,7 @@ App.prototype.reload = function() { App.prototype.gotUnreadFeeds = function(new_articles) { - if(new_articles == null) { // on error load the saved unread articles. + if(new_articles == null || !this.validate(new_articles)) { // on error load the saved unread articles. var old_articles = localStorage.unread_articles; if(old_articles) { @@ -148,6 +148,15 @@ App.prototype.gotUnreadFeeds = function(new_articles) { } }; +App.prototype.validate = function(articles) { + + for (var i = 0; i < articles.length; i++) { + if(typeof articles[i].title != "undefined") return true; + } + + return false; +}; + App.prototype.populateList = function() { var html_str = "";