(app: &mut App)
| 2396 | } |
| 2397 | |
| 2398 | async fn refresh_draft_chunks(app: &mut App) { |
| 2399 | let sandbox_name = match app.selected_sandbox_name() { |
| 2400 | Some(name) => name.to_string(), |
| 2401 | None => return, |
| 2402 | }; |
| 2403 | |
| 2404 | let req = openshell_core::proto::GetDraftPolicyRequest { |
| 2405 | name: sandbox_name, |
| 2406 | status_filter: String::new(), |
| 2407 | }; |
| 2408 | |
| 2409 | match tokio::time::timeout(Duration::from_secs(5), app.client.get_draft_policy(req)).await { |
| 2410 | Ok(Ok(resp)) => { |
| 2411 | let inner = resp.into_inner(); |
| 2412 | app.draft_chunks = inner.chunks; |
| 2413 | app.draft_version = inner.draft_version; |
| 2414 | if app.draft_selected >= app.draft_chunks.len() && !app.draft_chunks.is_empty() { |
| 2415 | app.draft_selected = app.draft_chunks.len() - 1; |
| 2416 | } |
| 2417 | } |
| 2418 | Ok(Err(e)) => { |
| 2419 | tracing::debug!("draft chunks refresh: {}", e.message()); |
| 2420 | } |
| 2421 | Err(_) => { |
| 2422 | tracing::debug!("draft chunks refresh timed out"); |
| 2423 | } |
| 2424 | } |
| 2425 | } |
| 2426 | |
| 2427 | /// Fetch the count of pending draft recommendations for every sandbox. |
| 2428 | /// |
no test coverage detected