Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 13 additions & 10 deletions apps/desktop/src-tauri/src/deeplink_actions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ pub enum CaptureMode {

#[derive(Debug, Serialize, Deserialize)]
#[serde(rename_all = "snake_case")]
pub enum DeepLinkAction {
pub enum Action {
StartRecording {
capture_mode: CaptureMode,
camera: Option<DeviceOrModelID>,
Expand All @@ -26,6 +26,7 @@ pub enum DeepLinkAction {
mode: RecordingMode,
},
StopRecording,
PauseRecording,
OpenEditor {
project_path: PathBuf,
},
Expand All @@ -41,15 +42,14 @@ pub fn handle(app_handle: &AppHandle, urls: Vec<Url>) {
.into_iter()
.filter(|url| !url.as_str().is_empty())
.filter_map(|url| {
DeepLinkAction::try_from(&url)
Action::try_from(&url)
.map_err(|e| match e {
ActionParseFromUrlError::ParseFailed(msg) => {
eprintln!("Failed to parse deep link \"{}\": {}", &url, msg)
}
ActionParseFromUrlError::Invalid => {
eprintln!("Invalid deep link format \"{}\"", &url)
}
// Likely login action, not handled here.
ActionParseFromUrlError::NotAction => {}
})
.ok()
Expand All @@ -76,7 +76,7 @@ pub enum ActionParseFromUrlError {
NotAction,
}

impl TryFrom<&Url> for DeepLinkAction {
impl TryFrom<&Url> for Action {
type Error = ActionParseFromUrlError;

fn try_from(url: &Url) -> Result<Self, Self::Error> {
Expand Down Expand Up @@ -104,10 +104,10 @@ impl TryFrom<&Url> for DeepLinkAction {
}
}

impl DeepLinkAction {
impl Action {
pub async fn execute(self, app: &AppHandle) -> Result<(), String> {
match self {
DeepLinkAction::StartRecording {
Action::StartRecording {
capture_mode,
camera,
mic_label,
Expand Down Expand Up @@ -143,15 +143,18 @@ impl DeepLinkAction {
.await
.map(|_| ())
}
DeepLinkAction::StopRecording => {
Action::StopRecording => {
crate::recording::stop_recording(app.clone(), app.state()).await
}
DeepLinkAction::OpenEditor { project_path } => {
Action::PauseRecording => {
crate::recording::pause_recording(app.clone(), app.state()).await
}
Action::OpenEditor { project_path } => {
crate::open_project_from_path(Path::new(&project_path), app.clone())
}
DeepLinkAction::OpenSettings { page } => {
Action::OpenSettings { page } => {
crate::show_window(app.clone(), ShowCapWindow::Settings { page }).await
}
}
}
}
}
2 changes: 1 addition & 1 deletion apps/desktop/src-tauri/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2776,7 +2776,7 @@ pub async fn run(recording_logging_handle: LoggingHandle, logs_dir: PathBuf) {
tauri::Builder::default().plugin(tauri_plugin_single_instance::init(|app, args, _cwd| {
trace!("Single instance invoked with args {args:?}");

// This is also handled as a deeplink on some platforms (eg macOS), see deeplink_actions
// This is also handled as a deeplink on some platforms (eg macOS), see deeplink_actions.
let Some(cap_file) = args
.iter()
.find(|arg| arg.ends_with(".cap"))
Expand Down