Преглед изворни кода

Fixed transmission queue

Changed the api result when there's no option selected, and I've added a default sort for added date.
G4Zz0L1 пре 5 година
родитељ
комит
41b0da21a0
1 измењених фајлова са 6 додато и 3 уклоњено
  1. 6 3
      api/homepage/transmission.php

+ 6 - 3
api/homepage/transmission.php

@@ -166,7 +166,7 @@ trait TransmissionHomepageItem
 					'method' => 'torrent-get',
 					'arguments' => array(
 						'fields' => array(
-							"id", "name", "totalSize", "eta", "isFinished", "isStalled", "percentDone", "rateDownload", "status", "downloadDir", "errorString"
+							"id", "name", "totalSize", "eta", "isFinished", "isStalled", "percentDone", "rateDownload", "status", "downloadDir", "errorString", "addedDate"
 						),
 					),
 					'tags' => ''
@@ -189,8 +189,11 @@ trait TransmissionHomepageItem
 							}
 						}
 					} else {
-						$torrents = json_decode($response->body, true);
+						$torrents = json_decode($response->body, true)['arguments']['torrents'];
 					}
+					usort($torrents, function ($a, $b) {
+						return $a["addedDate"] < $b["addedDate"];
+					});
 					$api['content']['queueItems'] = $torrents;
 					$api['content']['historyItems'] = false;
 				}
@@ -208,4 +211,4 @@ trait TransmissionHomepageItem
 		$this->setAPIResponse('success', null, 200, $api);
 		return $api;
 	}
-}
+}