diff --git a/js/App.js b/js/App.js index 325f507..2b13017 100644 --- a/js/App.js +++ b/js/App.js @@ -154,6 +154,8 @@ App.prototype.gotUnreadFeeds = function(new_articles) { App.prototype.validate = function(articles) { + if(articles.length == 0) return true; + for (var i = 0; i < articles.length; i++) { if(typeof articles[i].title != "undefined") return true; } @@ -288,12 +290,10 @@ App.prototype.showPrevious = function() { App.prototype.setCurrentRead = function() { var article = this.unread_articles[this.currentIndex]; if(!article) return; // happens if we're not on a full article site - if(!article.set_unread) { article.unread = false; this.updateList(); - var _this = this; - setTimeout(function() { _this.ttrss.setArticleRead(article.id); }, 100); + this.ttrss.setArticleRead(article.id); } article.set_unread = false; @@ -307,7 +307,7 @@ App.prototype.setCurrentUnread = function() { article.set_unread = true; this.updateList(); var _this = this; - setTimeout(function() { _this.ttrss.setArticleUnread(article.id); }, 100); + this.ttrss.setArticleUnread(article.id); $("#setunread").innerHTML = "✔ unread"; }; diff --git a/js/TinyTinyRSS.js b/js/TinyTinyRSS.js index 79e1586..4b877d3 100644 --- a/js/TinyTinyRSS.js +++ b/js/TinyTinyRSS.js @@ -52,10 +52,8 @@ TinyTinyRSS.prototype.doOperation = function(operation, new_options, callback) { if(callback) callback(JSON.parse(xhr.responseText).content); } else { - if(xhr.status != 0) - alert("error: " + xhr.status + " " + xhr.statusText); - if(callback) - callback(null); + if(xhr.status != 0) alert("error: " + xhr.status + " " + xhr.statusText); + if(callback) callback(null); } } } @@ -82,8 +80,9 @@ TinyTinyRSS.prototype.setArticleRead = function(article_id) { field: 2 }; - if (navigator.onLine) this.doOperation("updateArticle", options); - else { + if (navigator.onLine) { + this.doOperation("updateArticle", options); + } else { var read_articles = localStorage.read_articles; if(typeof read_articles !== "undefined") read_articles = JSON.parse(read_articles); else read_articles = [];