]> git.wh0rd.org Git - tt-rss.git/commitdiff
offline: store category collapsed state
authorAndrew Dolgov <fox@bah.org.ru>
Thu, 5 Feb 2009 19:29:34 +0000 (22:29 +0300)
committerAndrew Dolgov <fox@bah.org.ru>
Thu, 5 Feb 2009 19:29:34 +0000 (22:29 +0300)
modules/backend-rpc.php
offline.js

index edc167695c51367d3ef804a4fc205acde40fbe78..8905012f6654f62cdf66e45a5efdda013b5558f1 100644 (file)
 
                                print "<feed-categories>";
 
-                               $result = db_query($link, "SELECT id, title FROM
+                               $result = db_query($link, "SELECT id, title, collapsed FROM
                                        ttrss_feed_categories WHERE owner_uid = ".$_SESSION["uid"]);
 
-                                       print "<category id=\"0\"><![CDATA[";
+                                       print "<category id=\"0\" collapsed=\"".
+                                               (int)$_COOKIE["ttrss_vf_uclps"]."\"><![CDATA[";
                                        print __("Uncategorized");
                                        print "]]></category>";
 
                                while ($line = db_fetch_assoc($result)) {
-                                       print "<category id=\"".$line["id"]."\"><![CDATA[";
+                                       print "<category 
+                                               id=\"".$line["id"]."\"
+                                               collapsed=\"".(int)sql_bool_to_bool($line["collapsed"])."\"><![CDATA[";
                                        print $line["title"];
                                        print "]]></category>";
                                }
index ff65a76d9e1a24b349e2c9688155ae1205639f1c..fd3e7ef77c87343e2fec2a35a98a12df8d659e9a 100644 (file)
@@ -1,4 +1,4 @@
-var SCHEMA_VERSION = 4;
+var SCHEMA_VERSION = 5;
 
 var offline_mode = false;
 var store = false;
@@ -546,10 +546,26 @@ function offline_download_parse(stage, transport) {
                                        var cat_id = feeds[i].getAttribute("cat_id");
 
                                        db.execute("INSERT INTO feeds (id,title,has_icon,cat_id)"+
-                                               "VALUES (?,?,?, ?)",
+                                               "VALUES (?,?,?,?)",
                                                [id, title, has_icon, cat_id]);
                                }
-               
+
+                               var cats = transport.responseXML.getElementsByTagName("category");
+
+                               if (feeds.length > 0) {
+                                       db.execute("DELETE FROM categories");
+                               }
+
+                               for (var i = 0; i < cats.length; i++) {
+                                       var id = cats[i].getAttribute("id");
+                                       var collapsed = cats[i].getAttribute("collapsed");
+                                       var title = cats[i].firstChild.nodeValue;
+
+                                       db.execute("INSERT INTO categories (id,title,collapsed)"+
+                                               "VALUES (?,?,?)",
+                                               [id, title, collapsed]);
+                               }
+
                                window.setTimeout("update_offline_data("+(stage+1)+")", 10*1000);
                        } else {
 
@@ -790,7 +806,7 @@ function init_gears() {
 
                        db.execute("CREATE TABLE IF NOT EXISTS cache (id text, article text, param text, added text)");
                        db.execute("CREATE TABLE IF NOT EXISTS feeds (id integer, title text, has_icon integer, cat_id integer)");
-                       db.execute("CREATE TABLE IF NOT EXISTS categories (id integer, title text)");
+                       db.execute("CREATE TABLE IF NOT EXISTS categories (id integer, title text, collapsed integer)");
                        db.execute("CREATE TABLE IF NOT EXISTS articles (id integer, feed_id integer, title text, link text, guid text, updated text, content text, tags text, unread text, marked text, added text, comments text)");
 
                        db.execute("DELETE FROM cache WHERE id LIKE 'F:%' OR id LIKE 'C:%'");