fixed #6 handling of invalid data
This commit is contained in:
parent
284a0ebebe
commit
17c100ecb3
1 changed files with 10 additions and 1 deletions
11
js/App.js
11
js/App.js
|
@ -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 = "";
|
||||||
|
|
Reference in a new issue