fix(core): menu remove js binding not working (#9219)

* Fix menu `remove` js binding not working

* add change file [skip ci]

---------

Co-authored-by: Lucas Nogueira <lucas@tauri.app>
This commit is contained in:
Tony 2024-03-19 20:40:25 +08:00 committed by GitHub
parent fb146339cc
commit 43230cb6b7
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 10 additions and 5 deletions

View File

@ -0,0 +1,5 @@
---
"tauri": patch:bug
---
Fixes the menu plugin `remove` command signature.

View File

@ -536,19 +536,19 @@ fn insert<R: Runtime>(
#[command(root = "crate")]
fn remove<R: Runtime>(
app: AppHandle<R>,
menu_rid: ResourceId,
menu_kind: ItemKind,
rid: ResourceId,
kind: ItemKind,
item: (ResourceId, ItemKind),
) -> crate::Result<()> {
let resources_table = app.resources_table();
let (rid, kind) = item;
match menu_kind {
match kind {
ItemKind::Menu => {
let menu = resources_table.get::<Menu<R>>(menu_rid)?;
let menu = resources_table.get::<Menu<R>>(rid)?;
do_menu_item!(resources_table, rid, kind, |i| menu.remove(&*i))?;
}
ItemKind::Submenu => {
let submenu = resources_table.get::<Submenu<R>>(menu_rid)?;
let submenu = resources_table.get::<Submenu<R>>(rid)?;
do_menu_item!(resources_table, rid, kind, |i| submenu.remove(&*i))?;
}
_ => return Err(anyhow::anyhow!("unexpected menu item kind").into()),