Mountain/RPC/CocoonService/Window/OpenExternal.rs
1//! Forward an `OpenExternal` request to Sky on
2//! `sky://native/openExternal` so the webview can launch the URI in the
3//! system browser/handler.
4
5use serde_json::json;
6use tauri::Emitter;
7use tonic::{Response, Status};
8use ::Vine::Generated::{Empty, OpenExternalRequest};
9
10use crate::{RPC::CocoonService::CocoonServiceImpl, dev_log};
11
12pub async fn Fn(Service:&CocoonServiceImpl, Request:OpenExternalRequest) -> Result<Response<Empty>, Status> {
13 dev_log!("cocoon", "[CocoonService] open_external: {}", Request.uri);
14
15 let _ = Service
16 .environment
17 .ApplicationHandle
18 .emit("sky://native/openExternal", json!({ "url": Request.uri }));
19
20 Ok(Response::new(Empty {}))
21}