feat: add verion_type / release_type to IndexedVersion

Signed-off-by: Rachel Powers <508861+Ryex@users.noreply.github.com>
This commit is contained in:
Rachel Powers
2023-05-26 13:50:22 -07:00
parent f24211e8b5
commit c156034069
5 changed files with 93 additions and 3 deletions

View File

@ -144,7 +144,10 @@ auto FlameAPI::getLatestVersion(VersionSearchArgs&& args) -> ModPlatform::Indexe
for (auto file : arr) {
auto file_obj = Json::requireObject(file);
auto file_tmp = FlameMod::loadIndexedPackVersion(file_obj);
if(file_tmp.date > ver_tmp.date) {
bool better_release = true;
if (file_tmp.verison_type.has_value() && ver_tmp.verison_type.has_value())
better_release = file_tmp.verison_type.value() < ver_tmp.verison_type.value();
if(file_tmp.date > ver_tmp.date && better_release) {
ver_tmp = file_tmp;
latest_file_obj = file_obj;
}

View File

@ -94,8 +94,11 @@ void FlameMod::loadIndexedPackVersions(ModPlatform::IndexedPack& pack,
}
auto orderSortPredicate = [](const ModPlatform::IndexedVersion& a, const ModPlatform::IndexedVersion& b) -> bool {
bool a_better_release = true;
if (a.verison_type.has_value() && b.verison_type.has_value())
a_better_release = a.verison_type.value() < b.verison_type.value();
// dates are in RFC 3339 format
return a.date > b.date;
return a.date > b.date && a_better_release;
};
std::sort(unsortedVersions.begin(), unsortedVersions.end(), orderSortPredicate);
pack.versions = unsortedVersions;
@ -123,6 +126,9 @@ auto FlameMod::loadIndexedPackVersion(QJsonObject& obj, bool load_changelog) ->
file.version = Json::requireString(obj, "displayName");
file.downloadUrl = Json::ensureString(obj, "downloadUrl");
file.fileName = Json::requireString(obj, "fileName");
auto version_type = ModPlatform::IndexedVersionType(Json::requireInteger(obj, "releaseType"));
if (version_type.isValid())
file.verison_type = version_type;
auto hash_list = Json::ensureArray(obj, "hashes");
for (auto h : hash_list) {