Skip to content

Commit 70b048f

Browse files
authored
fix: take coco server back on refresh (#696)
* fix: take coco server back on refresh * chore: update release notes:
1 parent 45083f8 commit 70b048f

2 files changed

Lines changed: 19 additions & 0 deletions

File tree

docs/content.en/docs/release-notes/_index.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ Information about release notes of Coco Server is provided here.
1717

1818
- fix: quick ai state synchronous #693
1919
- fix: toggle extension should register/unregister hotkey #691
20+
- fix: take coco server back on refresh #696
2021

2122
### ✈️ Improvements
2223

src-tauri/src/server/servers.rs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -338,6 +338,9 @@ pub async fn refresh_coco_server_info<R: Runtime>(
338338
let mut updated_server: Server = serde_json::from_str(&body)
339339
.map_err(|e| format!("Failed to deserialize the response: {}", e))?;
340340

341+
// Mark server as online
342+
let _ = mark_server_as_online(app_handle.clone(), &id).await;
343+
341344
// Restore local state
342345
updated_server.id = id.clone();
343346
updated_server.builtin = is_builtin;
@@ -475,6 +478,21 @@ pub async fn try_register_server_to_search_source(
475478
}
476479
}
477480

481+
#[tauri::command]
482+
pub async fn mark_server_as_online<R: Runtime>(
483+
app_handle: AppHandle<R>, id: &str) -> Result<(), ()> {
484+
// println!("server_is_offline: {}", id);
485+
let server = get_server_by_id(id);
486+
if let Some(mut server) = server {
487+
server.available = true;
488+
server.health = None;
489+
save_server(&server);
490+
491+
try_register_server_to_search_source(app_handle.clone(), &server).await;
492+
}
493+
Ok(())
494+
}
495+
478496
#[tauri::command]
479497
pub async fn mark_server_as_offline<R: Runtime>(
480498
app_handle: AppHandle<R>, id: &str) -> Result<(), ()> {

0 commit comments

Comments
 (0)