mirror of
https://github.com/outbackdingo/firezone.git
synced 2026-01-27 10:18:54 +00:00
chore(linux GUI): enable update notifications (#4820)
Closes #4815 <img width="402" alt="image" src="https://github.com/firezone/firezone/assets/13400041/ff8f3b7a-f7b1-4cae-a3e4-1d1311054b69"> You can copy-paste the URL, which is better than nothing. We could also put an update nag in the tray menu if we really wanted, it would be easy to catch the click from that.
This commit is contained in:
@@ -468,6 +468,8 @@ fn handle_system_tray_event(app: &tauri::AppHandle, event: TrayMenuEvent) -> Res
|
||||
Ok(())
|
||||
}
|
||||
|
||||
// Allow dead code because `UpdateNotificationClicked` doesn't work on Linux yet
|
||||
#[allow(dead_code)]
|
||||
pub(crate) enum ControllerRequest {
|
||||
/// The GUI wants us to use these settings in-memory, they've already been saved to disk
|
||||
ApplySettings(AdvancedSettings),
|
||||
@@ -615,7 +617,7 @@ impl Controller {
|
||||
if let Some(req) = self.auth.start_sign_in()? {
|
||||
let url = req.to_url(&self.advanced_settings.auth_base_url);
|
||||
self.refresh_system_tray_menu()?;
|
||||
os::open_url(&self.app, &url)?;
|
||||
tauri::api::shell::open(&self.app.shell_scope(), url.expose_secret(), None)?;
|
||||
self.app
|
||||
.get_window("welcome")
|
||||
.context("Couldn't get handle to Welcome window")?
|
||||
@@ -675,12 +677,7 @@ impl Controller {
|
||||
// We don't need to route through the controller here either, we could
|
||||
// use the `open` crate directly instead of Tauri's wrapper
|
||||
// `tauri::api::shell::open`
|
||||
os::show_clickable_notification(
|
||||
&title,
|
||||
"Click here to download the new version.",
|
||||
self.ctlr_tx.clone(),
|
||||
Req::UpdateNotificationClicked(release.download_url),
|
||||
)?;
|
||||
os::show_update_notification(self.ctlr_tx.clone(), &title, release.download_url)?;
|
||||
}
|
||||
Req::UpdateNotificationClicked(download_url) => {
|
||||
tracing::info!("UpdateNotificationClicked in run_controller!");
|
||||
|
||||
@@ -1,11 +1,14 @@
|
||||
use super::{ControllerRequest, CtlrTx};
|
||||
use anyhow::Result;
|
||||
use secrecy::{ExposeSecret, SecretString};
|
||||
use tauri::{api::notification::Notification, Manager};
|
||||
use tauri::api::notification::Notification;
|
||||
|
||||
/// Open a URL in the user's default browser
|
||||
pub(crate) fn open_url(app: &tauri::AppHandle, url: &SecretString) -> Result<()> {
|
||||
tauri::api::shell::open(&app.shell_scope(), url.expose_secret(), None)?;
|
||||
/// Since clickable notifications don't work on Linux yet, the update text
|
||||
/// must be different on different platforms
|
||||
pub(crate) fn show_update_notification(
|
||||
_ctlr_tx: super::CtlrTx,
|
||||
title: &str,
|
||||
download_url: url::Url,
|
||||
) -> Result<()> {
|
||||
show_notification(title, download_url.to_string().as_ref())?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
@@ -17,15 +20,3 @@ pub(crate) fn show_notification(title: &str, body: &str) -> Result<()> {
|
||||
.show()?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// Show a notification that signals `Controller` when clicked
|
||||
pub(crate) fn show_clickable_notification(
|
||||
_title: &str,
|
||||
_body: &str,
|
||||
_tx: CtlrTx,
|
||||
_req: ControllerRequest,
|
||||
) -> Result<()> {
|
||||
// TODO: Tauri doesn't seem to have clickable notifications on Linux.
|
||||
// No indication if it'll be in 2.x or if there's a good third-party replacement
|
||||
Ok(())
|
||||
}
|
||||
|
||||
@@ -1,12 +1,20 @@
|
||||
use super::{ControllerRequest, CtlrTx};
|
||||
use anyhow::{Context, Result};
|
||||
use connlib_shared::BUNDLE_ID;
|
||||
use secrecy::{ExposeSecret, SecretString};
|
||||
use tauri::Manager;
|
||||
|
||||
/// Open a URL in the user's default browser
|
||||
pub(crate) fn open_url(app: &tauri::AppHandle, url: &SecretString) -> Result<()> {
|
||||
tauri::api::shell::open(&app.shell_scope(), url.expose_secret(), None)?;
|
||||
/// Since clickable notifications don't work on Linux yet, the update text
|
||||
/// must be different on different platforms
|
||||
pub(crate) fn show_update_notification(
|
||||
ctlr_tx: CtlrTx,
|
||||
title: &str,
|
||||
download_url: url::Url,
|
||||
) -> Result<()> {
|
||||
show_clickable_notification(
|
||||
title,
|
||||
"Click here to download the new version.",
|
||||
ctlr_tx,
|
||||
ControllerRequest::UpdateNotificationClicked(download_url),
|
||||
)?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
@@ -70,6 +78,6 @@ pub(crate) fn show_clickable_notification(
|
||||
Ok(())
|
||||
})
|
||||
.show()
|
||||
.context("Couldn't show clickable notification")?;
|
||||
.context("Couldn't show clickable URL notification")?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user