Skip to main content

Mountain/RPC/CocoonService/Window/
OpenExternal.rs

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