mirror of
https://github.com/infinilabs/coco-app.git
synced 2025-12-29 00:24:46 +01:00
feat: support for enable and disable services (#189)
This commit is contained in:
@@ -160,7 +160,6 @@ pub fn run() {
|
||||
let settings_window = app.get_webview_window(SETTINGS_WINDOW_LABEL).unwrap();
|
||||
setup::default(app, main_window.clone(), settings_window.clone());
|
||||
|
||||
|
||||
Ok(())
|
||||
})
|
||||
.on_window_event(|window, event| match event {
|
||||
@@ -174,7 +173,6 @@ pub fn run() {
|
||||
.build(ctx)
|
||||
.expect("error while running tauri application");
|
||||
|
||||
|
||||
// Create a single Tokio runtime instance
|
||||
let rt = RT::new().expect("Failed to create Tokio runtime");
|
||||
let app_handle = app.handle().clone();
|
||||
@@ -237,8 +235,7 @@ async fn init_app_search_source<R: Runtime>(app_handle: &AppHandle<R>) {
|
||||
// Remove any `None` values if `home_dir()` fails
|
||||
let app_dirs: Vec<PathBuf> = dir.into_iter().flatten().collect();
|
||||
|
||||
let application_search =
|
||||
local::application::ApplicationSearchSource::new(1000f64, app_dirs);
|
||||
let application_search = local::application::ApplicationSearchSource::new(1000f64, app_dirs);
|
||||
|
||||
// Register the application search source
|
||||
let registry = app_handle.state::<SearchSourceRegistry>();
|
||||
|
||||
@@ -437,10 +437,9 @@ pub async fn remove_coco_server<R: Runtime>(
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
pub async fn enable_server<R: Runtime>(
|
||||
app_handle: AppHandle<R>,
|
||||
id: String,
|
||||
) -> Result<(), ()> {
|
||||
pub async fn enable_server<R: Runtime>(app_handle: AppHandle<R>, id: String) -> Result<(), ()> {
|
||||
println!("enable_server: {}", id);
|
||||
|
||||
let server = get_server_by_id(id.as_str());
|
||||
if let Some(mut server) = server {
|
||||
server.enabled = true;
|
||||
@@ -458,10 +457,9 @@ pub async fn enable_server<R: Runtime>(
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
pub async fn disable_server<R: Runtime>(
|
||||
app_handle: AppHandle<R>,
|
||||
id: String,
|
||||
) -> Result<(), ()> {
|
||||
pub async fn disable_server<R: Runtime>(app_handle: AppHandle<R>, id: String) -> Result<(), ()> {
|
||||
println!("disable_server: {}", id);
|
||||
|
||||
let server = get_server_by_id(id.as_str());
|
||||
if let Some(mut server) = server {
|
||||
server.enabled = false;
|
||||
@@ -571,6 +569,7 @@ fn test_trim_endpoint_last_forward_slash() {
|
||||
},
|
||||
},
|
||||
priority: 0,
|
||||
enabled: true,
|
||||
};
|
||||
|
||||
trim_endpoint_last_forward_slash(&mut server);
|
||||
|
||||
Reference in New Issue
Block a user