Compare commits

..

2 commits

Author SHA1 Message Date
larzie
461c30f572
Merge d86830028e into 280b6efa94 2024-11-14 15:46:51 +11:00
Fleeym
280b6efa94
fix: fix mod downloads not checking version (#1148)
Some checks are pending
Build Binaries / Build Windows (push) Waiting to run
Build Binaries / Build macOS (push) Waiting to run
Build Binaries / Build Android (64-bit) (push) Waiting to run
Build Binaries / Build Android (32-bit) (push) Waiting to run
Build Binaries / Publish (push) Blocked by required conditions
2024-11-14 02:26:40 +02:00
5 changed files with 34 additions and 14 deletions

View file

@ -8,6 +8,7 @@
#include <fmt/chrono.h>
#include <loader/LoaderImpl.hpp>
#include "../internal/about.hpp"
#include "Geode/loader/Loader.hpp"
using namespace server;
@ -647,7 +648,7 @@ ServerRequest<ServerModVersion> server::getModVersion(std::string const& id, Mod
},
}, version);
return req.get(formatServerURL("/mods/{}/versions/{}", id, versionURL)).map(
return req.get(formatServerURL("/mods/{}/versions/{}?gd={}", id, versionURL, Loader::get()->getGameVersion())).map(
[](web::WebResponse* response) -> Result<ServerModVersion, ServerError> {
if (response->ok()) {
// Parse payload

View file

@ -8,6 +8,7 @@
#include <Geode/utils/ColorProvider.hpp>
#include <Geode/binding/ButtonSprite.hpp>
#include <Geode/loader/Loader.hpp>
#include "server/DownloadManager.hpp"
#include "ui/mods/GeodeStyle.hpp"
#include "ui/mods/popups/ModPopup.hpp"
#include "ui/mods/popups/DevPopup.hpp"
@ -631,18 +632,7 @@ void ModItem::onEnable(CCObject*) {
UpdateModListStateEvent(UpdateModState(m_source.getID())).post();
}
void ModItem::onInstall(CCObject*) {
if (auto updates = m_source.hasUpdates()) {
if (updates->replacement.has_value()) {
server::ModDownloadManager::get()->startDownload(
updates->replacement->id,
updates->replacement->version,
std::nullopt,
m_source.getID()
);
return;
}
}
server::ModDownloadManager::get()->startDownload(m_source.getID(), std::nullopt);
m_source.startInstall();
}
void ModItem::onDevelopers(CCObject*) {
DevListPopup::create(m_source)->show();

View file

@ -7,11 +7,13 @@
#include <Geode/loader/ModSettingsManager.hpp>
#include <Geode/ui/GeodeUI.hpp>
#include <Geode/utils/ColorProvider.hpp>
#include <optional>
#include "ConfirmUninstallPopup.hpp"
#include "../settings/ModSettingsPopup.hpp"
#include "../../../internal/about.hpp"
#include "../../GeodeUIEvent.hpp"
#include "../popups/ModtoberPopup.hpp"
#include "server/DownloadManager.hpp"
class FetchTextArea : public CCNode {
public:
@ -1047,7 +1049,9 @@ void ModPopup::onInstall(CCObject*) {
return;
}
}
server::ModDownloadManager::get()->startDownload(m_source.getID(), std::nullopt);
m_source.startInstall();
this->onClose(nullptr);
}

View file

@ -240,3 +240,27 @@ server::ServerRequest<std::optional<server::ServerModUpdate>> ModSource::checkUp
},
}, m_value);
}
void ModSource::startInstall() {
if (auto updates = this->hasUpdates()) {
if (updates->replacement.has_value()) {
server::ModDownloadManager::get()->startDownload(
updates->replacement->id,
updates->replacement->version,
std::nullopt,
this->getID()
);
} else {
server::ModDownloadManager::get()->startDownload(
this->getID(),
updates->version
);
}
} else {
server::ModDownloadManager::get()->startDownload(
this->getID(),
this->asServer()
? std::optional{this->asServer()->latestVersion().getVersion()}
: std::nullopt
);
}
}

View file

@ -49,4 +49,5 @@ public:
server::ServerRequest<std::optional<std::string>> fetchChangelog() const;
server::ServerRequest<std::unordered_set<std::string>> fetchValidTags() const;
server::ServerRequest<std::optional<server::ServerModUpdate>> checkUpdates();
void startInstall();
};