aboutsummaryrefslogtreecommitdiff
path: root/src/app
diff options
context:
space:
mode:
Diffstat (limited to 'src/app')
-rw-r--r--src/app/actions.rs31
-rw-r--r--src/app/api.rs12
-rw-r--r--src/app/mod.rs3
-rw-r--r--src/app/state.rs2
4 files changed, 42 insertions, 6 deletions
diff --git a/src/app/actions.rs b/src/app/actions.rs
index 870044a8..be8e1018 100644
--- a/src/app/actions.rs
+++ b/src/app/actions.rs
@@ -652,8 +652,12 @@ impl AppState {
self.handle_pane_died(pane_id);
Vec::new()
}
- AppEvent::UpdateReady { version } => {
+ AppEvent::UpdateReady {
+ version,
+ install_command,
+ } => {
self.update_available = Some(version.clone());
+ self.update_install_command = install_command.clone();
self.latest_release_notes_available = true;
self.update_dismissed = true;
if matches!(
@@ -663,7 +667,7 @@ impl AppState {
self.toast = Some(ToastNotification {
kind: ToastKind::UpdateInstalled,
title: format!("v{version} available"),
- context: "detach, then run `herdr update`".to_string(),
+ context: format!("detach, then run `{install_command}`"),
target: None,
});
}
@@ -953,6 +957,7 @@ mod tests {
let updates = state.handle_app_event(crate::events::AppEvent::UpdateReady {
version: "0.5.0".into(),
+ install_command: "herdr update".into(),
});
assert!(updates.is_empty());
@@ -1500,6 +1505,7 @@ mod tests {
let updates = state.handle_app_event(AppEvent::UpdateReady {
version: "0.5.0".into(),
+ install_command: "herdr update".into(),
});
assert!(updates.is_empty());
@@ -1513,6 +1519,27 @@ mod tests {
}
#[test]
+ fn update_ready_uses_event_install_command_in_toast() {
+ let mut state = AppState::test_new();
+ state.toast_config.delivery = crate::config::ToastDelivery::Herdr;
+
+ state.handle_app_event(AppEvent::UpdateReady {
+ version: "0.5.0".into(),
+ install_command: "brew update && brew upgrade herdr".into(),
+ });
+
+ assert_eq!(
+ state.update_install_command,
+ "brew update && brew upgrade herdr"
+ );
+ let toast = state.toast.as_ref().expect("update toast");
+ assert_eq!(
+ toast.context,
+ "detach, then run `brew update && brew upgrade herdr`"
+ );
+ }
+
+ #[test]
fn toggle_fullscreen_works() {
let mut state = app_with_workspaces(&["test"]);
state.workspaces[0].test_split(Direction::Horizontal);
diff --git a/src/app/api.rs b/src/app/api.rs
index 50a56624..5f959365 100644
--- a/src/app/api.rs
+++ b/src/app/api.rs
@@ -58,8 +58,12 @@ impl App {
None
};
- let update_ready_version = if let AppEvent::UpdateReady { version } = &ev {
- Some(version.clone())
+ let update_ready = if let AppEvent::UpdateReady {
+ version,
+ install_command,
+ } = &ev
+ {
+ Some((version.clone(), install_command.clone()))
} else {
None
};
@@ -93,10 +97,10 @@ impl App {
_ => unreachable!("toast delivery was checked above"),
};
- if let Some(version) = update_ready_version {
+ if let Some((version, install_command)) = update_ready {
let _ = notify(
&format!("v{version} available"),
- Some("detach, then run `herdr update`"),
+ Some(&format!("detach, then run `{install_command}`")),
);
} else {
for update in &pane_updates {
diff --git a/src/app/mod.rs b/src/app/mod.rs
index bc732f57..d9f666ed 100644
--- a/src/app/mod.rs
+++ b/src/app/mod.rs
@@ -291,6 +291,7 @@ impl App {
.filter(|notes| notes.preview)
.map(|notes| notes.version.clone());
let latest_release_notes_available = latest_release_notes.is_some();
+ let update_install_command = crate::update::update_install_command().to_string();
let mode = if config.should_show_onboarding() {
state::Mode::Onboarding
@@ -355,6 +356,7 @@ impl App {
selection: None,
context_menu: None,
update_available,
+ update_install_command,
latest_release_notes_available,
update_dismissed: false,
config_diagnostic,
@@ -1883,6 +1885,7 @@ mod tests {
app.event_tx
.try_send(AppEvent::UpdateReady {
version: format!("9.9.{i}"),
+ install_command: "herdr update".into(),
})
.unwrap();
}
diff --git a/src/app/state.rs b/src/app/state.rs
index 237e25a0..45473435 100644
--- a/src/app/state.rs
+++ b/src/app/state.rs
@@ -859,6 +859,7 @@ pub struct AppState {
pub context_menu: Option<ContextMenuState>,
// Notifications
pub update_available: Option<String>,
+ pub update_install_command: String,
pub latest_release_notes_available: bool,
pub update_dismissed: bool,
pub config_diagnostic: Option<String>,
@@ -1049,6 +1050,7 @@ impl AppState {
selection: None,
context_menu: None,
update_available: None,
+ update_install_command: "herdr update".into(),
latest_release_notes_available: false,
update_dismissed: false,
config_diagnostic: None,