Skip to content

Commit 213bc8a

Browse files
address review feedback
1 parent 75206ff commit 213bc8a

File tree

2 files changed

+41
-6
lines changed

2 files changed

+41
-6
lines changed

apps/desktop/src-tauri/src/deeplink_actions.rs

Lines changed: 34 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@ use cap_recording::{
22
RecordingMode, feeds::camera::DeviceOrModelID, sources::screen_capture::ScreenCaptureTarget,
33
};
44
use serde::{Deserialize, Serialize};
5-
use std::path::{Path, PathBuf};
5+
use std::path::PathBuf;
66
use tauri::{AppHandle, Manager, Url};
77
use tracing::trace;
88

9-
use crate::{App, ArcLock, recording::StartRecordingInputs, windows::ShowCapWindow};
9+
use crate::{App, ArcLock, recording::StartRecordingInputs, windows::{CapWindowId, ShowCapWindow}};
1010

1111
#[derive(Debug, Serialize, Deserialize)]
1212
#[serde(rename_all = "snake_case")]
@@ -34,7 +34,26 @@ pub enum DeepLinkAction {
3434
},
3535
}
3636

37+
pub fn setup_deeplink_handler(app_handle: &AppHandle) {
38+
let app_handle = app_handle.clone();
39+
app_handle
40+
.clone()
41+
.plugin(tauri_plugin_deep_link::init())
42+
.ok();
43+
44+
let handle = app_handle.clone();
45+
app_handle.listen("deep-link://new-url", move |event| {
46+
if let Ok(urls) = serde_json::from_str::<Vec<Url>>(event.payload()) {
47+
handle_urls(&handle, urls);
48+
}
49+
});
50+
}
51+
3752
pub fn handle(app_handle: &AppHandle, urls: Vec<Url>) {
53+
handle_urls(app_handle, urls);
54+
}
55+
56+
fn handle_urls(app_handle: &AppHandle, urls: Vec<Url>) {
3857
trace!("Handling deep actions for: {:?}", &urls);
3958

4059
let actions: Vec<_> = urls
@@ -145,14 +164,23 @@ impl DeepLinkAction {
145164
.map(|_| ())
146165
}
147166
DeepLinkAction::StopRecording => {
148-
crate::recording::stop_recording(app.clone(), app.state()).await
167+
crate::recording::stop_recording(app.clone(), app.state())
168+
.await
169+
.map_err(|e| e.to_string())
149170
}
150171
DeepLinkAction::OpenEditor { project_path } => {
151-
crate::open_project_from_path(Path::new(&project_path), app.clone())
172+
use crate::windows::ShowCapWindow;
173+
CapWindowId::Editor {
174+
project_path: project_path.clone(),
175+
}
176+
.show(app)
177+
.map_err(|e| e.to_string())
152178
}
153179
DeepLinkAction::OpenSettings { page } => {
154-
crate::show_window(app.clone(), ShowCapWindow::Settings { page }).await
180+
CapWindowId::Settings { page }
181+
.show(app)
182+
.map_err(|e| e.to_string())
155183
}
156184
}
157185
}
158-
}
186+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import { open, showHUD } from "@raycast/api";
2+
3+
export default async function startRecording() {
4+
const url = "cap://action?value=" + encodeURIComponent(JSON.stringify({ start_recording: {} }));
5+
await open(url);
6+
await showHUD("Starting Cap recording…");
7+
}

0 commit comments

Comments
 (0)