filter by search results while marking feed as read

This commit is contained in:
Andrew Dolgov 2017-03-31 11:21:35 +03:00
parent 86e534290e
commit 337535416f
5 changed files with 127 additions and 120 deletions

View file

@ -300,6 +300,7 @@ class Feeds extends Handler_Protected {
make_local_datetime($qfh_ret[4], false) : __("Never");
$highlight_words = $qfh_ret[5];
$reply['first_id'] = $qfh_ret[6];
$reply['search_query'] = [$search, $search_language];
$vgroup_last_feed = $vgr_last_feed;

View file

@ -450,8 +450,10 @@ class RPC extends Handler_Protected {
$feed_id = $this->dbh->escape_string($_REQUEST['feed_id']);
$is_cat = $this->dbh->escape_string($_REQUEST['is_cat']) == "true";
$mode = $this->dbh->escape_string($_REQUEST['mode']);
$search_query = $this->dbh->escape_string($_REQUEST['search_query']);
$search_lang = $this->dbh->escape_string($_REQUEST['search_lang']);
catchup_feed($feed_id, $is_cat, false, false, $mode);
catchup_feed($feed_id, $is_cat, false, false, $mode, [$search_query, $search_lang]);
print json_encode(array("message" => "UPDATE_COUNTERS"));
}

View file

@ -1163,15 +1163,14 @@
}
}
function catchup_feed($feed, $cat_view, $owner_uid = false, $max_id = false, $mode = 'all') {
function catchup_feed($feed, $cat_view, $owner_uid = false, $max_id = false, $mode = 'all', $search = false) {
if (!$owner_uid) $owner_uid = $_SESSION['uid'];
//if (preg_match("/^-?[0-9][0-9]*$/", $feed) != false) {
// Todo: all this interval stuff needs some generic generator function
$date_qpart = "false";
$search_qpart = is_array($search) && $search[0] ? search_to_sql($search[0], $search[1])[0] : 'true';
switch ($mode) {
case "1day":
@ -1220,13 +1219,13 @@
(SELECT id FROM
(SELECT DISTINCT id FROM ttrss_entries, ttrss_user_entries WHERE ref_id = id
AND owner_uid = $owner_uid AND unread = true AND feed_id IN
(SELECT id FROM ttrss_feeds WHERE $cat_qpart) AND $date_qpart) as tmp)");
(SELECT id FROM ttrss_feeds WHERE $cat_qpart) AND $date_qpart AND $search_qpart) as tmp)");
} else if ($feed == -2) {
db_query("UPDATE ttrss_user_entries
SET unread = false,last_read = NOW() WHERE (SELECT COUNT(*)
FROM ttrss_user_labels2, ttrss_entries WHERE article_id = ref_id AND id = ref_id AND $date_qpart) > 0
FROM ttrss_user_labels2, ttrss_entries WHERE article_id = ref_id AND id = ref_id AND $date_qpart AND $search_qpart) > 0
AND unread = true AND owner_uid = $owner_uid");
}
@ -1236,7 +1235,7 @@
SET unread = false, last_read = NOW() WHERE ref_id IN
(SELECT id FROM
(SELECT DISTINCT id FROM ttrss_entries, ttrss_user_entries WHERE ref_id = id
AND owner_uid = $owner_uid AND unread = true AND feed_id = $feed AND $date_qpart) as tmp)");
AND owner_uid = $owner_uid AND unread = true AND feed_id = $feed AND $date_qpart AND $search_qpart) as tmp)");
} else if ($feed < 0 && $feed > LABEL_BASE_INDEX) { // special, like starred
@ -1245,7 +1244,7 @@
SET unread = false, last_read = NOW() WHERE ref_id IN
(SELECT id FROM
(SELECT DISTINCT id FROM ttrss_entries, ttrss_user_entries WHERE ref_id = id
AND owner_uid = $owner_uid AND unread = true AND marked = true AND $date_qpart) as tmp)");
AND owner_uid = $owner_uid AND unread = true AND marked = true AND $date_qpart AND $search_qpart) as tmp)");
}
if ($feed == -2) {
@ -1253,7 +1252,7 @@
SET unread = false, last_read = NOW() WHERE ref_id IN
(SELECT id FROM
(SELECT DISTINCT id FROM ttrss_entries, ttrss_user_entries WHERE ref_id = id
AND owner_uid = $owner_uid AND unread = true AND published = true AND $date_qpart) as tmp)");
AND owner_uid = $owner_uid AND unread = true AND published = true AND $date_qpart AND $search_qpart) as tmp)");
}
if ($feed == -3) {
@ -1271,7 +1270,7 @@
SET unread = false, last_read = NOW() WHERE ref_id IN
(SELECT id FROM
(SELECT DISTINCT id FROM ttrss_entries, ttrss_user_entries WHERE ref_id = id
AND owner_uid = $owner_uid AND score >= 0 AND unread = true AND $date_qpart AND $match_part) as tmp)");
AND owner_uid = $owner_uid AND score >= 0 AND unread = true AND $date_qpart AND $match_part AND $search_qpart) as tmp)");
}
if ($feed == -4) {
@ -1279,7 +1278,7 @@
SET unread = false, last_read = NOW() WHERE ref_id IN
(SELECT id FROM
(SELECT DISTINCT id FROM ttrss_entries, ttrss_user_entries WHERE ref_id = id
AND owner_uid = $owner_uid AND unread = true AND $date_qpart) as tmp)");
AND owner_uid = $owner_uid AND unread = true AND $date_qpart AND $search_qpart) as tmp)");
}
} else if ($feed < LABEL_BASE_INDEX) { // label
@ -1291,7 +1290,7 @@
(SELECT id FROM
(SELECT DISTINCT ttrss_entries.id FROM ttrss_entries, ttrss_user_entries, ttrss_user_labels2 WHERE ref_id = id
AND label_id = '$label_id' AND ref_id = article_id
AND owner_uid = $owner_uid AND unread = true AND $date_qpart) as tmp)");
AND owner_uid = $owner_uid AND unread = true AND $date_qpart AND $search_qpart) as tmp)");
}
@ -1303,7 +1302,7 @@
(SELECT id FROM
(SELECT DISTINCT ttrss_entries.id FROM ttrss_entries, ttrss_user_entries, ttrss_tags WHERE ref_id = ttrss_entries.id
AND post_int_id = int_id AND tag_name = '$feed'
AND ttrss_user_entries.owner_uid = $owner_uid AND unread = true AND $date_qpart) as tmp)");
AND ttrss_user_entries.owner_uid = $owner_uid AND unread = true AND $date_qpart AND $search_qpart) as tmp)");
}
}

View file

@ -484,28 +484,31 @@ function catchupFeed(feed, is_cat, mode) {
switch (mode) {
case "1day":
str = __("Mark all articles in %s older than 1 day as read?");
str = __("Mark %w in %s older than 1 day as read?");
break;
case "1week":
str = __("Mark all articles in %s older than 1 week as read?");
str = __("Mark %w in %s older than 1 week as read?");
break;
case "2week":
str = __("Mark all articles in %s older than 2 weeks as read?");
str = __("Mark %w in %s older than 2 weeks as read?");
break;
default:
str = __("Mark all articles in %s as read?");
str = __("Mark %w in %s as read?");
}
var mark_what = last_search_query && last_search_query[0] ? __("search results") : __("all articles");
var fn = getFeedName(feed, is_cat);
str = str.replace("%s", fn);
str = str.replace("%s", fn)
.replace("%w", mark_what);
if (getInitParam("confirm_feed_catchup") == 1 && !confirm(str)) {
return;
}
var catchup_query = "?op=rpc&method=catchupFeed&feed_id=" +
feed + "&is_cat=" + is_cat + "&mode=" + mode;
var catchup_query = {op: 'rpc', method: 'catchupFeed', feed_id: feed,
is_cat: is_cat, mode: mode, search_query: last_search_query[0],
search_lang: last_search_query[1]};
console.log(catchup_query);

View file

@ -13,6 +13,7 @@ var loaded_article_ids = [];
var _last_headlines_update = 0;
var _headlines_scroll_offset = 0;
var current_first_id = 0;
var last_search_query;
var _catchup_request_sent = false;
@ -38,6 +39,7 @@ function headlines_callback2(transport, offset, background, infscroll_req) {
is_cat = reply['headlines']['is_cat'];
feed_id = reply['headlines']['id'];
last_search_query = reply['headlines']['search_query'];
if (background) {
var content = reply['headlines']['content'];