offline: sync marked/unread status
This commit is contained in:
parent
65c0779b77
commit
492a4a6ac8
|
@ -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 "<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"]."\"/>";
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -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]);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue