]> git.wh0rd.org Git - tt-rss.git/commitdiff
offline: sync marked/unread status
authorAndrew Dolgov <fox@bah.org.ru>
Tue, 17 Feb 2009 09:22:31 +0000 (12:22 +0300)
committerAndrew Dolgov <fox@bah.org.ru>
Tue, 17 Feb 2009 09:22:31 +0000 (12:22 +0300)
modules/backend-rpc.php
offline.js

index e3d9e61659373d99a04cc01034cc024521729e77..d7700d66a3b1c84de57b940e9a344c084dd3a0a6 100644 (file)
                                                        $unread = bool_to_sql_bool((bool) $e[1]);
                                                        $marked = bool_to_sql_bool((bool) $e[2]);
 
-                                                       /* Marked status is not synchronized yet */
-
                                                        $query = "UPDATE ttrss_user_entries SET 
                                                                unread = $unread, 
                                                                last_read = '$last_online' 
 
                                                        $result = db_query($link, $query);
 
-//                                                     if (db_affected_rows($result) > 0) {
-                                                               print "<sync-ok id=\"$id\"/>";
-//                                                     }
+                                                       if ($marked) {
+                                                               $query = "UPDATE ttrss_user_entries SET 
+                                                                       marked = $marked, 
+                                                                       last_read = '$last_online' 
+                                                               WHERE ref_id = '$id' AND 
+                                                                       (last_read IS NULL OR last_read < '$last_online') AND
+                                                                       owner_uid = ".$_SESSION["uid"];
+
+                                                               $result = db_query($link, $query);
+                                                       }
+
+                                                       print "<sync-ok id=\"$id\"/>";
 
                                                }
                                        }
 
                                        /* Maybe we need to further update local DB for this client */
 
-                                       $query = "SELECT ref_id,unread FROM ttrss_user_entries
+                                       $query = "SELECT ref_id,unread,marked FROM ttrss_user_entries
                                                WHERE last_read >= '$last_online' AND
                                                                owner_uid = ".$_SESSION["uid"] . " LIMIT 1000";
 
                                        $result = db_query($link, $query);
 
                                        while ($line = db_fetch_assoc($result)) {
-                                               print "<sync-ok id=\"".$line["ref_id"]."\"/>";
+                                               $unread = (int) sql_bool_to_bool($line["unread"]);
+                                               $marked = (int) sql_bool_to_bool($line["marked"]);
+
+                                               print "<sync-ok unread=\"$unread\" marked=\"$marked\" 
+                                                       id=\"".$line["ref_id"]."\"/>";
                                        }
 
                                }
index 2a4466797f43513705d65a6e5d53d79504828868..9054ea455cc0c1b848ff1ea54a65b1818724b351 100644 (file)
@@ -658,8 +658,17 @@ function offline_download_parse(stage, transport) {
                        if (sync_ok.length > 0) {
                                for (var i = 0; i < sync_ok.length; i++) {
                                        var id = sync_ok[i].getAttribute("id");
+                                       var unread = sync_ok[i].getAttribute("unread");
+                                       var marked = sync_ok[i].getAttribute("marked");
+
                                        if (id) {
                                                debug("synced offline info for id " + id);
+
+                                               if (unread != undefined && marked != undefined) {
+                                                       db.execute("UPDATE articles SET "+
+                                                               "unread = ?, marked = ? WHERE id = ?", [unread, marked, id]);
+
+                                               }
                                                db.execute("UPDATE articles SET modified = '' WHERE id = ?", [id]);
                                        }
                                }