Skip to content

Commit 024dc31

Browse files
authored
feat: expose applications::get_default_search_paths (#352)
1 parent 0948ab1 commit 024dc31

4 files changed

Lines changed: 72 additions & 7 deletions

File tree

src-tauri/Cargo.lock

Lines changed: 51 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src-tauri/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ tauri-plugin-drag = "2"
4141
tauri-plugin-macos-permissions = "2"
4242
tauri-plugin-fs-pro = "2"
4343
tauri-plugin-screenshots = "2"
44-
applications = "0.3.0"
44+
applications = "0.3.1"
4545

4646
tokio-native-tls = "0.3" # For wss connections
4747
tokio = { version = "1", features = ["full"] }

src-tauri/src/lib.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,8 @@ pub fn run() {
131131
server::attachment::upload_attachment,
132132
server::attachment::get_attachment,
133133
server::attachment::delete_attachment,
134-
server::transcription::transcription
134+
server::transcription::transcription,
135+
local::application::get_default_search_paths
135136
])
136137
.setup(|app| {
137138
let registry = SearchSourceRegistry::default();
@@ -411,4 +412,4 @@ async fn get_app_search_source<R: Runtime>(app_handle: AppHandle<R>) -> Result<(
411412
#[tauri::command]
412413
async fn show_settings(app_handle: AppHandle) {
413414
open_settings(&app_handle);
414-
}
415+
}

src-tauri/src/local/application.rs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,23 @@ use std::path::{Path, PathBuf};
1212
use tauri::{AppHandle, Runtime};
1313
use tauri_plugin_fs_pro::{icon, name};
1414

15+
#[tauri::command]
16+
pub fn get_default_search_paths<R: Runtime>(app_handle: AppHandle<R>) -> Vec<String> {
17+
let paths = applications::get_default_search_paths();
18+
let ret = Vec::with_capacity(paths.len());
19+
for search_path in paths {
20+
let path = search_path.path;
21+
let path_string = path
22+
.into_os_string()
23+
.into_string()
24+
.expect("path should be UTF-8 encoded");
25+
26+
ret.push(path_string);
27+
}
28+
29+
ret
30+
}
31+
1532
pub struct ApplicationSearchSource {
1633
base_score: f64,
1734
icons: HashMap<String, PathBuf>,

0 commit comments

Comments
 (0)