mirror of
https://github.com/infinilabs/coco-app.git
synced 2025-12-16 03:27:43 +01:00
fix: panic when opening view extension via hotkey (#949)
Another change that should be made to fix the View extension hotkey. I
should include it in this commit[1] but I forgot to.
[1]: e029ddf2ba
This commit is contained in:
27
src-tauri/src/extension/third_party/mod.rs
vendored
27
src-tauri/src/extension/third_party/mod.rs
vendored
@@ -248,6 +248,24 @@ impl ThirdPartyExtensionsSearchSource {
|
||||
if extension.supports_alias_hotkey() {
|
||||
if let Some(ref hotkey) = extension.hotkey {
|
||||
let on_opened = extension.on_opened().unwrap_or_else(|| panic!( "extension has hotkey, but on_open() returns None, extension ID [{}], extension type [{:?}]", extension.id, extension.r#type));
|
||||
let url = on_opened.url();
|
||||
let extension_type_string = extension.r#type.to_string();
|
||||
let document = Document {
|
||||
id: extension.id.clone(),
|
||||
title: Some(extension.name.clone()),
|
||||
icon: Some(extension.icon.clone()),
|
||||
on_opened: Some(on_opened.clone()),
|
||||
url: Some(url),
|
||||
category: Some(extension_type_string.clone()),
|
||||
source: Some(DataSourceReference {
|
||||
id: Some(extension_type_string.clone()),
|
||||
name: Some(extension_type_string.clone()),
|
||||
icon: None,
|
||||
r#type: Some(extension_type_string),
|
||||
}),
|
||||
|
||||
..Default::default()
|
||||
};
|
||||
|
||||
let extension_id_clone = extension.id.clone();
|
||||
|
||||
@@ -258,9 +276,16 @@ impl ThirdPartyExtensionsSearchSource {
|
||||
let extension_id_clone = extension_id_clone.clone();
|
||||
let app_handle_clone = tauri_app_handle.clone();
|
||||
|
||||
let mut args = HashMap::new();
|
||||
args.insert(
|
||||
String::from("document"),
|
||||
serde_json::to_value(&document).unwrap(),
|
||||
);
|
||||
|
||||
if event.state() == ShortcutState::Pressed {
|
||||
async_runtime::spawn(async move {
|
||||
let result = open(app_handle_clone, on_opened_clone, None).await;
|
||||
let result =
|
||||
open(app_handle_clone, on_opened_clone, Some(args)).await;
|
||||
if let Err(msg) = result {
|
||||
log::warn!(
|
||||
"failed to open extension [{}], error [{}]",
|
||||
|
||||
Reference in New Issue
Block a user