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
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:
@@ -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})"));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user