mirror of
https://github.com/LGUG2Z/komorebi.git
synced 2026-11-20 15:41:38 +01:00
fix(bar): the update widget asks the platform for its release URLs
The update widget's refresh thread polled the Windows repository's GitHub API on every platform (a hard-coded second URL, while the first fetch went through BarPlatform::latest_release_api_url), and the page the click opens was built for the Windows repository, so on macOS the widget compared the mac version against Windows releases after the first refresh and linked to the wrong project. The refresh now uses latest_release_api_url, and a new BarPlatform::release_page_url(version) builds the click target: Windows keeps https://github.com/LGUG2Z/komorebi/releases/v{version} exactly, macOS gets https://github.com/LGUG2Z/komorebi-for-mac/releases/tag/v{version}. BEHAVIOUR (macOS): the update widget compares against and links to the komorebi-for-mac releases. Windows output is unchanged (same URLs). Gate: macOS hand-check (see docs/dev/macos-handcheck.md); Windows needs no e2e. Verified: see the following revisions' fast-check results; not run on a Mac.
This commit is contained in:
1 parent
0f851bfb0a
commit
d7673d436f
4 files changed
+15
-5
No files matched your search
@@ -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<ImageIcon>;
|
||||
|
||||
@@ -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}")
|
||||
}
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user