diff --git a/feedlist.js b/feedlist.js index 8f1b5efec..e148337c7 100644 --- a/feedlist.js +++ b/feedlist.js @@ -30,13 +30,25 @@ function viewCategory(cat) { return false; } +function render_feedlist(data) { + try { + + var f = document.getElementById("feeds-frame"); + f.innerHTML = data; + cache_invalidate("FEEDLIST"); + cache_inject("FEEDLIST", data); + feedlist_init(); + + } catch (e) { + exception_error("render_feedlist", e); + } +} + function feedlist_callback2(transport) { try { debug("feedlist_callback2"); if (!transport_error_check(transport)) return; - var f = document.getElementById("feeds-frame"); - f.innerHTML = transport.responseText; - feedlist_init(); + render_feedlist(transport.responseText); } catch (e) { exception_error("feedlist_callback2", e); } @@ -257,6 +269,7 @@ function viewfeed(feed, subop, is_cat, subop_param, skip_history, offset) { f.innerHTML = cache_find_param(cache_prefix + feed, unread_ctr); request_counters(); + remove_splash(); } else { diff --git a/tt-rss.js b/tt-rss.js index d49eaa6be..c3c21cc20 100644 --- a/tt-rss.js +++ b/tt-rss.js @@ -510,7 +510,14 @@ function init_second_stage() { daemon_refresh_only = getInitParam("daemon_refresh_only") == 1; feeds_sort_by_unread = getInitParam("feeds_sort_by_unread") == 1; - setTimeout('updateFeedList(false, false)', 50); + var fl = cache_find("FEEDLIST"); + + if (fl) { + render_feedlist(fl); + request_counters(); + } else { + setTimeout('updateFeedList(false, false)', 50); + } debug("second stage ok"); @@ -1472,6 +1479,8 @@ function init_gears() { db.execute("CREATE TABLE IF NOT EXISTS cache (id text, article text, param text, added text)"); } + + cache_expire(); } catch (e) { exception_error("init_gears", e); diff --git a/viewfeed.js b/viewfeed.js index 615f366f3..6f018d19c 100644 --- a/viewfeed.js +++ b/viewfeed.js @@ -1500,6 +1500,11 @@ function cache_inject(id, article, param) { function cache_find(id) { if (db) { + var rs = db.execute("SELECT article FROM cache WHERE id = ?", [id]); + + if (rs.isValidRow()) { + return rs.field(0); + } } else { for (var i = 0; i < article_cache.length; i++) { @@ -1572,7 +1577,13 @@ function cache_check_param(id, param) { } function cache_expire() { - if (!db) { + if (db) { + var date = new Date(); + var ts = Math.round(date.getTime() / 1000); + + db.execute("DELETE FROM cache WHERE added < ? - 600", [ts]); + + } else { while (article_cache.length > 25) { article_cache.shift(); }