fixed #6 handling of invalid data

This commit is contained in:
jeena 2013-09-05 10:49:21 +02:00
parent 284a0ebebe
commit 17c100ecb3

View file

@ -127,7 +127,7 @@ App.prototype.reload = function() {
App.prototype.gotUnreadFeeds = function(new_articles) { 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; var old_articles = localStorage.unread_articles;
if(old_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() { App.prototype.populateList = function() {
var html_str = ""; var html_str = "";