From: Andrew Dolgov Date: Tue, 17 Feb 2009 09:22:31 +0000 (+0300) Subject: offline: sync marked/unread status X-Git-Tag: 1.3.1~6 X-Git-Url: https://git.wh0rd.org/?a=commitdiff_plain;h=492a4a6ac8c63239ecf67fda0acfc2afca9df457;p=tt-rss.git offline: sync marked/unread status --- diff --git a/modules/backend-rpc.php b/modules/backend-rpc.php index e3d9e616..d7700d66 100644 --- a/modules/backend-rpc.php +++ b/modules/backend-rpc.php @@ -547,8 +547,6 @@ $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' @@ -558,23 +556,36 @@ $result = db_query($link, $query); -// if (db_affected_rows($result) > 0) { - print ""; -// } + 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 ""; } } /* 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 ""; + $unread = (int) sql_bool_to_bool($line["unread"]); + $marked = (int) sql_bool_to_bool($line["marked"]); + + print ""; } } diff --git a/offline.js b/offline.js index 2a446679..9054ea45 100644 --- a/offline.js +++ b/offline.js @@ -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]); } }