Skip to content

Commit

Permalink
Show 'stop' banner after user changes picture directory
Browse files Browse the repository at this point in the history
  • Loading branch information
blissd committed Sep 8, 2024
1 parent 1800c18 commit bac2314
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
9 changes: 9 additions & 0 deletions src/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,9 @@ pub(super) enum AppMsg {
// Stop all background tasks
StopBackgroundTasks,

// Stopping background tasks is in progress
StoppingBackgroundTasks,

// Adapt to layout change
Adapt(adaptive::Layout),

Expand Down Expand Up @@ -560,6 +563,7 @@ impl SimpleComponent for App {
.forward(sender.input_sender(), |msg| match msg {
BootstrapOutput::TaskStarted(msg) => AppMsg::TaskStarted(msg),
BootstrapOutput::Completed => AppMsg::BootstrapCompleted,
BootstrapOutput::Stopping => AppMsg::StoppingBackgroundTasks,
});

let onboard = Onboard::builder()
Expand Down Expand Up @@ -953,6 +957,11 @@ impl SimpleComponent for App {
self.banner.set_title(&fl!("banner-stopping"));
self.bootstrap.emit(BootstrapInput::Stop);
},
AppMsg::StoppingBackgroundTasks => {
info!("Background tasks are stopping.");
self.banner.set_button_label(None);
self.banner.set_title(&fl!("banner-stopping"));
},
AppMsg::Adapt(adaptive::Layout::Narrow) => {
self.main_navigation.set_collapsed(true);
self.main_navigation.set_show_sidebar(false);
Expand Down
7 changes: 5 additions & 2 deletions src/app/background/bootstrap.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ use std::time::Instant;
use std::collections::VecDeque;
use std::path::PathBuf;

use tracing::info;
use tracing::{info, warn};

use super::{
load_library::{LoadLibrary, LoadLibraryInput, LoadLibraryOutput},
Expand Down Expand Up @@ -114,6 +114,8 @@ pub enum BootstrapOutput {
// Bootstrap process has completed.
Completed,

// Tasks are in the process of stopping
Stopping
}

type Task = dyn Fn() + Send + Sync;
Expand Down Expand Up @@ -230,6 +232,7 @@ impl Controllers {
BootstrapInput::Stop => {
info!("Stopping all background tasks");
if self.is_running {
let _ = sender.output(BootstrapOutput::Stopping);
if let Ok(mut tasks) = self.pending_tasks.lock() {
tasks.clear();
}
Expand All @@ -239,7 +242,7 @@ impl Controllers {
}
},
other => {
info!("Ignoring {:?}! Please check this isn't a bug!", other);
warn!("Ignoring {:?}! Please check this isn't a bug!", other);
},
};
}
Expand Down

0 comments on commit bac2314

Please sign in to comment.