Simplify Startup.json parsing slightly

The lambdas were originally there to allow for different ways to determine whether the version offered by the website is indeed an update. The lambdas became identical in a9cbd784f7 however, which is when this change should have been made.
This commit is contained in:
Tamás Bálint Misius
2024-06-19 12:15:44 +02:00
parent a24e1dbee8
commit b4a12aae32

View File

@@ -46,7 +46,7 @@ namespace http
if constexpr (!IGNORE_UPDATES)
{
auto &versions = document["Updates"];
auto parseUpdate = [this, &versions, &startupInfo](ByteString key, UpdateInfo::Channel channel, std::function<bool (int)> updateAvailableFunc) {
auto parseUpdate = [this, &versions, &startupInfo](ByteString key, UpdateInfo::Channel channel) {
if (!versions.isMember(key))
{
return;
@@ -64,7 +64,7 @@ namespace http
return info[key].asInt();
};
auto build = getOr(key == "Snapshot" ? "Snapshot" : "Build", 0);
if (!updateAvailableFunc(build))
if (size_t(build) <= APP_VERSION.build)
{
return;
}
@@ -79,20 +79,14 @@ namespace http
};
if constexpr (SNAPSHOT || MOD)
{
parseUpdate("Snapshot", UpdateInfo::channelSnapshot, [](int build) -> bool {
return size_t(build) > APP_VERSION.build;
});
parseUpdate("Snapshot", UpdateInfo::channelSnapshot);
}
else
{
parseUpdate("Stable", UpdateInfo::channelStable, [](int build) -> bool {
return size_t(build) > APP_VERSION.build;
});
parseUpdate("Stable", UpdateInfo::channelStable);
if (!startupInfo.updateInfo.has_value())
{
parseUpdate("Beta", UpdateInfo::channelBeta, [](int build) -> bool {
return size_t(build) > APP_VERSION.build;
});
parseUpdate("Beta", UpdateInfo::channelBeta);
}
}
}