mirror of
https://github.com/tauri-apps/tauri.git
synced 2026-01-31 00:35:19 +01:00
fix(api): "command not found" error when running addPluginListener (#14132)
* fix(api): "command not found" error when running addPluginListener the backend expects the command name to be in snake case we've made this change already for check_permissions and request_permissions, but missed register_listener * fix check instead * update bundle.global.js * code review suggestion * add note * adjust change file * remove unused var * fmt * build
This commit is contained in:
committed by
GitHub
parent
28a2f9bc55
commit
08bda64c25
5
.changes/register-plugin-listener-fix.md
Normal file
5
.changes/register-plugin-listener-fix.md
Normal file
@@ -0,0 +1,5 @@
|
||||
---
|
||||
"@tauri-apps/api": patch:bug
|
||||
---
|
||||
|
||||
Fix `core > addPluginListener` failing on command permission check.
|
||||
File diff suppressed because one or more lines are too long
@@ -185,9 +185,18 @@ async function addPluginListener<T>(
|
||||
cb: (payload: T) => void
|
||||
): Promise<PluginListener> {
|
||||
const handler = new Channel<T>(cb)
|
||||
return invoke(`plugin:${plugin}|registerListener`, { event, handler }).then(
|
||||
() => new PluginListener(plugin, event, handler.id)
|
||||
)
|
||||
try {
|
||||
return invoke(`plugin:${plugin}|register_listener`, {
|
||||
event,
|
||||
handler
|
||||
}).then(() => new PluginListener(plugin, event, handler.id))
|
||||
} catch {
|
||||
// TODO(v3): remove this fallback
|
||||
// note: we must try with camelCase here for backwards compatibility
|
||||
return invoke(`plugin:${plugin}|registerListener`, { event, handler }).then(
|
||||
() => new PluginListener(plugin, event, handler.id)
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
type PermissionState = 'granted' | 'denied' | 'prompt' | 'prompt-with-rationale'
|
||||
|
||||
Reference in New Issue
Block a user