Files
todo-baggins/src/query/subtasks.rs
Matouš Volf 3646aa91c4
Some checks failed
actionlint check / actionlint check (pull_request) Successful in 5s
checkov check / checkov check (pull_request) Successful in 52s
conventional commit messages check / conventional commit messages check (pull_request) Successful in 4s
conventional pull request title check / conventional pull request title check (pull_request) Successful in 2s
dotenv-linter check / dotenv-linter check (pull_request) Successful in 5s
GitLeaks check / GitLeaks check (pull_request) Successful in 6s
hadolint check / hadolint check (pull_request) Successful in 7s
htmlhint check / htmlhint check (pull_request) Successful in 9s
markdownlint check / markdownlint check (pull_request) Successful in 9s
Prettier check / Prettier check (pull_request) Successful in 10s
Rust check / Rust check (pull_request) Failing after 6m20s
ShellCheck check / ShellCheck check (pull_request) Successful in 12s
Stylelint check / Stylelint check (pull_request) Successful in 11s
yamllint check / yamllint check (pull_request) Successful in 13s
style: fix the rustfmt linted files
2024-12-29 19:30:35 +01:00

27 lines
972 B
Rust

use crate::query::{QueryErrors, QueryKey, QueryValue};
use crate::server::subtasks::get_subtasks_of_task;
use dioxus::prelude::ServerFnError;
use dioxus_query::prelude::{use_get_query, QueryResult, UseQuery};
pub(crate) fn use_subtasks_of_task_query(
task_id: i32,
) -> UseQuery<QueryValue, QueryErrors, QueryKey> {
use_get_query(
[QueryKey::SubtasksOfTaskId(task_id)],
fetch_subtasks_of_task,
)
}
async fn fetch_subtasks_of_task(keys: Vec<QueryKey>) -> QueryResult<QueryValue, QueryErrors> {
if let Some(QueryKey::SubtasksOfTaskId(task_id)) = keys.first() {
match get_subtasks_of_task(*task_id).await {
Ok(subtasks) => Ok(QueryValue::Subtasks(subtasks)),
Err(ServerFnError::WrappedServerError(errors)) => Err(QueryErrors::Error(errors)),
Err(error) => panic!("Unexpected error: {:?}", error),
}
.into()
} else {
panic!("Unexpected query keys: {:?}", keys);
}
}