[Scummvm-git-logs] scummvm-web master -> bead8af168685e3235c9b2df2bd8d0407a8d5dfb
Thunderforge
noreply at scummvm.org
Sat Jan 29 00:08:08 UTC 2022
This automated email contains information about 1 new commit which have been
pushed to the 'scummvm-web' repo located at https://github.com/scummvm/scummvm-web .
Summary:
bead8af168 DATA: Sorting by autoId after sorting by version
Commit: bead8af168685e3235c9b2df2bd8d0407a8d5dfb
https://github.com/scummvm/scummvm-web/commit/bead8af168685e3235c9b2df2bd8d0407a8d5dfb
Author: Thunderforge (wjherrmann at gmail.com)
Date: 2022-01-28T18:08:03-06:00
Commit Message:
DATA: Sorting by autoId after sorting by version
Changed paths:
include/Objects/DownloadsSection.php
include/Objects/File.php
diff --git a/include/Objects/DownloadsSection.php b/include/Objects/DownloadsSection.php
index 6f91469d..5b28df0b 100644
--- a/include/Objects/DownloadsSection.php
+++ b/include/Objects/DownloadsSection.php
@@ -29,10 +29,17 @@ class DownloadsSection extends BasicSection
{
if ($item->getCategoryIcon()) {
$this->items[] = new File($item->toArray(TableMap::TYPE_FIELDNAME), '');
- // If this item is for an old version, sort all items by version, descending
+ // If this item is for an old version, sort all items by version, descending, then by autoId
if ($this->hasOldVersion($item)) {
usort($this->items, function ($a, $b) {
- return -version_compare($a->version, $b->version);
+ // Return 0 if equal, -1 if $a->version is larger, 1 if $b->version is larger
+ $versionSortResult = -version_compare($a->version, $b->version);
+ if ($versionSortResult == 0) {
+ // Return 0 if equal, -1 if $a->autoId is smaller, 1 if $b->autoId is smaller
+ return $a->autoId <=> $b->autoId;
+ } else {
+ return $versionSortResult;
+ }
});
}
} else {
diff --git a/include/Objects/File.php b/include/Objects/File.php
index 918d80ac..2adc5b3e 100644
--- a/include/Objects/File.php
+++ b/include/Objects/File.php
@@ -17,6 +17,7 @@ class File extends BasicObject
public function __construct($data, $baseUrl = null)
{
parent::__construct($data);
+ $this->autoId = $data['autoId'] ?? null;
$this->category = $data['category'];
$this->category_icon = $data['category_icon'];
$this->notes = isset($data['notes']) ? $data['notes'] : '';
More information about the Scummvm-git-logs
mailing list