$force_update = sql_bool_to_bool($_REQUEST["force_update"]);
$has_sandbox = sql_bool_to_bool($_REQUEST["has_sandbox"]);
$excerpt_length = (int)$this->dbh->escape_string($_REQUEST["excerpt_length"]);
- $check_top_id = (int)$this->dbh->escape_string($_REQUEST["check_top_id"]);
+ $check_first_id = (int)$this->dbh->escape_string($_REQUEST["check_first_id"]);
$include_header = sql_bool_to_bool($_REQUEST["include_header"]);
$_SESSION['hasSandbox'] = $has_sandbox;
list($headlines, $headlines_header) = $this->api_get_headlines($feed_id, $limit, $offset,
$filter, $is_cat, $show_excerpt, $show_content, $view_mode, $override_order,
$include_attachments, $since_id, $search,
- $include_nested, $sanitize_content, $force_update, $excerpt_length, $check_top_id);
+ $include_nested, $sanitize_content, $force_update, $excerpt_length, $check_first_id);
if ($include_header) {
$this->wrap(self::STATUS_OK, array($headlines_header, $headlines));
$filter, $is_cat, $show_excerpt, $show_content, $view_mode, $order,
$include_attachments, $since_id,
$search = "", $include_nested = false, $sanitize_content = true,
- $force_update = false, $excerpt_length = 100, $check_top_id = false) {
+ $force_update = false, $excerpt_length = 100, $check_first_id = false) {
if ($force_update && $feed_id > 0 && is_numeric($feed_id)) {
// Update the feed if required with some basic flood control
"offset" => $offset,
"since_id" => $since_id,
"include_children" => $include_nested,
- "check_top_id" => $check_top_id
+ "check_first_id" => $check_first_id
);
$qfh_ret = queryFeedHeadlines($params);
$result = $qfh_ret[0];
$feed_title = $qfh_ret[1];
+ $first_id = $qfh_ret[6];
$headlines = array();
$headlines_header = array(
'id' => $feed_id,
+ 'first_id' => $first_id,
'is_cat' => $is_cat);
if (!is_numeric($result)) {
array_push($headlines, $headline_row);
}
} else if (is_numeric($result) && $result == -1) {
- $headlines_header['top_id_changed'] = true;
+ $headlines_header['first_id_changed'] = true;
}
return array($headlines, $headlines_header);
private function format_headlines_list($feed, $method, $view_mode, $limit, $cat_view,
$next_unread_feed, $offset, $vgr_last_feed = false,
- $override_order = false, $include_children = false, $check_top_id = false) {
+ $override_order = false, $include_children = false, $check_first_id = false) {
$disable_cache = false;
"override_order" => $override_order,
"offset" => $offset,
"include_children" => $include_children,
- "check_top_id" => $check_top_id
+ "check_first_id" => $check_first_id
);
$qfh_ret = queryFeedHeadlines($params);
$last_updated = strpos($qfh_ret[4], '1970-') === FALSE ?
make_local_datetime($qfh_ret[4], false) : __("Never");
$highlight_words = $qfh_ret[5];
+ $reply['first_id'] = $qfh_ret[6];
$vgroup_last_feed = $vgr_last_feed;
}
} else if (is_numeric($result) && $result == -1) {
$reply['content'] = '';
- $reply['top_id_changed'] = true;
+ $reply['first_id_changed'] = true;
}
if ($_REQUEST["debug"]) $timing_info = print_checkpoint("H2", $timing_info);
@$offset = $this->dbh->escape_string($_REQUEST["skip"]);
@$vgroup_last_feed = $this->dbh->escape_string($_REQUEST["vgrlf"]);
$order_by = $this->dbh->escape_string($_REQUEST["order_by"]);
- $check_top_id = $this->dbh->escape_string($_REQUEST["topid"]);
+ $check_first_id = $this->dbh->escape_string($_REQUEST["fid"]);
if (is_numeric($feed)) $feed = (int) $feed;
$ret = $this->format_headlines_list($feed, $method,
$view_mode, $limit, $cat_view, $next_unread_feed, $offset,
- $vgroup_last_feed, $override_order, true, $check_top_id);
+ $vgroup_last_feed, $override_order, true, $check_first_id);
//$topmost_article_ids = $ret[0];
$headlines_count = $ret[1];
$override_strategy = isset($params["override_strategy"]) ? $params["override_strategy"] : false;
$override_vfeed = isset($params["override_vfeed"]) ? $params["override_vfeed"] : false;
$start_ts = isset($params["start_ts"]) ? $params["start_ts"] : false;
- $check_top_id = isset($params["check_top_id"]) ? $params["check_top_id"] : false;
+ $check_first_id = isset($params["check_first_id"]) ? $params["check_first_id"] : false;
$ext_tables_part = "";
$query_strategy_part = "";
$start_ts_query_part = "";
}
-
+ $first_id = false;
// if previous topmost article id changed that means our current pagination is no longer valid
- if ($check_top_id) {
- $query = "SELECT DISTINCT
- date_entered,
- guid,
- ttrss_entries.id,
- ttrss_entries.title,
- updated,
- score
- FROM
- $from_qpart
- WHERE
- $feed_check_qpart
- ttrss_user_entries.ref_id = ttrss_entries.id AND
- ttrss_user_entries.owner_uid = '$owner_uid' AND
- $search_query_part
- $start_ts_query_part
- $filter_query_part
- $view_query_part
- $since_id_part
- $query_strategy_part ORDER BY $order_by LIMIT 1";
+ $query = "SELECT DISTINCT
+ date_entered,
+ guid,
+ ttrss_entries.id,
+ ttrss_entries.title,
+ updated,
+ score
+ FROM
+ $from_qpart
+ WHERE
+ $feed_check_qpart
+ ttrss_user_entries.ref_id = ttrss_entries.id AND
+ ttrss_user_entries.owner_uid = '$owner_uid' AND
+ $search_query_part
+ $start_ts_query_part
+ $filter_query_part
+ $since_id_part
+ $query_strategy_part ORDER BY $order_by LIMIT 1";
if ($_REQUEST["debug"]) {
print $query;
$result = db_query($query);
if ($result) {
- $current_top_id = db_fetch_result($result, 0, "id");
+ $first_id = (int) db_fetch_result($result, 0, "id");
- if ($current_top_id != $check_top_id) {
- // top changed, bail out
-
- return array(-1, $feed_title, $feed_site_url, $last_error, $last_updated, $search_words);
+ if ($offset > 0 && $check_first_id && $first_id != $check_first_id) {
+ return array(-1, $feed_title, $feed_site_url, $last_error, $last_updated, $search_words, $first_id);
}
}
- }
$query = "SELECT DISTINCT
date_entered,
$result = db_query($query);
}
- return array($result, $feed_title, $feed_site_url, $last_error, $last_updated, $search_words);
+ return array($result, $feed_title, $feed_site_url, $last_error, $last_updated, $search_words, $first_id);
}
}
if (offset > 0) {
- var firstRow = $$('div[id*="RROW-"]').first();
-
- if (firstRow) {
- query = query + "&topid=" + param_escape(parseInt(firstRow.id.replace("RROW-", "")));
+ if (current_first_id) {
+ query = query + "&fid=" + param_escape(current_first_id);
}
}
var cids_requested = [];
var loaded_article_ids = [];
var _last_headlines_update = 0;
+var current_first_id = 0;
var has_storage = 'sessionStorage' in window && window['sessionStorage'] !== null;
_infscroll_disable = 0;
}
+ current_first_id = reply['headlines']['first_id'];
var counters = reply['counters'];
var articles = reply['articles'];
//var runtime_info = reply['runtime-info'];
} else {
console.log("no new headlines received");
- var top_id_changed = reply['headlines']['top_id_changed'];
- console.log("top id changed:" + top_id_changed);
+ var first_id_changed = reply['headlines']['first_id_changed'];
+ console.log("first id changed:" + first_id_changed);
var hsp = $("headlines-spacer");
if (hsp) {
- if (top_id_changed) {
+ if (first_id_changed) {
hsp.innerHTML = "<a href='#' onclick='viewCurrentFeed()'>" +
__("New articles found, reload feed to continue.") + "</a>";
} else {