Skip to main content

Mountain/RPC/CocoonService/Window/
OpenExternal.rs

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