better feedlist reloading on subscribed feeds count change

This commit is contained in:
Andrew Dolgov 2010-11-23 13:03:36 +03:00
parent 4a529b592a
commit 8cd576a12a
4 changed files with 24 additions and 38 deletions

View File

@ -343,17 +343,6 @@ function parse_counters(reply, scheduled_call) {
hideOrShowFeeds(getInitParam("hide_read_feeds") == 1);
var feeds_stored = number_of_feeds;
if (feeds_stored != feeds_found) {
number_of_feeds = feeds_found;
if (feeds_stored != 0 && feeds_found != 0) {
console.log("Subscribed feed number changed, refreshing feedlist");
setTimeout('updateFeedList()', 50);
}
}
} catch (e) {
exception_error("parse_counters", e);
}

View File

@ -1129,7 +1129,8 @@ function unsubscribeFeed(feed_id, title) {
if (inPreferences()) {
updateFeedList();
} else {
dlg_frefresh_callback(transport, feed_id);
if (feed_id == getActiveFeedId())
setTimeout("viewfeed(-5)", 100);
}
} });
@ -1469,12 +1470,7 @@ function editFeed(feed, event) {
parameters: dojo.objectToQuery(dialog.attr('value')),
onComplete: function(transport) {
dialog.hide();
if (inPreferences()) {
updateFeedList();
} else {
notify('');
dlg_frefresh_callback(transport);
}
updateFeedList();
}})
}
},
@ -1540,8 +1536,6 @@ function feedBrowser() {
if (inPreferences()) {
updateFeedList();
} else {
setTimeout('updateFeedList(false, false)', 50);
}
} });

View File

@ -3143,12 +3143,15 @@
$params["bw_limit"] = (int) $_SESSION["bw_limit"];
$params["offline_enabled"] = (int) get_pref($link, "ENABLE_OFFLINE_READING");
$result = db_query($link, "SELECT COUNT(*) AS cf FROM
$result = db_query($link, "SELECT MAX(id) AS mid, COUNT(*) AS nf FROM
ttrss_feeds WHERE owner_uid = " . $_SESSION["uid"]);
$num_feeds = db_fetch_result($result, 0, "cf");
$max_feed_id = db_fetch_result($result, 0, "mid");
$num_feeds = db_fetch_result($result, 0, "nf");
$params["max_feed_id"] = (int) $max_feed_id;
$params["num_feeds"] = (int) $num_feeds;
$params["collapsed_feedlist"] = (int) get_pref($link, "_COLLAPSED_FEEDLIST");
return $params;
@ -3161,14 +3164,17 @@
}
function make_runtime_info($link) {
$result = db_query($link, "SELECT COUNT(*) AS cf FROM
ttrss_feeds WHERE owner_uid = " . $_SESSION["uid"]);
$num_feeds = db_fetch_result($result, 0, "cf");
$data = array();
$data['num_feeds'] = (int) $num_feeds;
$result = db_query($link, "SELECT MAX(id) AS mid, COUNT(*) AS nf FROM
ttrss_feeds WHERE owner_uid = " . $_SESSION["uid"]);
$max_feed_id = db_fetch_result($result, 0, "mid");
$num_feeds = db_fetch_result($result, 0, "nf");
$data["max_feed_id"] = (int) $max_feed_id;
$data["num_feeds"] = (int) $num_feeds;
$data['last_article_id'] = getLastArticleId($link);
$data['cdm_expanded'] = get_pref($link, 'CDM_EXPANDED');

View File

@ -3,7 +3,6 @@ var global_unread = -1;
var firsttime_update = true;
var _active_feed_id = 0;
var _active_feed_is_cat = false;
var number_of_feeds = 0;
var hotkey_prefix = false;
var hotkey_prefix_pressed = false;
var init_params = {};
@ -50,15 +49,6 @@ function setActiveFeedId(id, is_cat) {
}
function dlg_frefresh_callback(transport, deleted_feed) {
if (getActiveFeedId() == deleted_feed) {
setTimeout("viewfeed(-5)", 100);
}
setTimeout('updateFeedList()', 50);
closeInfoBox();
}
function updateFeedList() {
try {
@ -522,6 +512,13 @@ function parse_runtime_info(elem) {
return;
}
if (k == "max_feed_id" || k == "num_feeds") {
if (init_params[k] != v) {
console.log("feed count changed, need to reload feedlist.");
updateFeedList();
}
}
init_params[k] = v;
notify('');
}