Skip to content

Commit

Permalink
feat: support for enable and disable services (#189)
Browse files Browse the repository at this point in the history
  • Loading branch information
ayangweb authored Feb 24, 2025
1 parent 3b6c9e3 commit 8da843a
Show file tree
Hide file tree
Showing 5 changed files with 459 additions and 432 deletions.
5 changes: 1 addition & 4 deletions src-tauri/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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();
Expand Down Expand Up @@ -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>();
Expand Down
15 changes: 7 additions & 8 deletions src-tauri/src/server/servers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -571,6 +569,7 @@ fn test_trim_endpoint_last_forward_slash() {
},
},
priority: 0,
enabled: true,
};

trim_endpoint_last_forward_slash(&mut server);
Expand Down
Loading

0 comments on commit 8da843a

Please # to comment.