new option: HIDE_READ_FEEDS (+ pref setting RPC calls) (closes #23)
This commit is contained in:
parent
13b9833355
commit
7f123cdab4
7 changed files with 97 additions and 9 deletions
24
backend.php
24
backend.php
|
@ -53,6 +53,12 @@
|
|||
pg_query("set client_encoding = 'utf-8'");
|
||||
}
|
||||
|
||||
if (get_pref($link, "HIDE_READ_FEEDS") == "true") {
|
||||
setcookie("ttrss_vf_hreadf", 1);
|
||||
} else {
|
||||
setcookie("ttrss_vf_hreadf", 0);
|
||||
}
|
||||
|
||||
$fetch = $_GET["fetch"];
|
||||
|
||||
setcookie("ttrss_icons_url", ICONS_URL);
|
||||
|
@ -616,6 +622,24 @@
|
|||
|
||||
$subop = $_GET["subop"];
|
||||
|
||||
if ($subop == "setpref") {
|
||||
if (WEB_DEMO_MODE) {
|
||||
return;
|
||||
}
|
||||
|
||||
print "<rpc-reply>";
|
||||
|
||||
$key = db_escape_string($_GET["key"]);
|
||||
$value = db_escape_string($_GET["value"]);
|
||||
|
||||
set_pref($link, $key, $value);
|
||||
|
||||
print "<param-set key=\"$key\" value=\"$value\"/>";
|
||||
|
||||
print "</rpc-reply>";
|
||||
|
||||
}
|
||||
|
||||
if ($subop == "getLabelCounters") {
|
||||
$aid = $_GET["aid"];
|
||||
print "<rpc-reply>";
|
||||
|
|
14
db-prefs.php
14
db-prefs.php
|
@ -57,4 +57,18 @@
|
|||
return $value;
|
||||
}
|
||||
}
|
||||
|
||||
// doesn't peform any type checking, be vigilant
|
||||
|
||||
function set_pref($link, $key, $value) {
|
||||
$key = db_escape_string($key);
|
||||
$value = db_escape_string($value);
|
||||
|
||||
db_query($link, "UPDATE ttrss_user_prefs SET
|
||||
value = '$value' WHERE pref_name = '$key'
|
||||
AND owner_uid = " . $_SESSION["uid"]);
|
||||
|
||||
$_SESSION["prefs_cache"] = array();
|
||||
|
||||
}
|
||||
?>
|
||||
|
|
|
@ -235,6 +235,8 @@ insert into ttrss_prefs (pref_name,type_id,def_value,short_desc,section_id,help_
|
|||
|
||||
insert into ttrss_prefs (pref_name,type_id,def_value,short_desc,section_id) values('ENABLE_SEARCH_TOOLBAR', 1, 'false', 'Enable search toolbar',2);
|
||||
|
||||
insert into ttrss_prefs (pref_name,type_id,def_value,short_desc,section_id) values('HIDE_READ_FEEDS', 1, 'false', 'Hide feeds with no unread messages',2);
|
||||
|
||||
create table ttrss_user_prefs (
|
||||
owner_uid integer not null,
|
||||
pref_name varchar(250),
|
||||
|
|
|
@ -213,6 +213,8 @@ insert into ttrss_prefs (pref_name,type_id,def_value,short_desc,section_id,help_
|
|||
|
||||
insert into ttrss_prefs (pref_name,type_id,def_value,short_desc,section_id) values('ENABLE_SEARCH_TOOLBAR', 1, 'false', 'Enable search toolbar',2);
|
||||
|
||||
insert into ttrss_prefs (pref_name,type_id,def_value,short_desc,section_id) values('HIDE_READ_FEEDS', 1, 'false', 'Hide feeds with no unread messages',2);
|
||||
|
||||
create table ttrss_user_prefs (
|
||||
owner_uid integer not null references ttrss_users(id) ON DELETE CASCADE,
|
||||
pref_name varchar(250) not null references ttrss_prefs(pref_name) ON DELETE CASCADE,
|
||||
|
|
|
@ -10,6 +10,8 @@ update ttrss_feeds set private = false;
|
|||
alter table ttrss_feeds change private private bool not null;
|
||||
alter table ttrss_feeds alter column private set default 0;
|
||||
|
||||
insert into ttrss_prefs (pref_name,type_id,def_value,short_desc,section_id) values('HIDE_READ_FEEDS', 1, 'false', 'Hide feeds with no unread messages',2);
|
||||
|
||||
update ttrss_version set schema_version = 4;
|
||||
|
||||
commit;
|
||||
|
|
|
@ -10,6 +10,8 @@ update ttrss_feeds set private = false;
|
|||
alter table ttrss_feeds alter column private set not null;
|
||||
alter table ttrss_feeds alter column private set default false;
|
||||
|
||||
insert into ttrss_prefs (pref_name,type_id,def_value,short_desc,section_id) values('HIDE_READ_FEEDS', 1, 'false', 'Hide feeds with no unread messages',2);
|
||||
|
||||
update ttrss_version set schema_version = 4;
|
||||
|
||||
commit;
|
||||
|
|
60
tt-rss.js
60
tt-rss.js
|
@ -72,6 +72,31 @@ function dlg_display_callback() {
|
|||
}
|
||||
}
|
||||
|
||||
function hide_unread_callback() {
|
||||
if (xmlhttp.readyState == 4) {
|
||||
|
||||
try {
|
||||
|
||||
var reply = xmlhttp.responseXML.firstChild.firstChild;
|
||||
var value = reply.getAttribute("value");
|
||||
var hide_read_feeds = (value != "false")
|
||||
var feeds_doc = window.frames["feeds-frame"].document;
|
||||
|
||||
hideOrShowFeeds(feeds_doc, hide_read_feeds);
|
||||
|
||||
if (hide_read_feeds) {
|
||||
setCookie("ttrss_vf_hreadf", 1);
|
||||
} else {
|
||||
setCookie("ttrss_vf_hreadf", 0);
|
||||
}
|
||||
|
||||
} catch (e) {
|
||||
exception_error("hide_unread_callback", e);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
function refetch_callback() {
|
||||
if (xmlhttp.readyState == 4) {
|
||||
try {
|
||||
|
@ -504,6 +529,11 @@ function qaddFilter() {
|
|||
|
||||
function displayDlg(id, param) {
|
||||
|
||||
if (!xmlhttp_ready(xmlhttp)) {
|
||||
printLockingError();
|
||||
return
|
||||
}
|
||||
|
||||
notify("");
|
||||
|
||||
xmlhttp.open("GET", "backend.php?op=dlg&id=" +
|
||||
|
@ -524,6 +554,11 @@ function qfdDelete(feed_id) {
|
|||
|
||||
notify("Removing feed...");
|
||||
|
||||
if (!xmlhttp_ready(xmlhttp)) {
|
||||
printLockingError();
|
||||
return
|
||||
}
|
||||
|
||||
// var feeds_doc = window.frames["feeds-frame"].document;
|
||||
// feeds_doc.location.href = "backend.php?op=error&msg=Loading,%20please wait...";
|
||||
|
||||
|
@ -563,19 +598,26 @@ function updateFeedTitle(t) {
|
|||
}
|
||||
|
||||
function toggleDispRead() {
|
||||
var hide_read_feeds = (getCookie("ttrss_vf_hreadf") == 1);
|
||||
try {
|
||||
|
||||
hide_read_feeds = !hide_read_feeds;
|
||||
if (!xmlhttp_ready(xmlhttp)) {
|
||||
printLockingError();
|
||||
return
|
||||
}
|
||||
|
||||
var feeds_doc = window.frames["feeds-frame"].document;
|
||||
var hide_read_feeds = (getCookie("ttrss_vf_hreadf") == 1);
|
||||
|
||||
hideOrShowFeeds(feeds_doc, hide_read_feeds);
|
||||
hide_read_feeds = !hide_read_feeds;
|
||||
|
||||
var query = "backend.php?op=rpc&subop=setpref" +
|
||||
"&key=HIDE_READ_FEEDS&value=" + param_escape(hide_read_feeds);
|
||||
|
||||
if (hide_read_feeds) {
|
||||
setCookie("ttrss_vf_hreadf", 1);
|
||||
} else {
|
||||
setCookie("ttrss_vf_hreadf", 0);
|
||||
xmlhttp.open("GET", query);
|
||||
xmlhttp.onreadystatechange=hide_unread_callback;
|
||||
xmlhttp.send(null);
|
||||
|
||||
} catch (e) {
|
||||
exception_error("toggleDispRead", e);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue