Lines
96.77 %
Functions
50 %
Branches
100 %
//! What closing a window settles: the form and the bulk delete it started.
use super::App;
use crate::route::RouteCtx;
use crate::window::WindowId;
impl App {
/// Releases the form and abandons the bulk delete whose replies belong to window `id`. The
/// routes stay, so the replies are discarded as those of a gone window.
pub(super) fn settle_window(&mut self, id: WindowId) {
let notes = [self.release_form_of(id), self.abandon_bulk_of(id)];
let notes: Vec<String> = notes.into_iter().flatten().collect();
if !notes.is_empty() {
self.set_status(notes.join("; "));
}
if self.status_owner == Some(id) {
self.status_owner = None;
fn targets(&self, request_id: i64, id: WindowId) -> bool {
let route = self.pending_routes.get(&request_id);
route.is_some_and(|route| route.target == Some(id))
fn release_form_of(&mut self, id: WindowId) -> Option<String> {
let request_id = self.pending_form.as_ref()?.request_id;
if !self.targets(request_id, id) {
return None;
self.pending_form = None;
Some("window closed; the outcome of its form is not shown".to_string())
fn abandon_bulk_of(&mut self, id: WindowId) -> Option<String> {
let started_here = self.pending_routes.iter().any(|(request_id, route)| {
matches!(route.ctx, RouteCtx::BulkDelete { .. }) && self.targets(*request_id, id)
});
if started_here {
return self.bulk.abandon();
None