fix(KAN-65): synchronize update menu and remove dock badge
CI/CD / preconditions (pull_request) Successful in 2s
Native JavaScript checks / Native launcher and release tests (pull_request) Successful in 1m4s
macOS checks / Native Rust tests and unsigned build (pull_request) Successful in 1m37s
CI/CD / Publish immutable image (pull_request) Canceled after 0s
CI/CD / test_and_check_app (pull_request) Canceled after 1m38s

This commit is contained in:
2026-09-28 08:01:35 +02:00
parent 4ee047311f
commit 4f9bf2dec4
5 changed files with 48 additions and 9 deletions
+15 -6
View File
@@ -123,19 +123,28 @@ fn trusted_navigation(url: &Url) -> bool {
&& url.username().is_empty()
&& url.password().is_none()
}
pub fn refresh_menu(app: &AppHandle, available: bool, busy: bool) {
if let Some(menu) = app
.menu()
.and_then(|menu| menu.get("app-menu"))
.and_then(|item| {
item.as_submenu()
.and_then(|menu| menu.get("install-update"))
})
{
if let Some(item) = menu.as_menuitem() {
let _ = item.set_enabled(available && !busy);
}
}
}
pub fn refresh(app: &AppHandle) {
let (view, available, busy) = {
let state = app.state::<Mutex<State>>();
let state = state.lock().unwrap();
(state.view.clone(), state.update.is_some(), state.busy())
};
if let Some(menu) = app.menu().and_then(|m| m.get("install-update")) {
if let Some(item) = menu.as_menuitem() {
let _ = item.set_enabled(available && !busy);
}
}
refresh_menu(app, available, busy);
if let Some(window) = app.get_webview_window("updates") {
let _ = window.set_badge_label(available.then(|| crate::locale::en::UPDATE_BADGE.into()));
if let Ok(json) = serde_json::to_string(&view) {
let _ = window.eval(format!("window.updateStatus?.({json})"));
}