Browse Source

API/getHeadlines: fix order of returned feeds to be consistent with main UI

Andrew Dolgov 1 year ago
parent
commit
e46ed1ff97
1 changed files with 5 additions and 3 deletions
  1. 5 3
      classes/api.php

+ 5 - 3
classes/api.php

@@ -535,6 +535,7 @@ class API extends Handler {
 
 			/* Labels */
 
+			/* API only: -4 All feeds, including virtual feeds */
 			if ($cat_id == -4 || $cat_id == -2) {
 				$counters = Counters::getLabelCounters(true);
 
@@ -582,7 +583,7 @@ class API extends Handler {
 			if ($include_nested && $cat_id) {
 				$sth = $pdo->prepare("SELECT
 					id, title, order_id FROM ttrss_feed_categories
-					WHERE parent_cat = ? AND owner_uid = ? ORDER BY id, title");
+					WHERE parent_cat = ? AND owner_uid = ? ORDER BY order_id, title");
 
 				$sth->execute([$cat_id, $_SESSION['uid']]);
 
@@ -611,12 +612,13 @@ class API extends Handler {
 				$limit_qpart = "";
 			}
 
+			/* API only: -3 All feeds, excluding virtual feeds (e.g. Labels and such) */
 			if ($cat_id == -4 || $cat_id == -3) {
 				$sth = $pdo->prepare("SELECT
 					id, feed_url, cat_id, title, order_id, ".
 						SUBSTRING_FOR_DATE."(last_updated,1,19) AS last_updated
 						FROM ttrss_feeds WHERE owner_uid = ?
-						ORDER BY cat_id, title " . $limit_qpart);
+						ORDER BY order_id, title " . $limit_qpart);
 				$sth->execute([$_SESSION['uid']]);
 
 			} else {
@@ -627,7 +629,7 @@ class API extends Handler {
 						FROM ttrss_feeds WHERE
 						(cat_id = :cat OR (:cat = 0 AND cat_id IS NULL))
 						AND owner_uid = :uid
-						ORDER BY cat_id, title " . $limit_qpart);
+						ORDER BY order_id, title " . $limit_qpart);
 				$sth->execute([":uid" => $_SESSION['uid'], ":cat" => $cat_id]);
 			}