Skip to content

Commit e78fe4a

Browse files
authored
fix: broken windows search (#801)
This commit fixes the search issue introduced by [commit](5c0a865). We have no idea why the tauri command `get_app_search_source` won't be invoked after that commit on Windows. This commit resolves the issue by moving the extension init logic to the Rust side. Also, update the querysource logs in `quey_coco_fusion()`, the old one won't say anything if the querysource list is empty, the new one will tell us that.
1 parent 60fd79f commit e78fe4a

3 files changed

Lines changed: 28 additions & 10 deletions

File tree

src-tauri/src/lib.rs

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,22 @@ pub fn run() {
198198

199199
block_on(async {
200200
init(app.handle()).await;
201+
202+
// We want all the extensions here, so no filter condition specified.
203+
match extension::list_extensions(app_handle.clone(), None, None, false).await {
204+
Ok((_found_invalid_extensions, extensions)) => {
205+
// Initializing extension relies on SearchSourceRegistry, so this should
206+
// be executed after `app.manage(registry)`
207+
if let Err(e) =
208+
extension::init_extensions(app_handle.clone(), extensions).await
209+
{
210+
log::error!("initializing extensions failed with error [{}]", e);
211+
}
212+
}
213+
Err(e) => {
214+
log::error!("listing extensions failed with error [{}]", e);
215+
}
216+
}
201217
});
202218

203219
shortcut::enable_shortcut(app);
@@ -412,13 +428,6 @@ fn move_window_to_active_monitor<R: Runtime>(window: &WebviewWindow<R>) {
412428

413429
#[tauri::command]
414430
async fn get_app_search_source(app_handle: AppHandle) -> Result<(), String> {
415-
// We want all the extensions here, so no filter condition specified.
416-
let (_found_invalid_extensions, extensions) =
417-
extension::list_extensions(app_handle.clone(), None, None, false)
418-
.await
419-
.map_err(|e| e.to_string())?;
420-
extension::init_extensions(app_handle.clone(), extensions).await?;
421-
422431
let _ = server::connector::refresh_all_connectors(&app_handle).await;
423432
let _ = server::datasource::refresh_all_datasources(&app_handle).await;
424433

src-tauri/src/search/mod.rs

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,12 +83,22 @@ pub async fn query_coco_fusion(
8383
let timeout_duration = Duration::from_millis(query_timeout);
8484

8585
log::debug!(
86-
"{}(): {:?}, timeout: {:?}",
86+
"{}() invoked with parameters: from: [{}], size: [{}], query_strings: [{:?}], timeout: [{:?}]",
8787
function_name!(),
88+
from,
89+
size,
8890
query_strings,
8991
timeout_duration
9092
);
9193

94+
log::debug!(
95+
"will query querysources {:?}",
96+
sources_list
97+
.iter()
98+
.map(|search_source| search_source.get_type().id.clone())
99+
.collect::<Vec<String>>()
100+
);
101+
92102
let search_query = SearchQuery::new(from, size, query_strings.clone());
93103

94104
if let Some(query_source_id) = opt_query_source_id {
@@ -135,7 +145,6 @@ pub async fn query_coco_fusion(
135145
} else {
136146
for query_source_trait_object in sources_list {
137147
let query_source = query_source_trait_object.get_type().clone();
138-
log::debug!("will query querysource [{}]", query_source.id);
139148
futures.push(same_type_futures(
140149
query_source,
141150
query_source_trait_object,

src/commands/servers.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -417,4 +417,4 @@ export const query_coco_fusion = (payload: {
417417

418418
export const get_app_search_source = () => {
419419
return invokeWithErrorHandler<void>("get_app_search_source");
420-
};
420+
};

0 commit comments

Comments
 (0)