mirror of
https://github.com/geode-sdk/geode.git
synced 2024-11-14 19:15:05 -05:00
fix mod query default
This commit is contained in:
parent
79a2fe793a
commit
8be97b73c9
2 changed files with 26 additions and 33 deletions
|
@ -166,6 +166,7 @@ public:
|
||||||
server::ModsQuery const& getQuery() const;
|
server::ModsQuery const& getQuery() const;
|
||||||
InvalidateQueryAfter<server::ModsQuery> getQueryMut();
|
InvalidateQueryAfter<server::ModsQuery> getQueryMut();
|
||||||
bool isDefaultQuery() const override;
|
bool isDefaultQuery() const override;
|
||||||
|
server::ModsQuery createDefaultQuery() const;
|
||||||
ServerModListType getType() const;
|
ServerModListType getType() const;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -1,35 +1,7 @@
|
||||||
#include "ModListSource.hpp"
|
#include "ModListSource.hpp"
|
||||||
|
|
||||||
void ServerModListSource::resetQuery() {
|
void ServerModListSource::resetQuery() {
|
||||||
switch (m_type) {
|
m_query = this->createDefaultQuery();
|
||||||
case ServerModListType::Download: {
|
|
||||||
m_query = server::ModsQuery {};
|
|
||||||
} break;
|
|
||||||
|
|
||||||
case ServerModListType::Featured: {
|
|
||||||
m_query = server::ModsQuery {
|
|
||||||
.featured = true,
|
|
||||||
};
|
|
||||||
} break;
|
|
||||||
|
|
||||||
case ServerModListType::Trending: {
|
|
||||||
m_query = server::ModsQuery {
|
|
||||||
.sorting = server::ModsSort::RecentlyUpdated,
|
|
||||||
};
|
|
||||||
} break;
|
|
||||||
|
|
||||||
case ServerModListType::Recent: {
|
|
||||||
m_query = server::ModsQuery {
|
|
||||||
.sorting = server::ModsSort::RecentlyPublished,
|
|
||||||
};
|
|
||||||
} break;
|
|
||||||
|
|
||||||
case ServerModListType::Modtober24: {
|
|
||||||
m_query = server::ModsQuery {
|
|
||||||
.tags = { "modtober24" },
|
|
||||||
};
|
|
||||||
} break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ServerModListSource::ProviderTask ServerModListSource::fetchPage(size_t page, size_t pageSize, bool forceUpdate) {
|
ServerModListSource::ProviderTask ServerModListSource::fetchPage(size_t page, size_t pageSize, bool forceUpdate) {
|
||||||
|
@ -62,7 +34,7 @@ ServerModListSource::ServerModListSource(ServerModListType type)
|
||||||
|
|
||||||
ServerModListSource* ServerModListSource::get(ServerModListType type) {
|
ServerModListSource* ServerModListSource::get(ServerModListType type) {
|
||||||
switch (type) {
|
switch (type) {
|
||||||
default:
|
default: [[fallthrough]];
|
||||||
case ServerModListType::Download: {
|
case ServerModListType::Download: {
|
||||||
static auto inst = new ServerModListSource(ServerModListType::Download);
|
static auto inst = new ServerModListSource(ServerModListType::Download);
|
||||||
return inst;
|
return inst;
|
||||||
|
@ -115,9 +87,29 @@ InvalidateQueryAfter<server::ModsQuery> ServerModListSource::getQueryMut() {
|
||||||
return InvalidateQueryAfter(m_query, this);
|
return InvalidateQueryAfter(m_query, this);
|
||||||
}
|
}
|
||||||
bool ServerModListSource::isDefaultQuery() const {
|
bool ServerModListSource::isDefaultQuery() const {
|
||||||
return !m_query.query.has_value() &&
|
return m_query == this->createDefaultQuery();
|
||||||
m_query.tags.empty() &&
|
}
|
||||||
!m_query.developer.has_value();
|
|
||||||
|
server::ModsQuery ServerModListSource::createDefaultQuery() const {
|
||||||
|
switch (m_type) {
|
||||||
|
case ServerModListType::Download: return server::ModsQuery {};
|
||||||
|
|
||||||
|
case ServerModListType::Featured: return server::ModsQuery {
|
||||||
|
.featured = true,
|
||||||
|
};
|
||||||
|
|
||||||
|
case ServerModListType::Trending: return server::ModsQuery {
|
||||||
|
.sorting = server::ModsSort::RecentlyUpdated,
|
||||||
|
};
|
||||||
|
|
||||||
|
case ServerModListType::Recent: return server::ModsQuery {
|
||||||
|
.sorting = server::ModsSort::RecentlyPublished,
|
||||||
|
};
|
||||||
|
|
||||||
|
case ServerModListType::Modtober24: return server::ModsQuery {
|
||||||
|
.tags = { "modtober24" },
|
||||||
|
};
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ServerModListType ServerModListSource::getType() const {
|
ServerModListType ServerModListSource::getType() const {
|
||||||
|
|
Loading…
Reference in a new issue