fix Task::all when tasks is empty

This commit is contained in:
matcool 2024-04-28 18:10:38 -03:00
parent 16636e8e7b
commit 9eb7064fcd
2 changed files with 5 additions and 3 deletions

View file

@ -339,6 +339,11 @@ namespace geode {
static Task<std::vector<T*>, std::monostate> all(std::vector<Task<T, NP>>&& tasks, std::string const& name = "<Multiple Tasks>") {
using AllTask = Task<std::vector<T*>, std::monostate>;
// If there are no tasks, return an immediate task that does nothing
if (tasks.empty()) {
return AllTask::immediate({}, name);
}
// Create a new supervising task for all of the provided tasks
auto task = AllTask(AllTask::Handle::create(name));

View file

@ -24,9 +24,6 @@ SuggestedModListSource::ProviderTask SuggestedModListSource::fetchPage(size_t pa
for (auto problem : Loader::get()->getRecommendations()) {
tasks.push_back(loadModSuggestion(problem));
}
if (tasks.empty()) {
return ProviderTask::immediate(Ok(ProvidedMods()), {});
}
return LoadModSuggestionTask::all(std::move(tasks)).map(
[query = m_query](auto* results) -> ProviderTask::Value {
auto content = ProvidedMods();