Skip to content
Snippets Groups Projects
Commit c0a08063 authored by Andrew Dolgov's avatar Andrew Dolgov
Browse files

api: do not return Labels category when there are no labels (closes #651)

parent 41759103
No related branches found
No related tags found
No related merge requests found
......@@ -165,12 +165,14 @@ class API extends Handler {
}
foreach (array(-2,-1,0) as $cat_id) {
$unread = getFeedUnread($this->link, $cat_id, true);
if ($include_empty || !$this->isCategoryEmpty($cat_id)) {
$unread = getFeedUnread($this->link, $cat_id, true);
if ($unread || !$unread_only) {
array_push($cats, array("id" => $cat_id,
"title" => getCategoryTitle($this->link, $cat_id),
"unread" => $unread));
if ($unread || !$unread_only) {
array_push($cats, array("id" => $cat_id,
"title" => getCategoryTitle($this->link, $cat_id),
"unread" => $unread));
}
}
}
......@@ -724,6 +726,22 @@ class API extends Handler {
}
}
// only works for labels for the time being
private function isCategoryEmpty($id) {
if ($id == -2) {
$result = db_query($this->link, "SELECT COUNT(*) AS count FROM ttrss_labels2
WHERE owner_uid = " . $_SESSION["uid"]);
return db_fetch_result($result, 0, "count") == 0;
}
return false;
}
}
?>
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment