mirror of
https://github.com/PrismLauncher/PrismLauncher.git
synced 2026-07-04 20:36:58 +03:00
NOISSUE Filter all pack's by name to search for modpacks.ch
modpacks.ch searching has changed, and while likely a bug - we may as well make this change while we fetch all packs anyway. This makes MMC more reactive for searchs for the platform. This should be reverted if/when the modpacks.ch hits a size where we need to restrict how many packs are fetched.
This commit is contained in:
parent
6cc7788b4a
commit
175132539b
6 changed files with 39 additions and 51 deletions
|
|
@ -74,24 +74,6 @@ QVariant ListModel::data(const QModelIndex &index, int role) const
|
|||
return QVariant();
|
||||
}
|
||||
|
||||
void ListModel::performSearch()
|
||||
{
|
||||
auto *netJob = new NetJob("Ftb::Search");
|
||||
QString searchUrl;
|
||||
if(currentSearchTerm.isEmpty()) {
|
||||
searchUrl = BuildConfig.MODPACKSCH_API_BASE_URL + "public/modpack/all";
|
||||
}
|
||||
else {
|
||||
searchUrl = QString(BuildConfig.MODPACKSCH_API_BASE_URL + "public/modpack/search/25?term=%1")
|
||||
.arg(currentSearchTerm);
|
||||
}
|
||||
netJob->addNetAction(Net::Download::makeByteArray(QUrl(searchUrl), &response));
|
||||
jobPtr = netJob;
|
||||
jobPtr->start();
|
||||
QObject::connect(netJob, &NetJob::succeeded, this, &ListModel::searchRequestFinished);
|
||||
QObject::connect(netJob, &NetJob::failed, this, &ListModel::searchRequestFailed);
|
||||
}
|
||||
|
||||
void ListModel::getLogo(const QString &logo, const QString &logoUrl, LogoCallback callback)
|
||||
{
|
||||
if(m_logoMap.contains(logo))
|
||||
|
|
@ -104,28 +86,23 @@ void ListModel::getLogo(const QString &logo, const QString &logoUrl, LogoCallbac
|
|||
}
|
||||
}
|
||||
|
||||
void ListModel::searchWithTerm(const QString &term)
|
||||
void ListModel::request()
|
||||
{
|
||||
if(searchState != Failed && currentSearchTerm == term && currentSearchTerm.isNull() == term.isNull()) {
|
||||
// unless the search has failed, then there is no need to perform an identical search.
|
||||
return;
|
||||
}
|
||||
currentSearchTerm = term;
|
||||
|
||||
if(jobPtr) {
|
||||
jobPtr->abort();
|
||||
jobPtr.reset();
|
||||
}
|
||||
|
||||
beginResetModel();
|
||||
modpacks.clear();
|
||||
endResetModel();
|
||||
searchState = None;
|
||||
|
||||
performSearch();
|
||||
auto *netJob = new NetJob("Ftb::Request");
|
||||
auto url = QString(BuildConfig.MODPACKSCH_API_BASE_URL + "public/modpack/all");
|
||||
netJob->addNetAction(Net::Download::makeByteArray(QUrl(url), &response));
|
||||
jobPtr = netJob;
|
||||
jobPtr->start();
|
||||
|
||||
QObject::connect(netJob, &NetJob::succeeded, this, &ListModel::requestFinished);
|
||||
QObject::connect(netJob, &NetJob::failed, this, &ListModel::requestFailed);
|
||||
}
|
||||
|
||||
void ListModel::searchRequestFinished()
|
||||
void ListModel::requestFinished()
|
||||
{
|
||||
jobPtr.reset();
|
||||
remainingPacks.clear();
|
||||
|
|
@ -150,12 +127,10 @@ void ListModel::searchRequestFinished()
|
|||
}
|
||||
}
|
||||
|
||||
void ListModel::searchRequestFailed(QString reason)
|
||||
void ListModel::requestFailed(QString reason)
|
||||
{
|
||||
jobPtr.reset();
|
||||
remainingPacks.clear();
|
||||
|
||||
searchState = Failed;
|
||||
}
|
||||
|
||||
void ListModel::requestPack()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue