fix: task sorting
All checks were successful
actionlint check / actionlint check (pull_request) Successful in 6s
conventional pull request title check / conventional pull request title check (pull_request) Successful in 3s
conventional commit messages check / conventional commit messages check (pull_request) Successful in 7s
dotenv-linter check / dotenv-linter check (pull_request) Successful in 7s
GitLeaks check / GitLeaks check (pull_request) Successful in 10s
hadolint check / hadolint check (pull_request) Successful in 11s
htmlhint check / htmlhint check (pull_request) Successful in 44s
markdownlint check / markdownlint check (pull_request) Successful in 40s
Prettier check / Prettier check (pull_request) Successful in 36s
checkov check / checkov check (pull_request) Successful in 1m22s
ShellCheck check / ShellCheck check (pull_request) Successful in 29s
Stylelint check / Stylelint check (pull_request) Successful in 31s
yamllint check / yamllint check (pull_request) Successful in 29s
Rust check / Rust check (pull_request) Successful in 11m42s

This commit is contained in:
2025-12-19 18:40:48 +01:00
parent 999057314a
commit dc3effe640
7 changed files with 28 additions and 16 deletions

View File

@@ -13,6 +13,17 @@ use crate::{
},
};
#[allow(clippy::result_large_err)]
fn sort_loader_result<T: Ord + Clone>(
result: Result<Loader<Vec<T>>, Loading>,
) -> Result<Vec<T>, Loading> {
result.map(|loader| {
let mut items_sorted = loader();
items_sorted.sort();
items_sorted
})
}
#[allow(clippy::result_large_err)]
fn use_loader_with_update_subscription<F, T, E>(
mut future: impl FnMut() -> F + 'static,
@@ -40,22 +51,23 @@ where
}
#[allow(clippy::result_large_err)]
pub(crate) fn use_projects() -> Result<Loader<Vec<Project>>, Loading> {
use_loader_with_update_subscription(get_projects).inspect(|projects| projects().sort())
pub(crate) fn use_projects() -> Result<Vec<Project>, Loading> {
let result = use_loader_with_update_subscription(get_projects);
sort_loader_result(result)
}
#[allow(clippy::result_large_err)]
pub(crate) fn use_tasks_with_subtasks_in_category(
filtered_category: Category,
) -> Result<Loader<Vec<TaskWithSubtasks>>, Loading> {
use_loader_with_update_subscription(move || {
) -> Result<Vec<TaskWithSubtasks>, Loading> {
let result = use_loader_with_update_subscription(move || {
get_tasks_with_subtasks_in_category(filtered_category.clone())
})
.inspect(|tasks| tasks().sort())
});
sort_loader_result(result)
}
#[allow(clippy::result_large_err)]
pub(crate) fn use_subtasks_of_task(task_id: i32) -> Result<Loader<Vec<Subtask>>, Loading> {
use_loader_with_update_subscription(move || get_subtasks_of_task(task_id))
.inspect(|subtasks| subtasks().sort())
pub(crate) fn use_subtasks_of_task(task_id: i32) -> Result<Vec<Subtask>, Loading> {
let result = use_loader_with_update_subscription(move || get_subtasks_of_task(task_id));
sort_loader_result(result)
}