diff --git a/crates/komorebi-bar-core/src/platform.rs b/crates/komorebi-bar-core/src/platform.rs index c7c2316e..7117872d 100644 --- a/crates/komorebi-bar-core/src/platform.rs +++ b/crates/komorebi-bar-core/src/platform.rs @@ -31,6 +31,9 @@ pub trait BarPlatform: Send + Sync { /// The GitHub API URL that says which release of this platform's komorebi is the latest. fn latest_release_api_url(&self) -> &'static str; + /// The page of this platform's release `version` that the update widget opens when clicked. + fn release_page_url(&self, version: &str) -> String; + /// The icon of the program a command string would start (Windows: the executable's icon; /// macOS: none). fn command_icon(&self, command: &str) -> Option; diff --git a/crates/komorebi-bar-core/src/widgets/update.rs b/crates/komorebi-bar-core/src/widgets/update.rs index 04c068ea..c7bd51be 100644 --- a/crates/komorebi-bar-core/src/widgets/update.rs +++ b/crates/komorebi-bar-core/src/widgets/update.rs @@ -83,7 +83,7 @@ impl Update { { let client = reqwest::blocking::Client::new(); if let Ok(response) = client - .get("https://api.github.com/repos/LGUG2Z/komorebi/releases/latest") + .get(platform().latest_release_api_url()) .header("User-Agent", "komorebi-bar-version-checker") .send() { @@ -143,10 +143,9 @@ impl BarWidget for Update { if SelectableFrame::new(false) .show(ui, |ui| ui.add(Label::new(layout_job).selectable(false))) .clicked() - && let Err(error) = platform().open_system_tool(SystemTool::Url(format!( - "https://github.com/LGUG2Z/komorebi/releases/v{}", - self.latest_version - ))) + && let Err(error) = platform().open_system_tool(SystemTool::Url( + platform().release_page_url(&self.latest_version), + )) { eprintln!("{error}") } diff --git a/komorebi-bar/src/macos/os.rs b/komorebi-bar/src/macos/os.rs index 3275456e..dbab39cd 100644 --- a/komorebi-bar/src/macos/os.rs +++ b/komorebi-bar/src/macos/os.rs @@ -37,6 +37,10 @@ impl BarPlatform for MacBar { "https://api.github.com/repos/LGUG2Z/komorebi-for-mac/releases/latest" } + fn release_page_url(&self, version: &str) -> String { + format!("https://github.com/LGUG2Z/komorebi-for-mac/releases/tag/v{version}") + } + fn calendar_icon(&self) -> &'static str { CALENDAR } diff --git a/komorebi-bar/src/windows/os.rs b/komorebi-bar/src/windows/os.rs index 5ba8990c..ed41c03f 100644 --- a/komorebi-bar/src/windows/os.rs +++ b/komorebi-bar/src/windows/os.rs @@ -35,6 +35,10 @@ impl BarPlatform for WindowsBar { "https://api.github.com/repos/LGUG2Z/komorebi/releases/latest" } + fn release_page_url(&self, version: &str) -> String { + format!("https://github.com/LGUG2Z/komorebi/releases/v{version}") + } + fn calendar_icon(&self) -> &'static str { CALENDAR_DOTS }